Link to home
Start Free TrialLog in
Avatar of bs161900
bs161900

asked on

OnCreate handler never called.

I am working on a formview application. One of my controls is a user defined spin button control based on CSpinButtonCtrl, so in my formview class I embed it as a data member. This data member is connected with the control through DDX. When I implement an OnCreate message handler for this control it seems never been called. Could someone tell me why this is happening.
I want to change the default range upon creation of minimum 100 and maximum 0 to minimum 0 and maximum 100, so that pressing the up arrow increases the position value and pressing the down arrow decreases it. Using the default settings inverts the scroll directions and that is not what I want. If someone could solve the problem and tell me if this is the good approach, please let me know.
Thanks in advance, Ronny
Avatar of chensu
chensu
Flag of Canada image

Unlikely. Use Spy++ to see if the WM_CREATE message is sent to the control.
Avatar of naveenkohli
naveenkohli

You could have easily accomplished  this in OnInitialUpdate of your form view class..

void CTryFormView::OnInitialUpdate()
{
      CFormView::OnInitialUpdate();
      m_ctrlSpin.SetRange (0, 100);
      GetParentFrame()->RecalcLayout();
      ResizeParentToFit();

}

This will invert the acton of spinner. Uparrow will increase and down arrow wiill decrease...
Hi!
WM_CREATE will not catch by MFC object when it attached to the window trough DDX or SubclassDlgItem (at this moment  window already created and all needed messages, include WM_CREATE, are sended.
use naveenkohli method.
DDX connects the object to the window.  When DDX is called for the first time, the window has already been created (and WM_CREATE called.)  So the message map that is attached to the object will never intercept the WM_CREATE because, it has passed before it was connected.


ASKER CERTIFIED SOLUTION
Avatar of abk102299
abk102299

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bs161900

ASKER

Although it is been a while ago that I asked the question, I really appreciate your late respons. It demonstrates a whole different approach for control initialization, that I certainly will use in the future. Thanx
abk,
i did not check the answer you gave for this question for some time.
For doing a simple modification to a simple control, i don't know if its a good idea to introduce a new control class into the project. Especially in this case where only Range needed to be altered, just think for a moment. The way you have suggested is definitely the way to go if that control is going to be used time and gaian in the project or anywhere else.