Understanding Dialog Boxes in Win32 Applications: A Comprehensive Guide, Slides of Windows Programming

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

2011/2012

Uploaded on 11/06/2012

parasad
parasad 🇮🇳

4.5

(56)

131 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Our good old first Win32 programme of lecture 8
#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;
}
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Understanding Dialog Boxes in Win32 Applications: A Comprehensive Guide and more Slides Windows Programming in PDF only on Docsity!

Our good old first Win32 programme of lecture 8

#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

);

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