About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client &...

51
About Windows Jihoon.Yim 2008.07.05

Transcript of About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client &...

Page 1: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

About Windows

Jihoon.Yim

2008.07.05

Page 2: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

About Windows

2

Desktop WindowApplication WindowsClient & Nonclient AreaControl and Dialog Boxes

Desk Window

Page 3: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Desktop WindowDesktop WindowA system-defined window that

Paints the background of the screenServes as the base for all windows displayed by all applications

GetDesktopWindow()Returns a handle to the desktop window

SystemParametersInfo()Loads the bitmap from the specified fileUses the bitmap to paint the background of the screenEnters the new file name in the registry

3

Page 4: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Application WindowMain Window

Serves as the primary interface between the user and the app

Taskbar buttonThe system associates a taskbar button with the app

The following illustration shows the components :

4

Page 5: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Client & Nonclient AreaClient Area

The part of a window where the app displays output, such as text or graphics.The application manages the appearance and behavior of its client area

Nonclient AreaThe system manages most aspects of the nonclient areaThe title barMenu barWindow menu

Created and managed by the system

Minimize and maximize buttonsSizing borderScroll bars

5

Page 6: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Control and Dialog Boxes

ControlA window that an application uses to obtain a specific piece of information from the user

Dialog BoxA window that contains one or more conrolsTypically do not have a menu bar, minimize and maximize buttons, or scroll bars

Message BoxA special dialog box that displays a note, caution, or warning to the user

6

Page 7: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Windows Attributes

7

Class Name

Window Name

Window Style

Extended Window Style

Position

Size

Parent or Owner Window Handle

Menu Handle or Child-Window Identifier

Application Instance Handle

Window handle

Page 8: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Class Name

Every window belongs to a window class

An application must register a window class before creating any windows of that class

Window ProcedureA function that receives and processes all input and requests sent to the window

8

Page 9: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Name

A text string that identifies a window for the userDisplay

Display its window name in its title barA main windowDialog boxMessage box

Display it window name within the rectangle occupied by the control

ButtonsEdit controlsStatic controls

Do not displayList boxesCombo boxes

9

Page 10: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window StyleA named constant that defines an aspect of the

window’s appearance and behaviorSetWindowLong()

Set the styles after creating a window

General Window StyleThe general window styles begin with the WS_ prefixCan be combined with the OR operator

Class-specific Window StyleDefines the appearance and behavior of windows belonging to the predefined control classesSCROLLBAR

SBS_HORZ and SBS_VERT

10

Page 11: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Extended Window Style

Every window can optionally have one or more extended window styles

CreateWindowEx()Sets extended window styles when creating windows

SetWindowLong()Set the styles after crating a window

11

Page 12: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

POSITIONA window’s position is defined as the coordinates of its upper left corner

A top-level windowAlways relative to the upper left corner of the screen

A child windowRelative to the upper left corner of the parent window’s client area

WindowFromPoint()Retrieves a handle to the window occupying a particular point on the screen

ChildWindowFromPoint() & ChildWindowFromPointEx()Retrieves a handle to the child window occupying a particular point in the parent window’s client areaChildWindowFromPointEx() can ignore invisible, disabled, and parent child windows, ChildWindowFromPoint() cannot

12

Page 13: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

SizeGiven in pixels

Zero width or heightIf an application sets a window’s width and height to zero, the system sets the size to the default minimum window size.To discover the default minimum window size, use

GetSystemMetrics() with the SM_CXMIN and SM_CYMIN flags

AdjustWindowRect() and AdjustWindowRectEx()Calculate the required size of a window based on the desired size of the client area

Check the width and height of the screenGetSystemMerics() with the SM_CXSCREEN and SM_CYSCREEN flags

13

Page 14: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Parent or Owner Window handle

Child windowA window that has a parentClipping

A child window is clipped so that no part of the child window can appear outside the borders of its parent window

Top-level windowHas no parent, or whose parent is the desktop window

EnumWindows()Use this function to obtain a handle to each of its top-level windowPasses the handle to each top-level window, in turn, to an application-defined callback function,

