API calls

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello...I want to use this API function im my projectHWND
CreateDialogParam( HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);so i wrote this implementation:[DllImport("user32.dll")]public static
extern IntPtr CreateDialogParam ( IntPtr hInstance, string
lpTemplateName, IntPtr hWndParent, /*lpDialogFunc,*/ long
dwInitParam);what shoul i do with DLGPROC? It's pointer to function... I
created function like this:IntPtr DialogProc ( IntPtr hwndDlg, uint
uMsg, long wParam, long lParam);but... what to do next?thanx,David
I.
 
CreateDialogParam( HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);so i wrote this implementation:[DllImport("user32.dll")]public static

if the lpDialogFunc should point to the C# function then you should convert
the function pointer in above definition to a delegate with proper
signature.

in your case declare the delegate:

public delegate IntPtr DlgprocDelegate( ...parameters... );

and call the API function:

CreateDialogParam(..., new DlgprocDelegate( method_with_proper_signature ),
.... )

but if the function pointer is going to be taken from somewhere else (for
example from native code) then try to pass an IntPtr value - function
pointer is just a pointer.

Wiktor Zychla
 
thanx

Wiktor Zychla said:
CreateDialogParam( HINSTANCE hInstance,
LPCTSTR lpTemplateName,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);so i wrote this implementation:[DllImport("user32.dll")]public static

if the lpDialogFunc should point to the C# function then you should
convert the function pointer in above definition to a delegate with proper
signature.

in your case declare the delegate:

public delegate IntPtr DlgprocDelegate( ...parameters... );

and call the API function:

CreateDialogParam(..., new DlgprocDelegate(
method_with_proper_signature ), ... )

but if the function pointer is going to be taken from somewhere else (for
example from native code) then try to pass an IntPtr value - function
pointer is just a pointer.

Wiktor Zychla
 
Back
Top