Table 4-1 summarizes the windows support functions. The detailed function descriptions follow the table.
Table 4-1 Windows support function summary
Function Purpose
AdjustWindowRect Computes the entire window rect to accommodate a given client area size.
AdjustWindowRectEx Computes the entire window rect for a window with an extended style and a given client area size.
BeginDeferWindowPos Begins a fast movement of windows on the screen.
BringWindowToTop Activates a window and brings it to the top if it is behind any other windows.
ChildWindowFromPoint Determines the child window of a parent window from a given point.
ChildWindowFromPointEx Determines the child window of a parent window from a given point with the ability to ignore invisible, disabled, or transparent child windows.
CloseWindow Minimizes a window.
DeferWindowPos Moves a window using a fast movement process.
EnableWindow Enables or disables a window from receiving input from the mouse and keyboard.
Go!
Keyword
---Go!
EndDeferWindowPos Completes a fast movement of windows on the screen.
EnumChildWindows Calls an enumeration function for each of the child windows of a parent.
EnumProps Calls an enumeration function for each property in the property list of a window.
EnumPropsEx Calls an enumeration function with user data for each property in the property list of a window.
EnumThreadWindows Calls an enumeration function for each window associated with a thread.
EnumWindows Calls an enumeration function for each top-level window running in the system.
FindWindow Finds a top-level window and retrieves the window handle.
FindWindowEx Finds any window by window name and class name.
FlashWindow Highlights a window’s caption bar or flashes a window’s icon if minimized.
GetActiveWindow Retrieves the window handle to the window that is currently active.
GetClassInfo Retrieves information about a window class.
GetClassInfoEx Retrieves extended information about a window class.
GetClassLong Retrieves a long value from a window class structure.
GetClassName Retrieves the class name for a given window.
GetClassWord Retrieves a word value from a window class structure.
GetClientRect Retrieves a window’s client area size.
GetDesktopWindow Retrieves the desktop’s window handle.
GetFocus Retrieves the window handle for the window that has input focus.
GetForegroundWindow Retrieves the window handle for the window that the user is currently working with.
GetLastActivePopup Retrieves the window handle for the last pop-up window that was active.
GetNextWindow Finds the next parent or child windows.
GetParent Retrieves the parent window handle of a child window.
GetProp Retrieves a property data item associated with a window.
GetTopWindow Finds the child window that is on top of the other child windows.
GetWindow Retrieves a window’s handle.
GetWindowLong Retrieves a long value from a window’s data.
GetWindowPlacement Retrieves a window’s position information.
GetWindowRect Retrieves the size of the entire window.
GetWindowText Retrieves the title string of a window.
GetWindowTextLength Retrieves the length of the title string of a window.
GetWindowThreadProcessIdRetrieves the thread ID that created a window.
GetWindowWord Retrieves a word value from a window’s extra data.
IsChild Determines if a window is a child of a given parent window.
IsIconic Checks whether a window is minimized.
IsWindow Checks whether a handle points to a valid window.
IsWindowEnabled Checks whether a window is enabled or disabled.
IsWindowUnicode Checks whether a window is a native Unicode window.
IsWindowVisible Checks whether a window has been made visible.
IsZoomed Checks whether a window is maximized.
MapWindowPoints Maps the coordinates of a window to be relative to another window.
MoveWindow Moves and resizes a window.
RemoveProp Removes a property data item associated with a window.
SetActiveWindow Makes a window active.
SetClassLong Changes one of the long values of a window class.
SetClassWord Changes a word value in the window class extra data.
SetFocus Gives a window input focus.
SetForegroundWindow Makes a window the foreground window.
SetParent Changes the parent window of a child window.
SetProp Associates a property data item with a window.
SetWindowLong Changes a long value associated with a window.
SetWindowPlacement Changes the placement of a window.
SetWindowPos Changes the size, position, and order of a window at one time.
SetWindowText Changes a window’s title.
SetWindowWord Changes a word value associated with a window.
ShowOwnedPopups Shows or hides all pop-up windows associated with a parent window.
ShowWindow Displays, hides, or changes the windows show state.
ShowWindowAsync Displays, hides, or changes the show state of windows created by other threads.
WindowFromPoint Finds which window is at a given point on the screen.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Brief Full Advanced Search
Search Tips
To access the contents, click the chapter and section titles.
Windows NT Win32 API SuperBible (Publisher: Macmillan Computer Publishing) Author(s): Richard Simon
ISBN: 1571690891 Publication Date: 03/01/98
Search this book:
Previous Table of Contents Next
AdjustWindowRect...Windows 95 Windows NT
Description
AdjustWindowRect adjusts the rect pointed to by lpRect from the size of the client area to the size of a bounding rectangle. The bounding rectangle includes the size of the border, caption bar, menu bar, and the client area.
You generally use AdjustWindowRect with CreateWindow to create a window with a known client area size.
Syntax
BOOL AdjustWindowRect( LPRECT lpRect, DWORD dwStyle, BOOL bMenu ) Parameters
lpRect
LPRECT: A pointer to a RECT structure containing the coordinates of the client area for the window that will be created. The coordinates will be adjusted to the size of the window.
dwStyle
DWORD: The window styles that will be used to create the window. For a list of available window styles see Table 3-4 in Chapter 3, Creating Windows.
bMenu
BOOL: Set to TRUE if the rect should include space for a menu; otherwise, set to FALSE.
Returns
BOOL: TRUE if the function was successful, and FALSE if the function failed.
Include File winuser.h See Also
CreateWindow, AdjustWindowRectEx Example
This example shows how to create the main window of an application with a specific client area size.
The AdjustWindowRect function adjusts the values of the RECT structure to accommodate the title bar, menu, and borders of the window while leaving the client area positioned in the same place.
HINSTANCE hInst = NULL;
static LPCTSTR lpszClassName = “My Class”;
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
Go!
Keyword
---Go!
LPSTR lpCmdLine, int nCmdShow ) {
HWND hWnd;
MSG msg;
RECT rect;
//Register the application class.
//...
AdjustWindowRect( &rect, WS_OVERLAPPEDWINDOW, TRUE );
hWnd = CreateWindow( lpszClassName, // Class name registered.
“My Application”, // Title bar text.
AdjustWindowRectEx performs the same tasks as the AdjustWindowRect function except it has a parameter for an extended window style. You generally use this function with the
CreateWindowEx function.
Syntax
BOOL AdjustWindowRectEx( LPRECT lpRect, DWORD dwStyle, BOOL bMenu,
DWORD dwExStyle ) Parameters
lpRect
LPRECT: A pointer to a RECT structure containing the coordinates of the client area for the window that will be created. The coordinates will be adjusted to the size of the window.
dwStyle
DWORD: The window styles that will be used to create the window. For a list of available window styles see Table 3-4 in Chapter 3, Creating Windows.
bMenu
BOOL: Set to TRUE if the rect should include space for a menu; otherwise, set to FALSE.
dwExStyle
DWORD: The extended style that will be used to create the window. For a list of available extended window styles see Table 3-5 in Chapter 3.
Returns
BOOL: TRUE if the function was successful, and FALSE if the function failed.
Include File winuser.h See Also
CreateWindowEx, AdjustWindowRect Example
The example for the AdjustWindowRect function is modified with the following code segment to create a main window with a small caption.
. . .
AdjustWindowRectEx( &rect, WS_OVERLAPPEDWINDOW, TRUE, WS_EX_TOOLWINDOW );
hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, // Create a window with a small caption.
lpszClassName, // Class name registered.
“My Application”, // Title bar text.
WS_OVERLAPPEDWINDOW,// Window style.
rect.left, // Use the rect calculated rect.top, // with AdjustWindowRect() rect.right, // for the size and
rect.bottom, // position.
NULL, // No parent.
NULL, // Use class menu.
hInstance, NULL);
. . .
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Brief Full Advanced Search
Search Tips
To access the contents, click the chapter and section titles.
Windows NT Win32 API SuperBible
(Publisher: Macmillan Computer Publishing) Author(s): Richard Simon
ISBN: 1571690891 Publication Date: 03/01/98
Search this book:
Previous Table of Contents Next
BeginDeferWindowPos...Windows 95 Windows NT
Description
This is the first function an application calls in the series of functions
BeginDeferWindowPos, DeferWindowPos, and EndDeferWindowPos to move one or more windows at one time. The screen refreshes once when the EndDeferWindowPos function is called.
This function lets you move windows quickly with a minimum of time spent refreshing the appearance of the screen. It’s very useful for making adjustments to multiple windows at the same time.
Syntax
HDWP BeginDeferWindowPos( int nWindows ) Parameters
nWindows
int: The initial number of windows for which information is allocated in the position structure.
The DeferWindowPos function will increase the size of the structure if necessary.
Returns
HDWP: If the function succeeds, the return value is a handle to the multiple-window-position structure used in calls to the DeferWindowPos and EndDeferWindowPos functions. The return value is NULL if unsuccessful.
Include File
See the example for the DeferWindowPos function.
BringWindowToTop...Windows 95 Windows NT
Description
BringWindowToTop brings a window to the top and superimposes it over other overlapping
Go!
Keyword
---Go!
windows on the screen. The window is activated if it is a pop-up or top-level window.
You will most commonly use BringWindowToTop to bring pop-up windows in front of other windows and activate them for user input.
Syntax
BOOL BringWindowToTop( HWND hwnd ) Parameters
hwnd
HWND: The window handle to be brought to the top.
Returns
BOOL: TRUE if the function was successful, and FALSE if the function failed.
Include File
This example shows the WndProc function of an application that creates two overlapping edit controls. When the Test! menu option is selected, the second edit control is moved to the top of the window order.
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static HWND hEdit1 = NULL;
static HWND hEdit2 = NULL;
switch( uMsg )
case IDM_TEST :
// Bring hEdit2 to the top of the window order // and refresh the screen.
//...
BringWindowToTop( hEdit2 );
InvalidateRect( hWnd, NULL, TRUE );
UpdateWindow( hWnd );
break;
. . . }
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Brief Full Advanced Search
Search Tips
To access the contents, click the chapter and section titles.
Windows NT Win32 API SuperBible (Publisher: Macmillan Computer Publishing) Author(s): Richard Simon
ISBN: 1571690891 Publication Date: 03/01/98
Search this book:
Previous Table of Contents Next
ChildWindowFromPoint...Windows 95 Windows NT
Description
ChildWindowFromPoint returns the handle to the child window that contains the given point relative to the parent window’s client area.
This function is most commonly used to process the WM_MOUSEMOVE, WM_LBUTTONDOWN, and WM_RBUTTONDOWN messages and to determine the window the mouse cursor lies over when the messages occur.
Syntax
HWND ChildWindowFromPoint( HWND hwndParent, POINT pt ) Parameters
hwndParent
HWND: The parent window handle.
pt
POINT: A POINT structure that contains the client coordinates of the point to be checked.
Returns
HWND: If the function succeeds, the handle of the child window that contains the point is returned, even if the child window is hidden or disabled. If the point is outside the parent window’s boundaries, the return value is NULL. If the point is within the boundaries but not on a child window, the return value is the parent window handle.
Include File
This example shows a portion of the WndProc function of an application that creates a static child control. When the left mouse button is pressed, the application checks to see whether the mouse cursor was over the static control or the client area of the main window.
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static HWND hStatic = NULL;
Go!
Keyword
---Go!
switch( uMsg )
The same as ChildWindowFromPoint except disabled, transparent, and invisible child windows can be skipped when determining the child window.
Syntax
HWND ChildWindowFromPointEx( HWND hwndParent, POINT pt, UINT uFlags )
Parameters hwndParent
HWND: The parent window handle.
pt
POINT: A POINT structure that contains the client coordinates of the point to be checked.
uFlags
UINT: Determines which child windows will be skipped. The parameter can be a combination of the values listed in Table 4-2 combined with the binary OR ( | ) operator.
Table 4-2 ChildWindowFromPointEx flags
Value Meaning
CWP_ALL Look at all child windows.
CWP_SKIPDISABLED Skip disabled child windows.
CWP_SKIPINVISIBLE Skip invisible child windows.
CWP_SKIPTRANSPARENT Skip transparent child windows.
Returns
HWND: If the function succeeds, the handle of the child window that contains the point and meets the criteria in uFlags. If the point is within the parent boundaries but not within any child window that meets the criteria, the return value is the parent window handle. If the point is outside the boundaries, the return value is NULL.
Include File winuser.h See Also
ChildWindowFromPoint, WindowFromPoint Example
This code segment shows how the example for the ChildWindowFromPoint function can be changed to use the ChildWindowFromPointEx function, so disabled controls will be ignored when testing where the mouse hit.
case WM_LBUTTONDOWN : {
POINT pt;
HWND hwndChild;
pt.x = LOWORD( lParam );
pt.y = HIWORD( lParam );
hwndChild = ChildWindowFromPointEx( hWnd, pt,
CWP_SKIPDISABLED );
if ( hwndChild == hStatic )
MessageBox( hWnd, “static control!”, “Hit”, MB_OK );
else
MessageBox( hWnd, “client area!”, “Hit”, MB_OK );
} break;
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.
Brief Full Advanced Search
Search Tips
To access the contents, click the chapter and section titles.
Windows NT Win32 API SuperBible (Publisher: Macmillan Computer Publishing) Author(s): Richard Simon
ISBN: 1571690891 Publication Date: 03/01/98
Search this book:
Previous Table of Contents Next
CloseWindow...Windows 95 Windows NT
Description
CloseWindow minimizes the specified window and displays the window icon that was registered with the window class. If the window class has no icon, then a blank client area is displayed and the window will receive WM_PAINT messages for painting the icon. The application’s main window can be used to minimize the entire application or a child window such as an MDI (multiple-document interface) window.
Syntax
BOOL CloseWindow( HWND hwnd ) Parameters
hwnd
HWND: Identifies the window to be minimized.
Returns
BOOL: TRUE if the function was successful, and FALSE if the function failed.
Include File
In this example the CloseWindow function minimizes the application when the Test! menu option is selected.
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
CloseWindow( hWnd );
DeferWindowPos is the second function in the series BeginDeferWindowPos,
DeferWindowPos, and EndDeferWindowPos. The DeferWindowPos function sets the new position information for each window that is to be moved.
DeferWindowPos is useful for moving one or more windows quickly with only one screen update.
Syntax
HDWP DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT dwFlags )
Parameters hdwp
HDWP: The handle to the multiple-window position structure that was created with the BeginDeferWindowPos or returned from a previous call to DeferWindowPos.
hwnd
HWND: A handle to the window that will be moved.
hwndInsertAfter
HWND: A handle to the window that will precede the window in hwnd. One of the values in Table 4-3 can be used in place of a window handle. This parameter is ignored if the SWP_NOZORDER is set in the dwFlags parameter.
Table 4-3 DeferWindowPos hwndInsertAfter values
Value Meaning
HWND_BOTTOM Moves the window to the bottom position in the stack of child windows.
HWND_NOTOPMOST Moves the window to the bottom position of all topmost windows. This is above all nontopmost windows.
HWND_TOP Moves the window to the top position in the stack of child windows.
HWND_TOPMOST Moves the window to the top position of all topmost windows. When the window is deactivated it will still maintain its topmost position.
x
int: The new x position of the window’s upper-left corner.
y
int: The new y position of the window’s upper-left corner.
cx
int: The window’s new width, in pixels.
cy
int: The window’s new height, in pixels.
dwFlags
UINT: Affects how the window is moved and positioned. This parameter is made up of one or more of the values listed in Table 4-4 combined with the binary OR ( | ) operator.
Table 4-4 DeferWindowPos dwFlags values
Value Meaning
SWP_DRAWFRAME Draws the frame defined in the window’s class around the window.
SWP_FRAMECHANGED Forces the WM_NCCALCSIZE message to be sent to the window, even if the window’s size is not being changed.
SWP_HIDEWINDOW Hides the window.
SWP_NOACTIVATE Does not activate the window.
SWP_NOCOPYBITS Discards the entire contents of the client area. By default, the valid contents of the client area are saved and copied back into the client area after the window is sized or positioned.
SWP_NOMOVE The x and y parameters are ignored. The window will only be resized.
SWP_NOOWNERZORDER Preserves the position in the Z order of the owner window.
SWP_NOREDRAW Will not cause a repaint after the move takes place. The application must explicitly invalidate or redraw any part that needs to be drawn.
SWP_NOREPOSITION Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE The cx and cy parameters are ignored. The window will only be moved.
SWP_NOZORDER Ignores the hwndInsertAfter parameter.
SWP_SHOWWINDOW Displays the window.
Returns
HDWP: The handle to the updated multiple-window position structure. The handle returned could be different from the one passed in and should be used in subsequent calls to DeferWindowPos and ultimately EndDeferWindowPos. If the function does not succeed, a NULL will be returned.
Include File
This example (see Figure 4-1) shows a section of the WndProc function for an application that creates a static text control and an edit control as child windows of the main window. These controls then are sized using the BeginDeferWindowPos, DeferWindowPos, and
EndDeferWindowPos functions when the main window is sized. The width of the static control is kept the same as the main window’s width. The width and height of the edit control are changed to match the main window’s width and height minus the height of the static control.
Figure 4-1 DeferWindowPos example
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static HWND hStatic = NULL;
static HWND hEdit = NULL;
//...
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is