windows_programming_notes.nbk: Home | Index | Next Page: sample modal dialog box | Previous Page: Sample code


 sample dialog box callback procedure

Example dialog box procedure:

//##############################################################################
// RACL Arg Dialog Callback procedure
//##############################################################################

BOOL CALLBACK racl_arg_dialog_procedure(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    racl_arg_dialog  *arg_data = (racl_arg_dialog *)GetWindowLong(hwnd, GWL_USERDATA);

    switch(message) {
    case WM_INITDIALOG:
        racl_arg_dialog  *arg_data = (racl_arg_dialog *)lparam;
        SetWindowLong(hwnd, GWL_USERDATA, (LONG)arg_data);
        // HERE - setup dialog box
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wparam)) {
        case IDOK:
            racl_arg_dialog_finish(hwnd, arg_data);
            EndDialog(hwnd, 1);
            break;
        case IDCANCEL:
            EndDialog(hwnd, 0);
            break;
        }
        return TRUE;
    }
    return FALSE;
}

In this example, the data to edit is passed in a 'racl_arg_dialog' struct. The struct is filled in before the dialog box is created. The address of the struct is passed to the dialog box code as the lParam argument to the DialogBoxParam function. The callback then stores the pointer in the dialog box's USERDATA area.

See Also:


windows_programming_notes.nbk: Home | Index | Next Page: sample modal dialog box | Previous Page: Sample code


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time