By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

how to make the DlgProc a class method?

P: 1
Hi all,
I'm writing a Win32 app with VC 2005 unmannaged code.
I started a new project from scratched.
I want to have a class for the Dialog form that handle everyting for that form (processing messages and so on...).
In the WinMain() I want to create an object of the class I wrote.
Because DefProc is a CALLBACK function, i'm having hard time to change it to be another method in my form class.
I want to be able to create multiple instances of the same class.
How to change this DlgProc as a class method?
Thanks in advanced, Rami.

here is the Dialog Procedure that I want to make a class method:

Expand|Select|Wrap|Line Numbers
  1. LRESULT CALLBACK dlgTest_DlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, LPARAM dwInitParam )
  2. {
  3.     switch( uMsg )
  4.     {
  5.         //case WM_INITDIALOG : //Initilize the form controls.
  7.         case WM_COMMAND :
  8.             ControlEvents(LOWORD(wParam), HIWORD (wParam));
  9.             return TRUE;
  11.         case WM_CLOSE:
  12.             PostQuitMessage(0);
  13.             return FALSE;
  15.         case WM_DESTROY:
  16.             DestroyWindow (hDlg);
  17.             return FALSE;
  19.         default :
  20.             return( FALSE );
  21.     }
  23.     return( FALSE );
  24. }
Please note that the 'ControlEvent' is a class method that process each control events on the form, but for this to work I need the dlgTest_DlgProc to also be a class method.
Jul 5 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Try making dlgTest_DlgProc a friend to your class. That way it does not need to be a member function and it will have access to the object's private data.
Jul 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.