EnumWindowsProc()

14

Page 15: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Menu Handle or Child-Window Iden..

Child-Window IdentifierA unique, applicatoin-defined value associated with the child window

SetWindowLong()Can change the window’s identifier

GetWindowLong()Can Retrieve the identifier

Every window, except a child window, can have a menu.

15

Page 16: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Application Instance Handle

Instance HandleThe system provides the instance handle to an applicationThe system uses instance handles internally to distinguish one instance of an application from another

16

Page 17: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window HandleUniquely identifies the windowHWND Data type

Uses this handle in other functions to direct their actions to the window

FindWindow()Discover whether a window with the specified class name or window name exists in the system

FindWindowEx()To limit the search to the child windows of a particular application

IsWindow()Determines whether a window handle identifies a valid, existing window

Special constantsAn application can use HWND_BROADCAST in the SendMessage() and SendMessageTimeout(), orHWND_DESKTOP in the MapWindowPoints()

17

Page 18: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Creation

CreateWindowEx()Provide the information required to define the window attributesHas a parameter, dwExStyle

CreateWindow()Simply calls CreateWindowEx() with the dwExStyle parameter set to zero.

Creating special-purpose windowsDialogBoxCreateDialogMessageBox

18

Page 19: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Main Window CreationWinMain

Performs a number of tasksRegistering the window class for the main window by calling the RegisterClass()Creating the main window by calling the CreateWindowEx()

Limit an application to a single instanceCreate a named mutex using the CreateMutex()If GetLastError() returns ERROR_ALREADY_EXISTS,Exit WinMain

SW_SHOWDEFAULT When ShowWindow() is called to display the aplication’s main window, the flag must be set to.This flag tells the system to display the window as directed by the program

IsWindowUnicode()If a window class was registered with the Unicode version of RegisterClass(), the window receives only Unicode messages.To determine whether a window uses the Unicode Character set or not

19

Page 20: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window-Creation Messages

WM_NCCREATEThe system sends this message after creating the window’s nonclient area

WM_CREATEThe system sends this message after creating the client area

CREATESTRUCTContains all the information specified in the CreateWindowEx()

WM_PARENTNOTIFYWhen creating a child window, the system sends this message to the parent window after sending the WM_NCCREATE and WM_CREATE messages

20

Page 21: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Multithread Applications

EumThreadWindows()Enumerate the windows created by a particular thread.EnumThreadWindProc() callback function

GetWindowThreadProcessId()Returns the identifier of the thread that created a particular window

ShowWindowAsync()Set the show state of a window created by another thread

21

Page 22: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Features

22

Window TypesWindow RelationshipsWindow Show StateWindow Size and PositionWindow AnimationWindow Layout and MirroringWindow Destruction

Page 23: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Overlapped WindowsA top-level window that has a title bar, border, and client area

Serve as an application’s main window

Can have a window menu, minimize and maximize buttons, and scroll bars

WS_OVERLAPPED or WS_OVERLAPPEDWINDOWSpecify one of these styles when creating a windowWS_OVERLAPPED

Has a title bar and border

WS_OVERLAPPEDWINDOWHas a title bar, sizing border, window menu, and minimize and maximize buttons

23

Page 24: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Pop-up Windows

A special type of overlapped window used for dialog boxes, message boxes, and other temporary windows that appear outside an application’s main windowWS_POPUP

To create a pop-up window

WS_CAPTIONTo include a title bar

WS_POPUPWINDOWHas a border and a window menuMust be combined with the WS_POPUPWINDOW style to make the window menu visible

24

Page 25: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Child Windows

Child WindowConfined to the client area of its parent windowWS_CHILD styleMust have a parent window

If you do not specify a parent window, the system does not create the window

Cannot have a menuIf no border style is specified, the system creates a borderless window

An application can use borderless child windows to divide a parent window’s client area while keeping the divisions invisible to the user

25

Page 26: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Child WindowsSibling window

A child window that shares the same parent window as one or more other child windows

WS_CLIPSIBLING styleIf a child window does have this style, any portion of its sibling window that lies within the child window is clipped

