PDA

Click to See Complete Forum and Search --> : CreateDialogParam, help please


packetVB
Dec 9th, 2002, 09:22 AM
Hi,

The 4th argument passed to this is a lpDialogFunction.
How do I pass a Class function into the api so i can handle the DlgProc in a class?

For example:

Class Form
{
public:
void CreateForm(HINSTANCE HInstance)
{
HWND tempH;
tempH=CreateDialogParam(hTInstance,MAKEINTRESOURCE(MyDialog),NULL,Form::HandleEvents,NULL);
}
BOOL CALLBACK HandleEvents(HWND dhwnd,UINT message, WPARAM wParam, LPARAM lParam)
{
.....SomeCodehere
}

};

I keep getting

converting from `BOOL (Form::*)(HWND__ *, unsigned int, unsigned int, long int)' to `BOOL (*)(HWND__ *, unsigned int, unsigned int, long int)'


Any help, greatly appreciated.

Thanks
:)

CornedBee
Dec 9th, 2002, 09:39 AM
You can't pass a class member function. You have to use a static member of the class and pass the this pointer in the lpParam parameter, then save it in some per-instance container in the called function (best would be the GWL_USERVALUE storage location which you can access using GetWindowLong(Ptr) and SetWindowLong(Ptr).

packetVB
Dec 9th, 2002, 12:17 PM
Thanks CornedBee,
You pointed me in the right direction.


:)