Click to See Complete Forum and Search --> : DialogBox Problems non-MFC


Joseph Ferner
April 22nd, 1999, 02:08 AM
I can't create a window correctly in non-MFC.
I want to self contain the Config Dialog in a seperate class but I can't get to the Proc within the class then how do I get this code to work.
The problem is with the 4th parameter of "DialogBox"


int CConfigDlg::Create( HINSTANCE hInstance, HWND hParent )
{
return DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG_CONFIG), hParent, ConfigProc );
}

BOOL CALLBACK CConfigDlg::ConfigProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
.
.
.
}

DustinW
April 22nd, 1999, 12:22 PM
Your CConfigProc has to be static. In fact, if you're only going to have 1 dialog object of type CConfigProc, then you could make all of your class's data and methods static.

If you're going to have multiple objects of type CConfigDlg, then it gets more complicated. ConfigProc would need to be static, then within ConfigProc, you could call a non-static proc for the object with the hwndDlg passed in. The HWND would have to be a class member, which means you probably wouldn't be able to use DialogBox, but CreateDialog and EndDialog instead. It gets more complicated every second. This also means you'd have to keep a static list of all instatiations of CConfigDlg in order to find the right object to call the non-static proc for inside of ConfigProc. You could add to and delete from it in the constructor and destructors for the class. Windows and Object oriented programming don't really mix.