home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / inttab.pak / BIVBX.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  7.6 KB  |  234 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Visual Component Library                 }
  4. {                                                       }
  5. {       Copyright (c) 1995 Borland International        }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. {  bivbx.pas
  10.     Defines structs and functions for dealing with VBX controls. }
  11.  
  12. unit BIVBX;
  13.  
  14. interface
  15.  
  16. uses Messages, WinTypes;
  17.  
  18. type
  19.   { VBX Base Types }
  20.   Err = Word;
  21.   HPic = 0..65535;
  22.   HSZ = ^Char;
  23.   HLStr = ^Word;
  24.   HCTL = ^Byte;
  25.   HFormFile = THandle;
  26.  
  27.   { VBX Event Structure }
  28.   PVBXEvent = ^TVBXEvent;
  29.   TVBXEvent = record
  30.     Control: HCTL;
  31.     Window: HWND;
  32.     ID: Integer;
  33.     EventIndex: Integer;
  34.     EventName: PChar;
  35.     NumParams: Integer;
  36.     ParamList: Pointer;
  37.   end;
  38.  
  39.   PEventInfo = ^TEventInfo;
  40.   TEventInfo = record
  41.     Name: Word;
  42.     cParms: Word;
  43.     cwParms: Word;
  44.     ParmTypes: Word;
  45.     ParmProf: Word;
  46.     Flags: Longint;
  47.   end;
  48.  
  49.   PPropInfo = ^TPropInfo;
  50.   TPropInfo = record
  51.     Name: Word;
  52.     Flags: Longint;
  53.     offsetData: Byte;
  54.     infoData: Byte;
  55.     dataDefault: Longint;
  56.     ByteList: Word;
  57.     ByteMax: Byte;
  58.   end;
  59.  
  60.   TWMVBXFireEvent = record
  61.     Msg: Cardinal;
  62.     Unused: Word;
  63.     VBXEvent: PVBXEvent;
  64.     Result: Longint;
  65.   end;
  66.  
  67.   TBmp = record
  68.     hBmp: HBITMAP;
  69.     hpal: HPALETTE;
  70.   end;
  71.  
  72.   TWmf = record
  73.     hmeta: THandle;
  74.     xExt, yExt: Integer;
  75.   end;
  76.  
  77.   TIcn = record
  78.     hicon: HICON;
  79.   end;
  80.  
  81.   TPicData = record
  82.     case Byte of
  83.       0: (bmp: TBmp);
  84.       1: (wmf: TWmf);
  85.       2: (icon: TIcn)
  86.   end;
  87.  
  88.   PVBPicture = ^TVBPicture;
  89.   TVBPicture = record
  90.     picType: Byte;
  91.     picData: TPicData;
  92.     picReserved: array[0..3] of Byte;
  93.   end;
  94.  
  95.   TArrayRec = record
  96.     DataType: Word; { Type of element (Must be PTYPE_SHORT) }
  97.     Index: Longint; { Index of array element }
  98.   end;
  99.  
  100.   PElementStruct = ^TElementStruct;
  101.   TElementStruct = record
  102.     Value: Longint;         { Value to be transfered }
  103.     NumElems: Word;        { Number of elements }
  104.     Element: array[0..0] of TArrayRec;
  105.   end;
  106.  
  107.   TVBXType = (vbxInteger, vbxLong, vbxSingle, vbxDouble, vbxControl, vbxForm,
  108.     vbxString, vbxCurrency, vbxUnknown, vbxSelf);
  109.  
  110. const
  111.   PICTURE_NONE     = 0;
  112.   PICTURE_BITMAP   = 1;
  113.   PICTURE_METAFILE = 2;
  114.   PICTURE_ICON     = 3;
  115.  
  116.   PICTURE_INVALID     = $FFFF;
  117.   PICTURE_NULL        = 0;
  118.  
  119.   PTYPE_CSTRING = $01;  { HSZ }
  120.   PTYPE_SHORT   = $02;  { short }
  121.   PTYPE_LONG    = $03;  { LONG }
  122.   PTYPE_BOOL    = $04;  { BOOL }
  123.   PTYPE_COLOR   = $05;  { COLORREF or DWORD }
  124.   PTYPE_ENUM    = $06;  { BYTE }
  125.   PTYPE_REAL    = $07;  { float }
  126.   PTYPE_XPOS    = $08;  { LONG (twips) }
  127.   PTYPE_XSIZE   = $09;  { LONG (twips) }
  128.   PTYPE_YPOS    = $0A;  { LONG (twips) }
  129.   PTYPE_YSIZE   = $0B;  { LONG (twips) }
  130.   PTYPE_PICTURE = $0C;  { HPIC }
  131.   PTYPE_BSTRING = $0D;  { HLSTR }
  132.  
  133. { Initialization }
  134. function VBXInit(hInst: THandle; Prefix: PChar): Bool;
  135. function VBXInitHost(hInst: THandle; Prefix: PChar; uMode: Word; Title: PChar;
  136.   HelpFile: PChar; Flags: Longint): Bool;
  137. procedure VBXTerm;
  138. function VBXEnableDLL(InstApp: THandle; InstDLL: THandle): Bool;
  139. function VBXSetWndProc(lpfnWndProc: TFarProc): TFarProc;
  140. function VBXGetDialogParent: HWND;
  141. function VBXSetDialogParent(Wnd: HWND): HWND;
  142. function VBXLoadVBX(lpszFile: PChar): Pointer;
  143. function VBXCtrlWndProc(Wnd: HWND; wMsg: Word; wParam: Word; lParam: Longint): Longint;
  144.  
  145. { Controls }
  146. function VBXAllocControl(lpszClassName: PChar): HCTL;
  147. function VBXGetHctl(Wnd: HWND): HCTL;
  148. function VBXGetHwnd(Ctl: HCTL): HWND;
  149. function VBXCreate(hWndParent: HWND; ID: Word; lpszDLL, lpszClass,
  150.   lpszTitle: PChar; dwStyle: Longint; x, y, cx, cy, hFile: Integer): HCTL;
  151. function VBXCreateEx(hWndParent: HWND; ID: Word; lpszDLL, lpszClass,
  152.   lpszTitle: PChar; dwStyle: Longint; x, y, cx, cy, hFile: Integer;
  153.   lpfnWndProc: TFarProc): HCTL;
  154. procedure VBXDestroyControl(Ctl: HCTL);
  155. function VBXInitControlEx(Ctl: HCTL; hWndParent: HWND; lpszCaption: PChar;
  156.   dwStyle: Longint; const Rect: TRect; wID: Word; hF: HFormFile;
  157.   lpfnWndProc: TFarProc): Err;
  158.  
  159. { Dialogs }
  160. function VBXInitDialog(Wnd: HWND; hInst: THandle; lpID: PChar): Bool;
  161.  
  162. { Properties }
  163. function VBXGetArrayProp(Ctl: HCTL; Index, Element: Integer;
  164.   var Value: Longint): Bool;
  165. function VBXSetArrayProp(Ctl: HCTL; Index, Element: Integer;
  166.   Value: Longint): Bool;
  167. function VBXGetNumProps(Ctl: HCTL): Integer;
  168. function VBXGetProp(Ctl: HCTL; iProp: Integer; lpValue: Pointer): Bool;
  169. function VBXGetPropByName(Ctl: HCTL; lpszName: PChar; lpValue: Pointer): Err;
  170. function VBXGetPropIndex(Ctl: HCTL; lpszName: PChar): Integer;
  171. function VBXGetPropName(Ctl: HCTL; iProp: Integer): PChar;
  172. function VBXIsArrayProp(Ctl: HCTL; iProp: Integer): Bool;
  173. function VBXSetProp(Ctl: HCTL; iProp: Integer; lValue: Longint): Bool;
  174. function VBXSetPropByName(Ctl: HCTL; lpszName: PChar; lVal: Longint): Err;
  175. function VBXGetPropInfo(Ctl: HCTL; iProp: Integer): Pointer;
  176. function VBXGetStdPropIndex(Ctl: HCTL; iProp: Integer): Integer;
  177. function VBXGetPropText(Ctl: HCTL; iProp: Integer): HSZ;
  178. function VBXGetIndexOfStdProp(Ctl: HCTL; iStdProp: Integer): Integer;
  179. function VBXGetArrayPropByName(Ctl: HCTL; Name: PChar; Element: Integer;
  180.   var Value: Longint): Bool;
  181. function VBXSetArrayPropByName(Ctl: HCTL; Name: PChar; Element: Integer;
  182.   Value: Longint): Bool;
  183.  
  184. { Events }
  185. function VBXGetEventIndex(Ctl: HCTL; lpszName: PChar): Integer;
  186. function VBXGetEventName(Ctl: HCTL; iEvent: Integer): PChar;
  187. function VBXGetNumEvents(Ctl: HCTL): Integer;
  188. function VBXGetEventInfo(Ctl: HCTL; iEvent: Integer): Pointer;
  189.  
  190. { methods }
  191. function VBXMethod(Ctl: HCTL; iMethod: Integer; var lpArgs: Longint): Bool;
  192. function VBXMethodAddItem(Ctl: HCTL; iItem: Integer; item: PChar): Bool;
  193. function VBXMethodDrag(Ctl: HCTL; iAction: Integer): Bool;
  194. function VBXMethodMove(Ctl: HCTL; x, y, w, h: Longint): Bool;
  195. function VBXMethodRefresh(Ctl: HCTL): Bool;
  196. function VBXMethodRemoveItem(Ctl: HCTL; iItem: Integer): Bool;
  197.  
  198. { dynamic strings (HSZ) }
  199. function VBXCreateCString(Seg: THandle; lpszString: PChar): HSZ;
  200. function VBXGetCStringPtr(AHsz: HSZ): PChar;
  201. function VBXDestroyCString(AHsz: HSZ): HSZ;
  202. function VBXLockCString(AHsz: HSZ): HSZ;
  203. procedure VBXUnlockCString(AHsz: HSZ);
  204.  
  205. { Basic language strings (HLSTR) }
  206. function VBXCreateBasicString(pb: Pointer; cbLen: Word): HLSTR;
  207. function VBXGetBasicStringPtr(Ahlstr: HLSTR): PChar;
  208. procedure VBXDestroyBasicString(Ahlstr: HLSTR);
  209. function VBXGetBasicStringLength(Ahlstr: HLSTR): Word;
  210. function VBXSetBasicString(var Ahlstr: HLSTR; pb: Pointer; cbLen: Word): Err;
  211.  
  212. { pixel/twips conversions }
  213. function VBXTwp2PixY(Twips: Longint): Integer;
  214. function VBXTwp2PixX(Twips: Longint): Integer;
  215. function VBXPix2TwpY(Pixels: Integer): Longint;
  216. function VBXPix2TwpX(Pixels: Integer): Longint;
  217.  
  218. { pictures }
  219. function VBXCreatePicture(const APic: TVBPicture): HPic;
  220. procedure VBXDestroyPicture(APic: HPic);
  221. function VBXGetPicture(APic: HPic; var APic: TVBPicture): HPic;
  222. function VBXGetPictureFromClipboard(var APic: HPic; hData: THandle; wFormat: Word): Err;
  223. function VBXReferencePicture(APic: HPic): HPic;
  224. function VBXGetPicFromFile(var APic: TVBPicture; PicFile: PChar): Err; 
  225.  
  226. { Form file io }
  227. function VBXCreateFormFile(lLength: Longint; pData: Pointer): HFormFile;
  228. function VBXSaveProperties(Ctl: HCTL): HFormFile;
  229. function VBXGetFormFileLength(hF: HFormFile): Longint;
  230. function VBXDeleteFormFile(hF: HFormFile): Bool;
  231. function VBXWriteProp(Ctl: HCTL; hF: HFormFile; index: Integer): Err;
  232.  
  233. implementation
  234.