PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 11, 2022

[FIXED] How to know when CWnd's Create function was called?

 July 11, 2022     message, mfc     No comments   

Issue

I've wrote a class wrapping a grid controls. I want to init the custom grid class when it is created by calling Create function.

Is there a way that i can catch the event?


Solution

Yes, if CWnd:Create or Cwd:CreateEx is used, it is possible to catch the Win32 event with:

afx_msg int OnCreate(
   LPCREATESTRUCT lpCreateStruct 
);

See CWnd::OnCreate

With the corresponding mapping:

BEGIN_MESSAGE_MAP(MyGrid, CWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()

Attention: If your control is directly added on a dialog template by the designer (ie, using DDX), the function CWnd:.OnCreate() is not called.

In all cases, the following function is called at creation, after the Hwnd (handle of window) is initialized:

virtual void PreSubclassWindow( );

See PreSubclassWindow

Best regards, Alain



Answered By - Alain
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing