


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An in-depth exploration of dialog boxes in win32 applications, including their creation, definition, and usage. Topics covered include dialogbox() api, dialogproc, controls in a dialog resource definition statement, and various messages related to dialogs. Students will gain a solid understanding of how to create and manage dialog boxes in their own win32 projects.
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, "This is our first Windows Programming Application.", "Virtual University", MB_OK);
return 0; }
Modal Dialog Box contains a Modal Loop
DialogBox() API function creates a Modal
Dialog.
DialogBox() does not return until the dialog
is dismissed.
Controls in a Dialog Resource Definition statement
LTEXT Left-aligned static control
RTEXT Right-aligned static control
CTEXT Centre-aligned static control
DialogBox() API
INT_PTR DialogBox(
HINSTANCE hInstance, // handle to module
LPCTSTR lpTemplate, // dialog box template
HWND hWndParent, // handle to owner window DLGPROC lpDialogFunc // dialog box procedure
);
BOOL CALLBACK AboutAuthorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: return TRUE;
case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog(hDlg, 0); return TRUE; } break; } return FALSE; }
WM_INITDIALOG message
Sent by system just after creating the dialog and just
before making it visible
If FALSE is returned, it prevents the system from setting
the default keyboard focus.
If TRUE is returned, keyboard focus is set to the control
specified by wParam.
About dialog
Modal Dialogs
SetWindowText
Set the text of a control or the title bar of a window
BOOL SetWindowText(
HWND hWnd, // handle to window or control LPCTSTR lpString // title or text
);
GetDlgCtrlID
Retrieve the identifier of the specified control.
int GetDlgCtrlID(
HWND hwndCtl // handle to control
);
SendDlgItemMessage
sends a message to the specified control in a dialog box
LRESULT SendDlgItemMessage(
HWND hDlg, // handle to dialog box int nIDDlgItem, // control identifier
UINT Msg, // message to send WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
Edit control messages
EM_LIMITTEXT,
wParam, // text length
lParam // not used; must be zero
Sets the text limit of an edit control
Window/control messages
Set or retrieve current selection in an edit control
EM_SETSEL or EM_GETSEL
wParam, // starting position
lParam // ending position
Parameters to a Dialog
Passing information to the dialog
INT_PTR DialogBoxParam(
HINSTANCE hInstance, // handle to module LPCTSTR lpTemplateName, // dialog box template
HWND hWndParent, // handle to owner window DLGPROC lpDialogFunc, // dialog box procedure
LPARAM dwInitParam // initialization value
);
lParam parameter of WM_INITDIALOG contains dwInitParam