rose3377
asked on
Spin control... yet again
Me again,
Something is going wrong... refer to the history of the question...
I inserted this into OnInitDialog...
OnVScroll(SB_THUMBPOSITION ,m_spin1,N ULL)
It compiles and crashes...oops!
When I debug, it perfroms that line and goes to OnVScroll and gets hit somewhere around if(bla bla bla)
HELP PLEEZ... I am now getting desperate
Thanx
Something is going wrong... refer to the history of the question...
I inserted this into OnInitDialog...
OnVScroll(SB_THUMBPOSITION
It compiles and crashes...oops!
When I debug, it perfroms that line and goes to OnVScroll and gets hit somewhere around if(bla bla bla)
HELP PLEEZ... I am now getting desperate
Thanx
Yes, you need to wait until the window is ready to display. You can put OnVScroll() in OnPaint(). If you don't want to reload OnVScroll() afterwards, which means you only want to run once when the window starts, you need a flag to disable it, such as:
void YouClass::OnPaint()
{
.
.
static bool RunOnceFlag=false;
if(!RunOnceFlag) {
OnVScroll();
RunOnceFlag=true;
}
}
Answer to second question: You could use integer and then devided by 10.
void YouClass::OnPaint()
{
.
.
static bool RunOnceFlag=false;
if(!RunOnceFlag) {
OnVScroll();
RunOnceFlag=true;
}
}
Answer to second question: You could use integer and then devided by 10.
ASKER
Refer to the history of the question in titled Spin Control again
I placed that code in OnPaint. The program gets to OnVScroll...
CString strValue;
strValue.Format("%3.1f", (double) nPos / 10.0);
***((CSpinButtonCtrl*) pScrollBar)->GetBuddy()
->SetWindowText(strValue);
and crashes on the line with stars...
I placed that code in OnPaint. The program gets to OnVScroll...
CString strValue;
strValue.Format("%3.1f", (double) nPos / 10.0);
***((CSpinButtonCtrl*) pScrollBar)->GetBuddy()
->SetWindowText(strValue);
and crashes on the line with stars...
ASKER
See Comment Above...
Yours:
***((CSpinButtonCtrl*) pScrollBar)->GetBuddy()
->SetWindowText(strValue);
There should be parenthesis around the GetBuddy function. Remember, it is returnin a CWnd*.
Try:::
(((CSpinButtonCtrl*)pScrol lBar)->Get Buddy())-> SetWindowT ext(strVal ue);
Does that do it?
***((CSpinButtonCtrl*) pScrollBar)->GetBuddy()
->SetWindowText(strValue);
There should be parenthesis around the GetBuddy function. Remember, it is returnin a CWnd*.
Try:::
(((CSpinButtonCtrl*)pScrol
Does that do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Calling a notification function directly, like tsauy suggests to do with OnVScroll() directly from OnPaint(), is completely sick and wrong. If you're unlucky, it will actually work and you'll be fooled until your users upgrade to a new verison of windows and it breaks. Nominally, it'll cause a crash.
Don't do it; it's wrong.
B ekiM
Don't do it; it's wrong.
B ekiM
ASKER
Another thing...
If I overlook the inital display problem and I continue, when I press up arrow, it increments in 0.1 which is great.
If I type in 12 and press up arrow, it becomes 1.3
How do I correct this....?