Prototype of Window Procedure - Window Programming - Lecture Slides, Slides of Windows Programming

Prototype of window procedure, Child Windows, Z order of a window, Notification Codes, Child windows application, Window management functions, Application analysis are the terms you can learn in this lecture and few others as well.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

parasad
parasad 🇮🇳

4.5

(56)

131 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Windows Programming
Lecture 15
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Prototype of Window Procedure - Window Programming - Lecture Slides and more Slides Windows Programming in PDF only on Docsity!

Windows Programming

Lecture 15

Z-order

  • The Z order of a window indicates the window's position in a stack of overlapping windows. This window stack is oriented along an imaginary axis, the z-axis, extending outward from the screen.
  • The window at the top of the Z order overlaps all other windows.
  • The window at the bottom of the Z order is overlapped by all other windows.

Child Windows

  • A child window always appears within the client area of its parent window.
  • Child windows are most often as controls.
  • A child window sends WM_COMMAND notification messages to its parent window.
  • When a child window is created a unique identifier for that window is specified in hMenu parameter of CreateWindow()

Prototype of window procedure

LRESULT CALLBACK WindowProc

(

HWND hwnd, // handle to window UINT uMsg, // WM_COMMAND WPARAM wParam, // notification code and identifier LPARAM lParam // handle to control (HWND)

);

Notification Codes

  • Common controls are child windows that send notification messages to the parent window when events, such as input from the user, occur in the control. The application relies on these notification messages to determine what action the user wants it to take. Except for trackbars, which use the WM_HSCROLL and WM_VSCROLL messages to notify their parent of changes, common controls send notification messages as WM_NOTIFY messages.

WM_COMMAND Notifications

The wParam parameter of Window Procedure contains the notification code and control identifier.

low word: ID of the control

high word: notification code

BUTTON BN_CLICKED

EDIT EN_CHANGE etc

Child windows application

Objectives of Child windows

application

  • Parent-child communication
  • Message Routing
  • Usage of GDI function calls

Window management functions-II

HWND GetDlgItem ( HWND hDlg, // handle to dialog box int nIDDlgItem // control identifier );

HWND FindWindow

(

LPCTSTR lpClassName, // class name LPCTSTR lpWindowName // window name

);

Application analysis

Window classes in the child windows application:

  • mainWindowClass
  • popupWindowClass
  • System Window Classes

PopupWindowClass

wc.lpfnWndProc = popupWindowProc;

wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);

wc.hCursor = LoadCursor(NULL, IDC_HELP);

wc.lpszClassName = "PopupWindowClass";

Creating windows

hWndMain = CreateWindow("MainWindowClass", "Virtual University", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 400, 300, NULL, NULL, hInstance, NULL);

hWndPopup = CreateWindow("PopupWindowClass", "Popup Window", WS_POPUP | WS_CAPTION | WS_VISIBLE, 250, 250, 300, 250, hWndMain, NULL, hInstance, NULL);

Main window’s WndProc

case WM_COMMAND: wControlID = LOWORD(wParam); wNotificationCode = HIWORD(wParam); if(wNotificationCode == BN_CLICKED) { switch(wControlID) { case 5: SendMessage(hWndPopup, ?, wparam, ???); break; ... ... ...

User defined messages

WINUSER.H contains Window messages

#define WM_LBUTTONDOWN 0x0201 (513) #define WM_DESTROY 0x0002 (2) #define WM_QUIT 0x0012 (18) #define WM_USER 0x0400 (1024)

#define WM_DRAW_FIGURE WM_USER+