home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / VBXINC.PAK / BIVBX.H
Encoding:
C/C++ Source or Header  |  1997-05-06  |  8.1 KB  |  257 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.  *      $Revision:   9.17  $
  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(_HSZ_DEFINED)
  29.     #if defined(__DECLARE_HSZ) || (! defined(__DDEML_H) && ! defined(_INC_DDEMLH))
  30.       #define _HSZ_DEFINED
  31.       typedef LPSTR          HSZ;
  32.     #endif
  33.   #endif
  34.   
  35.  
  36.   typedef unsigned char  ENUM;
  37.   typedef LPVOID         HCTL;
  38.   typedef short          SHORT;
  39.   typedef unsigned short USHORT;
  40.   typedef HANDLE         HFORMFILE;
  41.   typedef USHORT         ERR;
  42.   typedef WORD           HPIC;
  43.   typedef LPVOID         HLSTR;
  44.  
  45.   #ifdef RC_INVOKED
  46.     #define DLGINIT 240
  47.   #else
  48.     #define RT_DLGINIT MAKEINTRESOURCE(240)
  49.   #endif
  50.  
  51. #endif
  52.  
  53. /* VBX Window Messages */
  54. #define WM_VBXFIREEVENT 0x0360
  55.  
  56. /* VBX Event Structure */
  57. typedef struct VBXEVENT {
  58.   HCTL   Control;
  59.   HWND   Window;
  60.   int    ID;
  61.   int    EventIndex;
  62.   LPCSTR EventName;
  63.   int    NumParams;
  64.   LPVOID ParamList;
  65. } VBXEVENT, FAR * LPVBXEVENT, NEAR * NPVBXEVENT;
  66.  
  67. /* macros for accessing event arguments */
  68. #define VBX_EVENTARGNUM(event,type,index) \
  69.   *(((type FAR * FAR *)(event)->ParamList)[(event)->NumParams - (index) - 1])
  70. #define VBX_EVENTARGSTR(event,index) \
  71.   (((HLSTR FAR *)(event)->ParamList)[(event)->NumParams - (index) - 1])
  72.   
  73. /* Initialization */
  74. BOOL      WINAPI VBXInit(HINSTANCE instance, LPCSTR classPrefix);
  75. void      WINAPI VBXTerm(void);
  76. BOOL      WINAPI VBXEnableDLL(HINSTANCE instApp, HINSTANCE instDLL);
  77.  
  78. /* Controls */
  79. HCTL      WINAPI VBXGetHctl(HWND window);
  80. HWND      WINAPI VBXGetHwnd(HCTL control);
  81. HCTL      WINAPI VBXCreate(HWND windowParent, UINT id,
  82.                            LPCSTR library, LPCSTR cls,
  83.                            LPCSTR title, DWORD style,
  84.                            int x, int y, int w, int h,
  85.                            HFORMFILE file);
  86. BOOL      WINAPI VBXMakeDefCtlNameBuf(HCTL hCtl, LPSTR lpszBuf, int nMax);
  87.  
  88. /* Dialogs */
  89. BOOL WINAPI VBXInitDialog(HWND window, HINSTANCE instance, LPSTR id);
  90.  
  91. /* Properties */
  92. #define PTYPE_CSTRING    0x01  /* HSZ */
  93. #define PTYPE_SHORT      0x02  /* short */
  94. #define PTYPE_LONG       0x03  /* LONG */
  95. #define PTYPE_BOOL       0x04  /* BOOL */
  96. #define PTYPE_COLOR      0x05  /* COLORREF or DWORD */
  97. #define PTYPE_ENUM       0x06  /* BYTE */
  98. #define PTYPE_REAL       0x07  /* float */
  99. #define PTYPE_XPOS       0x08  /* LONG (twips) */
  100. #define PTYPE_XSIZE      0x09  /* LONG (twips) */
  101. #define PTYPE_YPOS       0x0A  /* LONG (twips) */
  102. #define PTYPE_YSIZE      0x0B  /* LONG (twips) */
  103. #define PTYPE_PICTURE    0x0C  /* HPIC */
  104. #define PTYPE_BSTRING    0x0D  /* HLSTR */
  105.  
  106. BOOL   WINAPI VBXGetArrayProp(HCTL control, int index, int element, LPVOID value);
  107. BOOL   WINAPI VBXGetArrayPropByName(HCTL control, LPSTR name, int element, LPVOID value);
  108. int    WINAPI VBXGetNumProps(HCTL control);
  109. BOOL   WINAPI VBXGetProp(HCTL control, int index, LPVOID value);
  110. BOOL   WINAPI VBXGetPropByName(HCTL control, LPSTR name, LPVOID value);
  111. int    WINAPI VBXGetPropIndex(HCTL control, LPCSTR name);
  112. int    WINAPI VBXGetPropNameBuf(HCTL control, int index, LPSTR buffer, int len);
  113. USHORT WINAPI VBXGetPropType(HCTL control, int index);
  114. BOOL   WINAPI VBXIsArrayProp(HCTL control, int index);
  115. BOOL   WINAPI VBXSetArrayProp(HCTL control, int index, int element, LONG value);
  116. BOOL   WINAPI VBXSetArrayPropByName(HCTL control, LPSTR name, int element, LONG value);
  117. BOOL   WINAPI VBXSetProp(HCTL control, int index, LONG value);
  118. BOOL   WINAPI VBXSetPropByName(HCTL control, LPSTR name, LONG value);
  119.  
  120. /* Events */
  121. int    WINAPI VBXGetEventIndex(HCTL control, LPCSTR name);
  122. int    WINAPI VBXGetEventNameBuf(HCTL control, int index, LPSTR buffer, int len);
  123. int    WINAPI VBXGetNumEvents(HCTL control);
  124.  
  125. /* Methods */
  126. BOOL   WINAPI VBXMethodAddItem(HCTL control, int index, LPCSTR item);
  127. BOOL   WINAPI VBXMethodClear(HCTL control);
  128. BOOL   WINAPI VBXMethodDrag(HCTL control, int action);
  129. BOOL   WINAPI VBXMethodLinkSend(HCTL control);
  130. BOOL   WINAPI VBXMethodMove(HCTL control, long x, long y, long w, long h);
  131. BOOL   WINAPI VBXMethodRefresh(HCTL control);
  132. BOOL   WINAPI VBXMethodRemoveItem(HCTL control, int item);
  133. BOOL   WINAPI VBXMethodZOrder(HCTL control, int position);
  134.  
  135. /* Pixel/twips conversions */
  136. SHORT  WINAPI VBXTwp2PixY(LONG twips);
  137. SHORT  WINAPI VBXTwp2PixX(LONG twips);
  138. LONG   WINAPI VBXPix2TwpY(SHORT pixels);
  139. LONG   WINAPI VBXPix2TwpX(SHORT pixels);
  140.  
  141. /* Dynamic strings (HSZ) */
  142. HSZ    WINAPI VBXCreateCString(HANDLE segment, LPSTR string);
  143. HSZ    WINAPI VBXDestroyCString(HSZ string);
  144. int    WINAPI VBXGetCStringBuf(HSZ string, LPSTR buffer, int len);
  145. int    WINAPI VBXGetCStringLength(HSZ string);
  146. int    WINAPI VBXLockCStringBuf(HSZ string, LPSTR buffer, int len);
  147. VOID   WINAPI VBXUnlockCString(HSZ string);
  148.        
  149. /* Color properties */
  150. #define COLOR_SYSCOLOR          0x80000000L
  151. #define MAKESYSCOLOR(iColor)    ((COLORREF)((iColor)|COLOR_SYSCOLOR))
  152.  
  153. #ifndef NO_VBX_PICTURES
  154. /* Pictures */
  155. typedef struct PICTURE {
  156.   BYTE Type;
  157.   union {
  158.     struct {
  159.       HBITMAP  Bitmap;
  160.       HPALETTE Palette;
  161.     } Bitmap;
  162.     struct {
  163.       HANDLE Metafile;
  164.       int xExtent;
  165.       int yExtent;
  166.     } Metafile;
  167.     struct {
  168.       HICON Icon;
  169.     } Icon;
  170.   } Data;
  171.   BYTE unused0;
  172.   BYTE unused1;
  173.   BYTE unused2;
  174.   BYTE unused3;
  175. } PICTURE, NEAR * NPPICTURE;
  176.  
  177. #if !defined(NO_VBX_LPPICTURE)
  178. typedef PICTURE FAR* LPPICTURE;
  179. #endif
  180.  
  181. #define PICTURE_EMPTY       0
  182. #define PICTURE_BMP         1
  183. #define PICTURE_META        2
  184. #define PICTURE_ICON        3
  185.  
  186. HPIC   WINAPI VBXCreatePicture(PICTURE FAR* picture);
  187. VOID   WINAPI VBXDestroyPicture(HPIC pic);
  188. HPIC   WINAPI VBXGetPicture(HPIC pic, PICTURE FAR* picture);
  189. ERR    WINAPI VBXGetPictureFromClipboard(HPIC FAR *pic, HANDLE data, WORD format);
  190. HPIC   WINAPI VBXReferencePicture(HPIC pic);
  191. #endif
  192.  
  193. /* Basic language strings (HLSTR) */
  194. HLSTR  WINAPI VBXCreateBasicString(LPVOID buffer, USHORT len);
  195. VOID   WINAPI VBXDestroyBasicString(HLSTR string);
  196. int    WINAPI VBXGetBasicStringBuf(HLSTR string, LPSTR buffer, int len);
  197. USHORT WINAPI VBXGetBasicStringLength(HLSTR string);
  198. ERR    WINAPI VBXSetBasicString(HLSTR far *string, LPVOID buffer, USHORT len);
  199.  
  200. /* Form files */
  201. HFORMFILE WINAPI VBXCreateFormFile(LONG len, LPVOID data);
  202. BOOL      WINAPI VBXDeleteFormFile(HFORMFILE file);
  203.  
  204. /* Errors */
  205. BOOL      WINAPI VBXGetErrorMessage( ERR FAR * lpErr, LPSTR lpszBuf, int nMax );
  206.  
  207. /* Miscellaneous */
  208. BOOL      WINAPI VBXCopy( HCTL hCtl );
  209. BOOL      WINAPI VBXPaste( HCTL hCtl );
  210. HCTL      WINAPI VBXGetDataSourceControl( HCTL hCtl, BOOL FAR * pbIsRegistered );
  211.  
  212. /*
  213.  * obsolete functions - these functions are limited to 16-bit only
  214.  * and should be replaced as follows:
  215.  *
  216.  * Old (16-bit only)          New (16-bit and 32-bit)
  217.  * -----------------          -----------------------
  218.  * VBXGetBasicStringPtr       VBXGetBasicStringBuf
  219.  * VBXGetCStringPtr           VBXGetCStringBuf
  220.  * VBXGetEventName            VBXGetEventNameBuf
  221.  * VBXGetPropName             VBXGetPropNameBuf
  222.  * VBXLockCString             VBXLockCStringBuf
  223.  * VBXGetProp w/ELEMENTSTRUCT VBXGetArrayProp            
  224.  * VBXSetProp w/ELEMENTSTRUCT VBXSetArrayProp
  225.  * VBXMethod                  not supported
  226.  *
  227.  */
  228.  
  229. #if !defined(__FLAT__)
  230.  
  231. LPSTR  WINAPI VBXGetBasicStringPtr(HLSTR string);
  232. LPSTR  WINAPI VBXGetCStringPtr(HSZ string);
  233. LPCSTR WINAPI VBXGetEventName(HCTL control, int index);
  234. LPCSTR WINAPI VBXGetPropName(HCTL control, int index);
  235. LPSTR  WINAPI VBXLockCString(HSZ string);
  236. BOOL   WINAPI VBXMethod(HCTL control, int method, long far * args);
  237.  
  238. typedef struct ELEMENTSTRUCT {
  239.   LONG   Value;
  240.   USHORT NumElems;
  241.   struct {
  242.     USHORT Type;
  243.     LONG   Index;
  244.   } Element[1];
  245. } ELEMENTSTRUCT, FAR * LPELEMENTSTRUCT, NEAR * NPELEMENTSTRUCT;
  246.  
  247. #endif
  248.  
  249. #include <poppack.h>
  250.  
  251. #ifdef __cplusplus
  252.   }
  253. #endif
  254.  
  255. #endif  /* __BIVBX_H */
  256.  
  257.