Re: CSliderCtrl SetPos Window Refreshing
"ssylee" <stanigator@gmail.com> wrote in message
news:e28c24a3-f63f-432c-923c-d957afa28942@q33g2000pra.googlegroups.com...
void UserControls::OnEnUpdateTBY()
{
BrachySimApp *theApp = (BrachySimApp*) AfxGetApp();
if(theApp->activeUSview->mouseclick || userupdate)
{
if(!desired_slider_initialized)
{
desired_slider_initialized = true;
desired_depth_slider.SetPos(50);
desired_depth_slider.UpdateWindow();
From your picture, it looks like the slider window is being updated to the
new position, but the old one isn't being erased. For the erasing, the
parent dialog needs to be redrawn. So also call
this->UpdateWindow(); // which can be simplified by removing
"this->"
See if that works.
If not, perhaps it's when you call SetPos() that's the issue. Is
OnEnUpdateTBY() a handler for when an edit control has changed? Should be
OK at this point. But when I get weird behavior like this, instead of
calling SetPos()/UpdateWindow(), I postpone them until the existing messages
have been pumped so none of them will screw up what I'm trying to do. So I
would replace
desired_depth_slider.SetPos(50);
desired_depth_slider.UpdateWindow();
with
PostMessage ( UWM_UPDATE_SLIDER, 50 ); // #define UWM_UPDATE_SLIDER
(WM_APP+n) where n is after the last one you use for this dialog (probably
is unused, so use 0)
and handle it with
afx_msg LRESULT OnUpdateSlider(WPARAM wParam, LPARAM)
{
int pos = (int) wParam; // will be 50 here
desired_depth_slider.SetPos(pos);
desired_depth_slider.UpdateWindow();
return 0; // return value doens't matter
}