If a window has either the WS_CLIPCHILDREN or WS_CLIPSIBLINGS style, a slight loss in performance occurs.

For best performance, an application that needs to logically divide its main window should do so in the window procedure of the main window rather thn by using child windows.

26

Page 27: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Child Windows

Relationship to Parent WindowSetParent()

Change the parent window of an existing child windowThe system removes the child window from the client area of the old parent window andMoves it to the client area of the new parent windowIf SetParent() specifies a NULL handle, the desktop window becomes the new parent windowIn this case, the child window is drawn on the desktop, outside the borders of any other window.

GetParent()Retrieves a handle to a child window’s parent window

The parent window relinquishes a portion of its client area to a child window

27

Page 28: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Child Windows

Relationship to Parent WindowDescendant Window

Each child window, in turn, can have child windowsIn this chain of windows, each child window is called a descendant window of the original parent window

IsChild()Discover whether a given window is a child window or a descendant window of a given window

EnumChildWindows()Enumerates the child windows of a parent windowDecsendant windows of the given window are also enumerated.

28

Page 29: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Child WindowsMessages

The system passes a child window’s input messages directly o the child windowThe messages are not passed through the parent windowThe only exception is if the child window has been disabled by the EnabledWindow() function

This permits the parent window to examine the input messages and enable the child window, if necessary.

Unique integer identifierDirect the message to the controlA control sends notification messages to its parent windowThe parent uses to identify which control sent the messageSpecifies the child-window identifier for other types of child windows by setting the hMenu parameter of the CreateWindowEx function to a value rather than a men handle

29

Page 30: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Layered Window

Improve performance and visual effect for a window that has a complex shape, animates its shape, or Wishes to use alpha blending effects.If the layered window has the WS_EX_TRASPARENT, the shape of the layered window will be ignored the mouse evens will be passed to other windows underneath the layered window.

30

Page 31: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Message-Only WindowsEnables you to send and receive messagesNot visible, no z-order, cannot be enumerated, and does not receive broadcast messagesCreate

Specify the HWND_MESSAGE constant or a handle to an existing message-only window in the hWndParent parameter of the CreateWindowEx()You can also change an existing window to a message-only window by specifying HWND_MESSAGE in the hWndNewParent parameter of the SetParent()

To find message only windowsSpecify HWND_MESSAGE in the hwndParent parameter of the FindWindowEx()

FindWindowEx()Searches message-only windows as well as top-level windows if both the hwndParent and hwndChildAfter parameters are NULL

31

Page 32: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Relationships

Foreground and Background WindowsForeground window

The thread that created the window with which the user is currently working

Background WindowThe window created by background threads

Priority LevelDetermines the amount of CPU time the thread receivesThe foreground thread has a normal base priority of 9A background thread has a normal base priority of 7

GetForegroundWindow()Retrieve a handle to the foreground windowTo check if your app window is the foreground window, compare the handle returned by GetForegroundWindow to that of your app window

32

Page 33: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Relationships

Foreground and Background WindowsSetForegroundWindow()

Sets the foreground window

LockSetForegroundWindowDisable calls to SetForegroundWindow

Enable another process to set the foreground windowBy calling the AllowSetForegroundWindow() orBy calling the BroadcastSystemMessage() with the BSF_ALLOWSFW flag

33

Page 34: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window RelationshipsOwned Windows

ConstraintsAn owned window is always above its owner in the z-orderThe system automatically destroys an owned window when its owner is destroyedAn owned window is hidden when its owner is minimized

Only an overlapped or pop-up window can be an owner window

WS_OVERLAPPED styleWS_POPUP style

A child window cannot be an owner windowAfter creating an owned window an application cannot transfer ownership of the window to another windowDialog boxes and message boxes are owned window by defaultGW_OWNER flag

An app can use the GetWindow() with the GW_OWNER flag to retrieve a handle to a window’s owner

34

Page 35: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window RelationshipsZ-Order

The window’s position in a stack of overlapping windowsAn imaginary axis, the z-axis, extending outward from the screenThe window at the top of the z-order overlaps all other windowsThe system maintains the z-order in a single listA topmost window

