Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Hey Ninjas!! Welcome to another article on Advanced Template Library. Today we will learn about Windows Support Class - CWindow in Advanced Template Library (ATL). The Advanced Template Library comprises all template-based C++ classes. It is helpful in creating small Component Object Model objects. The Component Object Model objects is a platform-independent object-oriented system used for developing binary software components.
COM is an object-oriented system and allows the components to be used by various programming languages. COM forms an important part of the Windows operating system. It is used extensively in the development of Windows-based applications allowing the developers to create reusable software components to be used in different applications. A binary software component is a component of software that exposes a set of interfaces that other software can use to access its functionality.
CWindow Class
Before moving to address the methods of the CWindow class, here’s a brief overview of the CWindow class.
CWindow is another class in the Active Template Library (ATL) that provides methods to manipulate the window. It represents a window and forms a thin wrapper around the Win32 API functions for creating and manipulating windows. Like the other ATL classes, it is also designed to be used to develop Windows-based applications. The CWindow class provides several methods for creating and managing windows, such as Create, Destroy, ShowWindow, and UpdateWindow. It also provides methods for working with the window's size, position, and appearance. We often use the CWindow class in conjunction with the other ATL classes to create custom window classes.
Syntax
The Cwindow class is declared in the following manner.
class CWindow
Methods
The following are the methods of CWindow class
Method
Description
ArrangeIconicWindows
This method is used to arrange all the minimized child windows.
Attach
This method attaches a window to the cwindow object.
BeginPaint
This method initialises the window for painting.
BringWindowToTop
This method brings the window to the top of the z order.
CenterWindow
This method centers the window for a given window.
Create
This method creates a window.
DestroyWindow
The DestroyWindow method destroys the window connected with the cwindow object.
Detach
This method detaches the window.
DragAcceptFiles
This method registers whether the window accepts dragged files
DrawMenuBar
This method redraws the windows menu bar.
EnableScrollBar
This method enables or disables the scroll bar arrows of the window.
EnableWindow
This method enables or disables input of the window.
EndPaint
This method marks the end of painting in the window.
FlashWindow
This method displays the window once.
GetClientRect
This method retrieves the coordinates of the client area.
GetFont
This method retrieves the window's current font.
GetMenu
This method retrieves the window's menu.
HideCaret
This method hides the system caret.
IsChild
This method determines whether the specified window is a child window or not.
IsWindow
This method determines whether the specified window handle identifies an existing window.
IsWindowEnabled
This method determines whether the window is enabled for input.
IsWindowVisible
This method determines the window's visibility state.
KillTimer
This method destroys a timer event.
LockWindowUpdate
This method disables or enables drawing in the window.
MessageBox
This method displays a message box.
MoveWindow
This method changes the window's size and position.
OpenClipboard
This method opens the clipboard.
Print
This method requests that the window be drawn in a specified device context.
PrintClient
This method requests that the window's client area be drawn in a specified device context.
RedrawWindow
This method updates a specified rectangle or region in the client area.
ResizeClient
This method resizes the window.
ScrollWindow
This method scrolls the specified client area.
SetActiveWindow
This method activates the window.
SetParent
This method changes the parent window.
ShowWindow
This method sets the window's show state.
UpdateWindow
This method updates the client area.
ValidateRect
This method validates the client area within the specified rectangle.
WinHelp
This method starts the windows help menu.
Examples
CWindow::Detach
This method detaches the window. Here goes an example of how to do it:
HWND hwnd;
//attaching hwnd with CWindow
CWindow detWindow;
//attaching the window
detWindow.Attach(hwnd);
//detatching it from the HWND
detWindow.Detach();
CWindow::IsWindow
This method helps in determining if the specified window handle identifies an existing window. Here goes an example of how to do it:
HWND hwnd;
CWindow testWindow;
//attaching with the hwnd
testWindow.Attach(hwnd);
BOOL bWindow = testWindow.IsWindow()
CWindow::IsWindowEnabled
This method helps in determining if the window is enabled for input. Here goes an example of how to do it: