Processes in Windows - Window Programming - Lecture Slides, Slides of Windows Programming

Processes in Windows, Instances, Window Class, Window Class Structure, Registering a Window Class, Window creation process, Messages in Windows, Message Queuing 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 / 37

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Windows Programming
Lecture 09
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

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

Windows Programming

Lecture 09

Processes in Windows

  • In Windows, every running application is

called a process.

  • Every process has a process ID that

uniquely identifies it. You can pass a

process ID to the OpenProcess API function

to get a process handle. Most API functions

that provide process information require a

handle rather than an ID.

Multiple instances of Notepad have the same look, shape etc.

Window Class

  • A window class is a set of attributes that the application uses as a template to create a window. Every window belongs to a window class. All window classes are process specific.
  • Window class tells the Operating System about the characteristics and physical layout of its windows

WNDCLASS Structure

  • The WNDCLASS structure contains the window class attributes.
  • The WNDCLASS structure holds most of the information while registering a window class. This information is used by any windows which belong to the class. The only item which this structure does not hold is a handle to the class's small icon. (The more advanced WNDCLASSEX structure does.)

WNDCLASS Structure

  • typedef struct _WNDCLASS { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HINSTANCE hInstance; HICON hIcon; HCURSOR hCursor; HBRUSH hbrBackground; LPCTSTR lpszMenuName; LPCTSTR lpszClassName; *} WNDCLASS, PWNDCLASS;

WNDCLASS Structure

  • hInstance Handle to the instance that contains the window procedure for the class.
  • hIcon Handle to the class icon. This member must be a handle to an icon resource. If this member is NULL, the system provides a default icon.
  • hCursor Handle to the class cursor. This member must be a handle to a cursor resource. If this member is NULL, an application must explicitly set the cursor shape whenever the mouse moves into the application's window.

WNDCLASS Structure

  • hbrBackground

Handle to the class background brush. This member can be a handle to the physical brush to be used for painting the background, or it can be a color value.

  • lpszMenuName Pointer to a null-terminated character string that specifies the resource name of the class menu, as the name appears in the resource file. If you use an integer to identify the menu, use the MAKEINTRESOURCE macro.
  • lpszClassName

Pointer to a null-terminated string or is an atom. If this parameter is an atom, it must be a class atom created by a previous call to the RegisterClass or RegisterClassEx function.

Registered Window Classes

  • List of registered windows’ classes is

maintained by Windows

  • You can register your own Window class

using RegisterClass() API

function

RegisterClass()

RegisterClass() registers a new

window class for use.

ATOM datatype

  • Unique Identifier of the registered window

class returned by RegisterClass()

API function call.

UnregisterClass()

The UnregisterClass function unregisters a

window class, freeing the memory required

for the class.

CreateWindow() Win32 API function

  • The CreateWindow() function creates

an overlapped, pop-up, or child window. It

specifies the window class, window title,

window style, and (optionally) the initial

position and size of the window. The

function also specifies the window's parent

or owner, if any, and the window's menu.

CreateWindow()

HWND CreateWindow(

LPCTSTR lpClassName, // registered class name LPCTSTR lpWindowName, // window name DWORD dwStyle, // window style int x, // horizontal position of window int y, // vertical position of window