Overlaps all other non-topmost windows, regardless of whether it is the active or foreground windowWS_EX_TOPMOST styleAll topmost windows appear in the z-order before any non-topmost windows

A child window is grouped with its parent in z-order

35

Page 36: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Relationships

Z-OrderBringWindowToTop()

Bring a window to the top of the z-order for window of the same type

Rearrange the z-order by usingSetWindowPos()DeferWindowPos()

GetTopWindow()Search all child windows of a parent window and return a handle to the child window that is highest in z-order

GetNextWindow()Retrieves a handle to the next or previous window in z-order

36

Page 37: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Show StateActive Window

The top-level window of the app with which the user is currently working

Only a top-level window can be an active windowOnly one top-level window in the system is active at a time

SetActiveWindow()An application activates a top-level windowOther functions can cause the system to activate a different top-level window, including SetWindowPos(), DeferWindowPos(), SetWindowPlacement(), and DestroyWindow()

GetActiveWindow()To retrieve a handle to the active window

WM_ACTIVATEAPPWhen the activation changes from a top-level window of one application to the top-level window of another, the system sends a WM_ACTIVEAPP message to both applications

WM_ACTIVEWhen the activation changes to a different top-level window in the same application, the system sends both windows a WM_ACTIVE message

37

Page 38: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Show StateDisabled Windows

Do not receive keyboard or mouse input from the userCan receive messages from other windows, from other applications, and from the systemWS_DISABLED styleEnableWindow()

Enable or disable an existing window

WM_ENABLEWhen window’s enabled state is about to change

IsEnabledWindow()Determine whether a window is enabled

When a child window is disabled, the system passes the child’s mouse input messages to the parent window

38

Page 39: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Windows RelationshipsWindow Visibility

Hidden windowCan process messages from the system or from toher windowsCannot process input from the user or display output

WS_VISIBILE StyleTypically, an application sets the WS_VISIBLE style after it has created a window to keep details of the creation process hidden from the user

WM_SHOWWINDOWThe system sends the WM_SHOWWINDOW message to the window after creating the window, but before displaying it

IsWindowVisible()Determine whether a window is visible

Can show or hide a window by usingShowWindow, SetWindowPos, DeferWindowpos, SetWindowPlacement, SetWindowLong

ShowOwnedPopups()Occasionally, an app may need to hide the owned windows without having to minimize or hide the ownerIn this case, the application uses the ShowOwnedPopups()Sets or removes the WS_VISIBLE style for all owned windows and sends the WM_SHOWWINDOW message to the owned windows before hiding or showing them

Even if a window has the WS_VISIBLE style, the user may not be able to see the window on the screen

39

Page 40: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Windows RelationshipsMinimized, Maximized, and Restored Windows

Maximized windowA window has the WS_MAXIMIZE styleAlthough a window’s size can be set to the same size of a maximized window, a maximized window is slightly differentDisables the window’s sizing border and the window-positioning capability of the title bar

Minimized windowA window that has the WS_MINIMIZE style

Restored windowA window that has been returned to its previous size and position

ArrangeIconicWindows()Arranges the icons on the desktop, or It arranges a parent window’s minimized child windows in the parent window

OpenIcon()Restores a minimized window to its previous size and position

ShowWindow()Can minimize, maximize, or restore a windowCan set the window’s visibility and activation states

40

Page 41: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Windows RelationshipsMinimized, Maximized, and Restored Windows

SetWindowPlacement()Includes the same functionality as ShowWindow()Can override the window’s default minimized, maximized, and restored positions

IsZoomed() and IsIconic()Determines whether a given window is maximized or minimized, respectively

GetWindowPlacement()Retrieves the minimized, maximized, and restored positions for the window, and Also determines the window’s show state

WM_QUERYOPEN messageWhen the system receives a command to maximize or restore a minimized window, it sends the window this messageIf the window procedure returns FALSE, the system ignores the maximize or restore command

41

Page 42: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Windows Relationships

