DlgProc
In a plugin there must be a dialog callback function, which is responsible for processing events
and messages sent to the dialog. The function has four parameters: dialog handle, message
and two additional parameters.
Dialog handler function syntax is presented here, as it should appear in a plugin.
LONG_PTR WINAPI DlgProc( HANDLE hDlg, int Msg, int Param1, LONG_PTR Param2 );
Parameters
Return value
The DlgProc function return value depends on the Msg parameter.
Remarks
Sometimes information contained in Param1 and Param2
consists of two parts, which are placed in two 16-bit words, composing each parameter. There're two
macros defined in Windows to provide access to each part of Param1 and Param2
- LOWORD
They return high-order and low-order words respectively from long int 32-bit value.
Example
Dialog handler code fragment for Reversi game:
LONG_PTR WINAPI ReversiDialogProc(HANDLE hDlg, int Msg,int Param1,LONG_PTR Param2) { struct FarDialogItem DialogItem; struct FarListItem *ListItems; int i; switch(Msg) { case DN_INITDIALOG: // Get information about the element Info.SendDlgMessage(hDlg,DM_GETDLGITEM,75,(LONG_PTR)&DialogItem); ListItems=DialogItem.ListItems->Items; ... NewGame(hDlg); return FALSE; case DN_HELP: { // Show different help topics depending on game move static char *Help[3]={"Contents","Rule","Recommendations"}; if(NumPl1==2 && NumPl2 == 2) i=0; else if(NumPl1+NumPl2 > 16) i=2; else i=1; return (LONG_PTR)(Help[i]); } ... case DM_CLOSE: // Check the element with which the user tries to close the dialog if(Param1 != 10 && Param1 > 0) return FALSE; // one can't close the dialog break; } // Let the Dialog Manager process other events and messages return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
See also: