Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Please help me in calling OnCreate(LPCREATESTRUCT LPCS) FUNCTION PRAGMATICALLY.

I am unable to proceed further because of failing in filling LPCREATESTRUCT structure.
Can any one help me on this?


Thanks,
Sarath.
Posted
Comments
Richard MacCutchan 11-Nov-13 6:51am    
Why would you want to? This method is called automatically by the framework in MFC when the Window is first being created, and can only be used at that point.
CPallini 11-Nov-13 7:30am    
Why do you want to call it?

You don't call OnXYZ type functions, they are called by the framework upon receiving messages. These functions are called message handlers, because they handle messages for specific types of windows events.

For more info check the documentation on Message Handlers[^]

On a sidenote, OnCreate isn't supposed to fill in the passed struct - it is provided by the framework, who got all the parameters from the function that created the new window, e. g. CreateWindow()[^]
 
Share this answer
 
Hello, you would not call OnCreate programatically, OnCreate is called by MFC framework.

If you are having trouble creating you main window, I believe the solution here will help you: Document View Architecture in VC++ MFC[^]
 
Share this answer
 
v2
C#
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CFormView::OnCreate(lpCreateStruct) == -1)
      return -1;

   // TODO:  Add your specialized creation code here

   return 0;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900