System Window Classes - Window Programming - Lecture Slides, Slides of Windows Programming

System Window Classes, Two types of System Window Classes, Pre defined Window Classes, Styles of system Window class, Sub classing, Types of Sub classing, List box controls 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 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Windows Programming
Lecture 12
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download System Window Classes - Window Programming - Lecture Slides and more Slides Windows Programming in PDF only on Docsity!

Windows Programming

Lecture 12

System Window Classes

  • Till now, we registered a window class before creating a window. A number of window classes are pre-registered / pre-coded in Windows, and their window procedures also are pre-written
  • No call to RegisterClass() before creating

such a window

Window Classes

  • User defined window classes are automatically unregistered when application using those classes terminates.
  • System classes cannot be unregistered by user processes.

System/Pre-defined Window Classes

(to be used by user processes only)

  • Button o pushbutton o autocheckbox o radio etc.
  • ComboBox
  • Edit
  • ListBox
  • ScrollBar
  • Static

Styles of system Window class

BUTTON

BS_AUTOCHECKBOX BS_AUTORADIOBUTTON BS_PUSHBUTTON BS_RADIOBUTTON BS_DEFPUSHBUTTON … … …

Example: System Window Classes

hWnd = CreateWindow( "BUTTON", "Virtual University", BS_RADIOBUTTON | WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CAPTION, 50, 50, 200, 100, NULL, NULL, hInstance, NULL);

while(GetMessage(&msg, NULL, 0, 0) > 0) { if(msg.message == WM_LBUTTONUP) { DestroyWindow(hWnd); PostQuitMessage(0); } DispatchMessage(&msg); }

GetWindowLong( )

LONG GetWindowLong(

HWND hWnd , // handle to window int nIndex // offset of value to retrieve

);

SetWindowLong( )

The SetWindowLong() function changes an

attribute of the specified window.

Sub-classing

Sub-classing allows you to change the behavior of an existing window, typically a control, by inserting a message map to intercept the window's messages. For example, suppose you have a dialog box with an edit control that you want to accept only non-numeric characters. You could do this by intercepting WM_CHAR messages destined for the edit control and discarding any messages indicating that a numeric character has been entered.

Sub-classing

Sub-classing is of two types:

  • Just for one window
  • For all windows in the application created after substitution of the window procedure

GetClassLong()

The GetClassLong() function retrieves the specified 32-bit (long) value from the WNDCLASS structure associated with the specified window.

GetClassLong()

LONG GetClassLong(

HWND hWnd, // handle to window

int nIndex // offset of value to retrieve

);

SetClassLong()

LONG SetClassLong(

HWND hWnd, // handle to window

int nIndex, // offset of value to set

LONG dwNewLong // new value

Difference Between

SetWindowLong() and SetClassLong()

  • In SetWindowLong() , behavior of a single window is modified.
  • In SetClassLong() , behavior of the window class is modified