Main Menu

Define pointers in include file

Started by matty47, November 18, 2024, 06:10:04 PM

Previous topic - Next topic

matty47

Trying to write an include file for Gdi32.dll. Hoe would I indicate that a parameter is a pointer
ChoosePixelFormat(hDC, pPixelFormatDescriptor*)e.g. the pPixelFormatDescriptor in this line?

kevin

#1
  The type aren't really relevant for the passing.  So pointers/bytes/words everything are passed the same way as 32bit integers through the stack.  So even boolean/char/bytes/words all the same in 32bit applications. 

  Here's the (untested) concept..  You can find various examples that do much the same through the forums.
 
PlayBASIC Code: [Select]
; PROJECT : Project1
; AUTHOR :
; CREATED : 19/11/2024
; ---------------------------------------------------------------------


/*
int ChoosePixelFormat(
HDC hdc,
const PIXELFORMATDESCRIPTOR *ppfd
);
*/


linkdll "Gdi32.dll"
_ChoosePixelFormat(hDC, pPixelFormatDescriptor) alias "ChoosePixelFormat"
endlinkdll


/*
orignal windows structure
https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-pixelformatdescriptor

typedef struct tPIXELFORMATDESCRIPTOR {
WORD nSize;
WORD nVersion;
DWORD dwFlags;
BYTE iPixelType;
BYTE cColorBits;
BYTE cRedBits;
BYTE cRedShift;
BYTE cGreenBits;
BYTE cGreenShift;
BYTE cBlueBits;
BYTE cBlueShift;
BYTE cAlphaBits;
BYTE cAlphaShift;
BYTE cAccumBits;
BYTE cAccumRedBits;
BYTE cAccumGreenBits;
BYTE cAccumBlueBits;
BYTE cAccumAlphaBits;
BYTE cDepthBits;
BYTE cStencilBits;
BYTE cAuxBuffers;
BYTE iLayerType;
BYTE bReserved;
DWORD dwLayerMask;
DWORD dwVisibleMask;
DWORD dwDamageMask;
} PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;

*/


// our compatible structure
Type tPIXELFORMATDESCRIPTOR
nSize as word;
nVersion as word;
dwFlags ;
iPixelType as byte;
cColorBits as byte;
cRedBits as byte;
cRedShift as byte;
cGreenBits as byte;
cGreenShift as byte;
cBlueBits as byte;
cBlueShift as byte;
cAlphaBits as byte;
cAlphaShift as byte;
cAccumBits as byte;
cAccumRedBits as byte;
cAccumGreenBits as byte;
cAccumBlueBits as byte;
cAccumAlphaBits as byte;
cDepthBits as byte;
cStencilBits as byte;
cAuxBuffers as byte;
iLayerType as byte;
bReserved as byte;
dwLayerMask;
dwVisibleMask;
dwDamageMask;
endtype


function ChoosePixelFormat(hDC,PixelFormat as tPIXELFORMATDESCRIPTOR pointer)

// do stuff before system call if needed

_ChoosePixelFormat(hDC,int(PixelFormat))

// clean up after system call if need.

endfunction


print "running"


sync
waitkey






   


matty47


kevin


 Well make sure you post your progress