home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / BIVBX.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  8KB  |  235 lines

  1. /*  bivbx.h
  2.  
  3.     Defines structs and functions for dealing with VBX controls.
  4.  
  5. */
  6. /*
  7.  *      C/C++ Run Time Library - Version 6.0
  8.  *
  9.  *      Copyright (c) 1993, 1994 by Borland International
  10.  *      All Rights Reserved.
  11.  *
  12.  */
  13.  
  14. #ifndef __BIVBX_H
  15. #define __BIVBX_H
  16.  
  17. #define STRICT
  18. #include <windows.h>
  19.  
  20. #ifdef __cplusplus
  21.   extern "C" {            /* Assume C declarations for C++ */
  22. #endif
  23.  
  24. #include <pshpack1.h>
  25.  
  26. #ifndef __VBX_H
  27.  
  28.   #if ! defined(__DDEML_H) && ! defined(_HSZ_DEFINED)
  29.     #define _HSZ_DEFINED
  30.     typedef LPSTR          HSZ;
  31.   #endif
  32.   typedef unsigned char  ENUM;
  33.   typedef LPVOID         HCTL;
  34.   typedef short          SHORT;
  35.   typedef unsigned short USHORT;
  36.   typedef HANDLE         HFORMFILE;
  37.   typedef USHORT         ERR;
  38.   typedef WORD           HPIC;
  39.   typedef LPVOID         HLSTR;
  40.  
  41.   #ifdef RC_INVOKED
  42.     #define DLGINIT 240
  43.   #else
  44.     #define RT_DLGINIT MAKEINTRESOURCE(240)
  45.   #endif
  46.  
  47. #endif
  48.  
  49. /* VBX Window Messages */
  50. #define WM_VBXFIREEVENT 0x0360
  51.  
  52. /* VBX Event Structure */
  53. typedef struct VBXEVENT {
  54.   HCTL   Control;
  55.   HWND   Window;
  56.   int    ID;
  57.   int    EventIndex;
  58.   LPCSTR EventName;
  59.   int    NumParams;
  60.   LPVOID ParamList;
  61. } VBXEVENT, FAR * LPVBXEVENT, NEAR * NPVBXEVENT;
  62.  
  63. /* macros for accessing event arguments */
  64. #define VBX_EVENTARGNUM(event,type,index) \
  65.   *(((type FAR * FAR *)(event)->ParamList)[(event)->NumParams - (index) - 1])
  66. #define VBX_EVENTARGSTR(event,index) \
  67.   (((HLSTR FAR *)(event)->ParamList)[(event)->NumParams - (index) - 1])
  68.   
  69. /* Initialization */
  70. BOOL WINAPI VBXInit(HINSTANCE instance, LPCSTR classPrefix);
  71. void WINAPI VBXTerm(void);
  72. BOOL WINAPI VBXEnableDLL(HINSTANCE instApp, HINSTANCE instDLL);
  73.  
  74. /* Controls */
  75. HCTL WINAPI VBXGetHctl(HWND window);
  76. HWND WINAPI VBXGetHwnd(HCTL control);
  77. HCTL WINAPI VBXCreate(HWND windowParent, UINT id,
  78.                                   LPCSTR library, LPCSTR cls,
  79.                                   LPCSTR title, DWORD style,
  80.                                   int x, int y, int w, int h,
  81.                                   HFORMFILE file);
  82.  
  83. /* Dialogs */
  84. BOOL WINAPI VBXInitDialog(HWND window, HINSTANCE instance, LPSTR id);
  85.  
  86. /* Properties */
  87. #define PTYPE_CSTRING    0x01  /* HSZ */
  88. #define PTYPE_SHORT      0x02  /* short */
  89. #define PTYPE_LONG       0x03  /* LONG */
  90. #define PTYPE_BOOL       0x04  /* BOOL */
  91. #define PTYPE_COLOR      0x05  /* COLORREF or DWORD */
  92. #define PTYPE_ENUM       0x06  /* BYTE */
  93. #define PTYPE_REAL       0x07  /* float */
  94. #define PTYPE_XPOS       0x08  /* LONG (twips) */
  95. #define PTYPE_XSIZE      0x09  /* LONG (twips) */
  96. #define PTYPE_YPOS       0x0A  /* LONG (twips) */
  97. #define PTYPE_YSIZE      0x0B  /* LONG (twips) */
  98. #define PTYPE_PICTURE    0x0C  /* HPIC */
  99. #define PTYPE_BSTRING    0x0D  /* HLSTR */
  100.  
  101. BOOL   WINAPI VBXGetArrayProp(HCTL control, int index, int element, LPVOID value);
  102. BOOL   WINAPI VBXGetArrayPropByName(HCTL control, LPSTR name, int element, LPVOID value);
  103. int    WINAPI VBXGetNumProps(HCTL control);
  104. BOOL   WINAPI VBXGetProp(HCTL control, int index, LPVOID value);
  105. ERR    WINAPI VBXGetPropByName(HCTL control, LPSTR name, LPVOID value);
  106. int    WINAPI VBXGetPropIndex(HCTL control, LPCSTR name);
  107. int    WINAPI VBXGetPropNameBuf(HCTL control, int index, LPSTR buffer, int len);
  108. USHORT WINAPI VBXGetPropType(HCTL control, int index);
  109. BOOL   WINAPI VBXIsArrayProp(HCTL control, int index);
  110. BOOL   WINAPI VBXSetArrayProp(HCTL control, int index, int element, LONG value);
  111. BOOL   WINAPI VBXSetArrayPropByName(HCTL control, LPSTR name, int element, LONG value);
  112. BOOL   WINAPI VBXSetProp(HCTL control, int index, LONG value);
  113. ERR    WINAPI VBXSetPropByName(HCTL control, LPSTR name, LONG value);
  114.  
  115. /* Events */
  116. int    WINAPI VBXGetEventIndex(HCTL control, LPCSTR name);
  117. int    WINAPI VBXGetEventNameBuf(HCTL control, int index, LPSTR buffer, int len);
  118. int    WINAPI VBXGetNumEvents(HCTL control);
  119.  
  120. /* methods */
  121. BOOL   WINAPI VBXMethodAddItem(HCTL control, int index, LPCSTR item);
  122. BOOL   WINAPI VBXMethodDrag(HCTL control, int action);
  123. BOOL   WINAPI VBXMethodMove(HCTL control, long x, long y, long w, long h);
  124. BOOL   WINAPI VBXMethodRefresh(HCTL control);
  125. BOOL   WINAPI VBXMethodRemoveItem(HCTL control, int item);
  126.  
  127. /* pixel/twips conversions */
  128. SHORT  WINAPI VBXTwp2PixY(LONG twips);
  129. SHORT  WINAPI VBXTwp2PixX(LONG twips);
  130. LONG   WINAPI VBXPix2TwpY(SHORT pixels);
  131. LONG   WINAPI VBXPix2TwpX(SHORT pixels);
  132.  
  133. /* dynamic strings (HSZ) */
  134. HSZ    WINAPI VBXCreateCString(HANDLE segment, LPSTR string);
  135. HSZ    WINAPI VBXDestroyCString(HSZ string);
  136. int    WINAPI VBXGetCStringBuf(HSZ string, LPSTR buffer, int len);
  137. int    WINAPI VBXGetCStringLength(HSZ string);
  138. int    WINAPI VBXLockCStringBuf(HSZ string, LPSTR buffer, int len);
  139. VOID   WINAPI VBXUnlockCString(HSZ string);
  140.        
  141. /* color properties */
  142. #define COLOR_SYSCOLOR          0x80000000L
  143. #define MAKESYSCOLOR(iColor)    ((COLORREF)((iColor)|COLOR_SYSCOLOR))
  144.  
  145. /* pictures */
  146. typedef struct PICTURE {
  147.   BYTE Type;
  148.   union {
  149.     struct {
  150.       HBITMAP  Bitmap;
  151.       HPALETTE Palette;
  152.     } Bitmap;
  153.     struct {
  154.       HANDLE Metafile;
  155.       int xExtent;
  156.       int yExtent;
  157.     } Metafile;
  158.     struct {
  159.       HICON Icon;
  160.     } Icon;
  161.   } Data;
  162.   BYTE unused0;
  163.   BYTE unused1;
  164.   BYTE unused2;
  165.   BYTE unused3;
  166. } PICTURE;
  167.  
  168. #define PICTURE_EMPTY       0
  169. #define PICTURE_BMP         1
  170. #define PICTURE_META        2
  171. #define PICTURE_ICON        3
  172.  
  173. HPIC   WINAPI VBXCreatePicture(PICTURE FAR * picture);
  174. VOID   WINAPI VBXDestroyPicture(HPIC pic);
  175. HPIC   WINAPI VBXGetPicture(HPIC pic, PICTURE FAR * picture);
  176. ERR    WINAPI VBXGetPictureFromClipboard(HPIC FAR *pic, HANDLE data, WORD format);
  177. HPIC   WINAPI VBXReferencePicture(HPIC pic);
  178.  
  179. /* Basic language strings (HLSTR) */
  180. HLSTR  WINAPI VBXCreateBasicString(LPVOID buffer, USHORT len);
  181. VOID   WINAPI VBXDestroyBasicString(HLSTR string);
  182. int    WINAPI VBXGetBasicStringBuf(HLSTR string, LPSTR buffer, int len);
  183. USHORT WINAPI VBXGetBasicStringLength(HLSTR string);
  184. ERR    WINAPI VBXSetBasicString(HLSTR far *string, LPVOID buffer, USHORT len);
  185.  
  186. /* form files */
  187. HFORMFILE WINAPI VBXCreateFormFile(LONG len, LPVOID data);
  188. BOOL      WINAPI VBXDeleteFormFile(HFORMFILE file);
  189.  
  190. /*
  191.  * obsolete functions - these functions are limited to 16-bit only
  192.  * and should be replaced as follows:
  193.  *
  194.  * Old (16-bit only)          New (16-bit and 32-bit)
  195.  * -----------------          -----------------------
  196.  * VBXGetBasicStringPtr       VBXGetBasicStringBuf
  197.  * VBXGetCStringPtr           VBXGetCStringBuf
  198.  * VBXGetEventName            VBXGetEventNameBuf
  199.  * VBXGetPropName             VBXGetPropNameBuf
  200.  * VBXLockCString             VBXLockCStringBuf
  201.  * VBXGetProp w/ELEMENTSTRUCT VBXGetArrayProp            
  202.  * VBXSetProp w/ELEMENTSTRUCT VBXSetArrayProp
  203.  * VBXMethod                  not supported
  204.  *
  205.  */
  206.  
  207. #if !defined(__FLAT__)
  208.  
  209. LPSTR  WINAPI VBXGetBasicStringPtr(HLSTR string);
  210. LPSTR  WINAPI VBXGetCStringPtr(HSZ string);
  211. LPCSTR WINAPI VBXGetEventName(HCTL control, int index);
  212. LPCSTR WINAPI VBXGetPropName(HCTL control, int index);
  213. LPSTR  WINAPI VBXLockCString(HSZ string);
  214. BOOL   WINAPI VBXMethod(HCTL control, int method, long far * args);
  215.  
  216. typedef struct ELEMENTSTRUCT {
  217.   LONG   Value;
  218.   USHORT NumElems;
  219.   struct {
  220.     USHORT Type;
  221.     LONG   Index;
  222.   } Element[1];
  223. } ELEMENTSTRUCT, FAR * LPELEMENTSTRUCT, NEAR * NPELEMENTSTRUCT;
  224.  
  225. #endif
  226.  
  227. #include <poppack.h>
  228.  
  229. #ifdef __cplusplus
  230.   }
  231. #endif
  232.  
  233. #endif  /* __BIVBX_H */
  234.  
  235.