home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0067_WinG Interface.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-24  |  3.1 KB  |  93 lines

  1.  
  2. There are a couple of problems with using WinG and the Delphi IDE.  First,
  3. WinG has some sort of problem with ToolHelp that causes GPF's all the time.
  4. Second, WinG apps created with Delphi don't always seem to load the WING.DLL
  5. file correctly (!) so the programs will not run.
  6.  
  7. Using LoadLibrary to access WinG seems to alleviate both problems.  Here is
  8. my WinG import unit:
  9.  
  10.  
  11. unit Newwing;  {WinG import unit for Borland Pascal}
  12. interface
  13. uses winTypes, winProcs;
  14.  
  15. function InitWinG : Boolean;
  16. function DeInitWinG : Boolean;
  17.  
  18. type
  19.   TWinGDither = (winG4x4Dispersed,winG8x8Dispersed,winG4x4Clustered);
  20.   TWinGCreateDC =
  21.     function:hDC;
  22.   TWinGRecommendDIBFormat =
  23.     function(pFormat:pBitmapInfo):boolean;
  24.   TWinGCreateBitmap =
  25.     function(WinGDC:hDC; pHeader:pBitmapInfo; var ppBits:pointer):hBitmap;
  26.   TWinGGetDIBPointer =
  27.     function(WinGBitmap:hBitmap;pHeader:pBitmapInfo):pointer;
  28.   TWinGGetDIBColorTable =
  29.     function(WinGDC:hDC; StartIndex, NumberOfEntries:word;pColors:pointer):word;
  30.   TWinGSetDIBColorTable =
  31.     function(WinGDC:hDC; StartIndex, NumberOfEntries:word;pColors:pointer):word;
  32.   TWinGCreateHalftonePalette =
  33.     function:hPalette;
  34.   TWinGCreateHalftoneBrush =
  35.     function(context:hDC; crColor:tColorRef;ditherType:tWinGDither):hBrush;
  36.   TWinGBitBlt =
  37.     function(hdcDst:hDC; nXOriginDst, nYOriginDst, nWidthDst,nHeightDst:integer;
  38.              hdcSrc:hDC; nXOriginSrc, nYOriginSrc:integer):boolean;
  39.   TWinGStretchBlt =
  40.     function(hdcDst:hDC; nXOriginDst, nYOriginDst, nWidthDst,nHeightDst:integer;
  41.              hdcSrc:hDC; nXOriginSrc, nYOriginSrc, nWidthSrc,nHeightSrc:integer)
  42.              :boolean;
  43.  
  44. var
  45.   WinGCreateDC : TWinGCreateDC;
  46.   WinGRecommendDIBFormat: TWinGRecommendDIBFormat;
  47.   WinGCreateBitmap: TWinGCreateBitmap;
  48.   WinGGetDIBPointer: TWinGGetDIBPointer;
  49.   WinGGetDIBColorTable: TWinGGetDIBColorTable;
  50.   WinGSetDIBColorTable: TWinGSetDIBColorTable;
  51.   WinGCreateHalftonePalette: TWinGCreateHalftonePalette;
  52.   WinGCreateHalftoneBrush: TWinGCreateHalftoneBrush;
  53.   WinGBitBlt: TWinGBitBlt;
  54.   WinGStretchBlt: TWinGStretchBlt;
  55.  
  56.  
  57. implementation
  58.  
  59. Const
  60.   WinGName : String = 'WING.DLL' + chr(0);
  61.   WinGH : THandle = 0;
  62.  
  63. Function InitWinG : Boolean;
  64.   Begin
  65.     WinGH := LoadLibrary(@WinGName[1]);
  66.     If WinGH < HINSTANCE_ERROR
  67.       Then
  68.         Begin
  69.           InitWinG := False;
  70.           Exit;
  71.         End;
  72.     @WinGCreateDC := GetProcAddress(WinGH,Pointer(1001));
  73.     @WinGRecommendDIBFormat:= GetProcAddress(WinGH,Pointer(1002));
  74.     @WinGCreateBitmap:= GetProcAddress(WinGH,Pointer(1003));
  75.     @WinGGetDIBPointer:= GetProcAddress(WinGH,Pointer(1004));
  76.     @WinGGetDIBColorTable:= GetProcAddress(WinGH,Pointer(1005));
  77.     @WinGSetDIBColorTable:= GetProcAddress(WinGH,Pointer(1006));
  78.     @WinGCreateHalftonePalette:= GetProcAddress(WinGH,Pointer(1007));
  79.     @WinGCreateHalftoneBrush:= GetProcAddress(WinGH,Pointer(1008));
  80.     @WinGStretchBlt:= GetProcAddress(WinGH,Pointer(1009));
  81.     @WinGBitBlt:= GetProcAddress(WinGH,Pointer(1010));
  82.  
  83.     InitWinG := True;
  84.   End;
  85.  
  86. Function DeInitWinG : Boolean;
  87.   Begin
  88.     FreeLibrary(WinGH);
  89.     DeInitWinG := True;
  90.   End;
  91.  
  92. End.
  93.