Minimized, Maximized, and Restored WindowsTo override the system-defined defaults, an application can call the SetWindowPlacement() or process the WM_GETMINMAXINFOWM_GETMINMAXINFO message

Received by a window when the system is about to maximize the windowIncludes a pointer to a MINMAXINFO structure containing values the system uses to set the maximized size and positionReplace these values overrides the defaults

42

Page 43: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and PositionDefault Size and Position

CW_USEDEFAULTAllow the system to calculate the initial size or position of a top-level window

Tracking SizeWS_THICKFRAME style

The system maintains a minimum and maximum tracking size for a window

WM_GETMINMAXINFOAn app can discover the defaults and override them by processing this message

System CommandsGenerated when the user chooses commands from the window menuAn app can emulate the user action by sending a WM_SYSCOMMAND message to the window

43

Page 44: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and PositionSize and Position Functions

Set the window’s size or position :SetWindowPlacementMoveWindowSetWindowPosDeferWindowPos

SetWindowPlacementSets a window’s minimized position, maximized position, restored size and position, and show state

MoveWindow and SetWindowPosSimilar. Both set the size or position of a single app windowSetWindowPos includes a set of flags that affect the window’s show stateMoveWindow does not include these flags

BeginDeferWindowPos, DeferWindowPos and EndDeferWindowPos

To simultaneously set the position of a number of windows, including the size, position, position in the z-order, and show state

44

Page 45: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and PositionSize and Position Functions

GetWindowRect()Retrieve the coordinates of a window’s bounding rectangleFills a RECT structure with the coordinates of the window’s upper left and lower right cornersThe coordinates are relative to the upper left corner of the screen, even for a child window

ScreenToClient() or MapWindowPoints()Maps the screen coordinates of a child window’s bounding rectangle to coordinate relative to the parent window’s client area

GetClientRect()Retrieves the coordinates of a window’s client areaFills a RECT structure with the coordinates of the upper left and lower right corners of the client areaCoordinates are relative to the client area itselfThis means the coordinates of a client area’s upper left corner are always(0,0)The coordinates of the lower right corner are the width and height of the client area

45

Page 46: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and Position

Size and Position FunctionsCascadeWindow()

Cascade the windows on the desktop or Cascade the child windows of the specified parent window

TileWindows()Tiles the windows on the desktop orTiles the child windows of the specified parent window

Size and Position MessageWM_GETMINMAXINFO message

Whose size or position is about to changeIncludes a pointer to a MINMAXINFO structureA window must have the WS_THICKFRAME style to receive WM_GETMINMAXINFO

46

Page 47: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and Position

Size and Position MessageWM_WINDOWPOSCHANGING message

Whose size, position, position in the z-order, or show state is about to changeIncludes a pointer to a WINDOWPOS structure that specified the window’s new state

WM_WINDOWPOSCHANGED messageAfter changing a window’s size, position, position in the z-order, or show state, the system sends this message to the windowIncludes a pointer to WINDOWPOS structureA window that must process WM_SIZE and WM_MOVE messages must pass WM_WINDOWPOSCHANGED to the DefWindowProc()Otherwise the system does not send WM_SIZE and WM_MOVE messages to the window

47

Page 48: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window Size and Position

Size and Position MessageWM_NCCALCSIZE message

When the window is created or sizedThe system uses the message to calculate the size of window’s client area and the position of the client area relative to the upper left corner of the window

Window Animation

Window Layout and Mirroring

48

Page 49: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

Window DestructionDestoryWindow()

destroys all the windows it createsSends a WM_DESTORY message first to the window,Then to its child windows and descendant windowsIn this way, all descendant windows of the window being destroyed are also destroyed.

If the app does not release the resources, the system will free any resources not freed by the app.

WM_CLOSEA window with a window menu receives a WM_CLOSE message when the user clicks CloseBY processing this message, an app can prompt the user for confirmation before destroying the window

49

Page 50: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

References

MSDN 2003ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1042/winui/winui/windowsuserinterface/windowing/windows/aboutwindows.htm

50

Page 51: About Windows Jihoon.Yim 2008.07.05. About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.

51

Thank you