Table of contents
1.
Introduction
2.
CWindowImpl Class
2.1.
Syntax
2.2.
Parameters
3.
Members
3.1.
Public Methods
3.1.1.
CWindowImpl::Create
3.2.
CWindowImplBaseT Methods
3.2.1.
DefWindowProc
3.2.2.
GetCurrentMessage
3.2.3.
GetWindowProc
3.2.4.
OnFinalMessage
3.2.5.
SubclassWindow
3.2.6.
UnsubclassWindow
3.3.
Static Methods
3.3.1.
GetWndClassInfo
3.3.2.
WindowProc
4.
Frequently Asked Questions
4.1.
What are Public methods?
4.2.
What are static methods?
4.3.
Name some static methods of the CWindowImpl class.
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Windows Support Class - CWindowImpl

Author Nagendra
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

 

Hey Ninjas!! Welcome to another article on Advanced Template Library. Today we will learn about Windows Support Class - CWindowImpl in Advanced Template Library (ATL). The Advanced Template Library comprises all template-based C++ classes. It helps create small Component Object Model objects. The Component Object Model objects is a platform-independent object-oriented system for developing binary software components.

CWindowImpl Windows Support Class

CWindowImpl Class

The CWindowImpl is used for creating a window. This class also creates subclasses of the window. The CWindowImpl window method uses a message map to route messages to the proper handlers.

Syntax

template <class T, class TBase = CWindow, class TWinTraits = CControlWinTraits>
class ATL_NO_VTABLE CWindowImpl : public CWindowImplBaseT<TBase, TWinTraits>
You can also try this code with Online C++ Compiler
Run Code

Parameters

  • T: This is the new derived class of CWindowImpl.
  • TBase: This is the base of the class. CWindow is the default base class.
  • TWinTraits: This class defines the style for the window. CControlWinTraits is the default traits class.

Members

The CWindowImpl consists of Public Methods, CWindowImplBaseT Methods, and Static Methods. Let's get into the details of them.

Public Methods

The CWindowImpl consists of a create method.

CWindowImpl::Create

The Create method is used to create a window.

Syntax:

HWND Create(
    HWND hWndParent,
    _U_RECT rect = NULL,
    LPCTSTR szWindowName = NULL,
    DWORD dwStyle = 0,
    DWORD dwExStyle = 0,
    _U_MENUorID MenuOrID = 0U,
    LPVOID lpCreateParam = NULL);
You can also try this code with Online C++ Compiler
Run Code


Parameters:

  • hWndParent: It handles the parent window.
     
  • rect: It is the RECT structure that specifies the window's position.
     
  • szWindowName: This parameter specifies the window name.
     
  • dwStyle: It specifies the style of the window. 
     
  • dwExStyle: This value is combined with the style for the window the traits class provides. 
     
  • MenuOrID: this parameter is the window identifier. Child Window uses it.
     
  • lpCreateParam: It is a pointer to window-creation data. 

CWindowImplBaseT Methods

The following are the CWindowImplBaseT Methods:

  • DefWindowProc
     
  • GetCurrentMessage
     
  • GetWindowProc
     
  • OnFinalMessage
     
  • SubclassWindow
     
  • UnsubclassWindow
     

Let's get details of each of them.

DefWindowProc

This method is used to process the messages.

Syntax:

LRESULT DefWindowProc(
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam);
LRESULT DefWindowProc();
You can also try this code with Online C++ Compiler
Run Code


Parameters

  • uMsg: It contains the window message.
     
  • wParam: It is the additional message information.
     
  • lParam: It is the additional message information.
     

GetCurrentMessage

This method returns the current message.

Syntax:

const MSG* GetCurrentMessage();
You can also try this code with Online C++ Compiler
Run Code

GetWindowProc

This method returns the current window procedure.

Syntax:

virtual WNDPROC GetWindowProc();
You can also try this code with Online C++ Compiler
Run Code

OnFinalMessage

This method is called after the last message is received. You can override the WindowProc Class to use different mechanisms for handling messages rather than the default one.

Syntax:

virtual void OnFinalMessage(HWND hWnd);
You can also try this code with Online C++ Compiler
Run Code


Parameter:

  • hWnd: This parameter handles the window being destroyed.

SubclassWindow

This method subclasses a window. It attaches the window to the CWindowImpl object. It returns TRUE if the window is subclassed, else it returns FALSE.

Syntax:

BOOL SubclassWindow(HWND hWnd);
You can also try this code with Online C++ Compiler
Run Code


Parameter:

  • hWnd: This parameter handles the window being subclassed.

UnsubclassWindow

This method restores the previously subclassed window.

Syntax:

HWND UnsubclassWindow();
You can also try this code with Online C++ Compiler
Run Code

Static Methods

The CWindowImpl class consists of two static methods. The GetWndClassInfo and the WindowProc method.

Let's get into the details of them.

GetWndClassInfo

This method manages the window class information. It returns a static instance of CWndClassInfo Class.

Syntax:

static CWndClassInfo& GetWndClassInfo();
You can also try this code with Online C++ Compiler
Run Code

WindowProc

The WindowProc implements the window procedure.

Syntax:

static LRESULT CALLBACK WindowProc(
    HWND hWnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam);
You can also try this code with Online C++ Compiler
Run Code


Parameters

  • hWnd: It handles the current window.
     
  • uMsg: It contains the window message.
     
  • wParam: It is the additional message information.
     
  • lParam: It is the additional message information

Frequently Asked Questions

What are Public methods?

The public methods are accessible inside and outside the scope of the class.

What are static methods?

The static methods are used without creating an instance of the class.

Name some static methods of the CWindowImpl class.

The GetWndClassInfo and the WindowProc method are the static methods of the CWindowImpl class.

Conclusion

In this article, we have discussed the details of CWindowImpl Windows Support Class and its methods. We hope the blog has helped you enhance your knowledge of CWindowImpl Windows Support Class. You can refer to our guided paths on the Coding Ninjas Studio platform to learn more about DSADBMSCompetitive ProgrammingPythonJavaJavaScript, etc. To practice and improve yourself in the interview, you can also check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews. Do upvote our blogs to help other ninjas grow. 

Happy Coding!!

Live masterclass