Discussion:
CMFCToolBarComboBoxButton not redrawing after update
(too old to reply)
Bogdan
2008-10-10 13:41:12 UTC
Permalink
Hi,

I have a combo box button (CBS_DROPDOWNLIST) with a dynamic content in a
toolbar. If I update currently selected item (DeleteItem() + AddItem()) the
change will not be reflected until I move a cursor over the box (which
causes a redraw). That is, the old/deleted item will be displayed until I
move the cursor over the control or drag another window over it. I tried
Invalidatexxx() and Redrawxxx() methods on the embedded combobox but without
any success.

I used to have a combo box in CToolBar and had no such problems so it must
be an issue in the FeaturePack library.

Any suggestions on how to tackle this one?
Thanks,
Bogdan
Damir Valiulin
2008-10-15 15:40:04 UTC
Permalink
Bogdan,

I am assuming you derived your own combo button class (lets call it
CMyComboButon) from CMFCToolBarComboBoxButton. If so, you can add the
following member function to it:

void RFC_CMyComboButon::Redraw()
{
if (m_pWndCombo->GetSafeHwnd() != NULL && m_pWndCombo->GetParent() != NULL){
m_pWndCombo->GetParent()->InvalidateRect(m_rectCombo);
m_pWndCombo->GetParent()->UpdateWindow();
}
}

Then call this "Redraw" function after you add/delete items.

Regards,
Damir

P.S. BTW, I saw couple of your previous posts with other frustrations with
MFC Feature Pack. I had the same issues and decided it would take too much
time to convert years of code spent on old MFC derived classes. Especially
given how POORLY documented this feature pack is and how rough the code feels
compared to old MFC. Getting custom drawn Combobox to show up on toolbar was
how far I got on this...
Post by Bogdan
Hi,
I have a combo box button (CBS_DROPDOWNLIST) with a dynamic content in a
toolbar. If I update currently selected item (DeleteItem() + AddItem()) the
change will not be reflected until I move a cursor over the box (which
causes a redraw). That is, the old/deleted item will be displayed until I
move the cursor over the control or drag another window over it. I tried
Invalidatexxx() and Redrawxxx() methods on the embedded combobox but without
any success.
I used to have a combo box in CToolBar and had no such problems so it must
be an issue in the FeaturePack library.
Any suggestions on how to tackle this one?
Thanks,
Bogdan
Bogdan
2008-10-15 16:58:18 UTC
Permalink
Damir,

Thanks for the reply. Your suggestion works for me. I have to say that I
was quite reluctant to try it because I thought that I had tried it before.
I'm glad I did.
I'm no longer actively porting my app to FeaturePack (reasons are too
obvious). I did not completely give up on it yet either. I'll open the
project and make necessary updates whenever I encounter anything that might
help me to move ahead (like your unexpected reply).

Thanks again,
Bogdan
Post by Damir Valiulin
Bogdan,
I am assuming you derived your own combo button class (lets call it
CMyComboButon) from CMFCToolBarComboBoxButton. If so, you can add the
void RFC_CMyComboButon::Redraw()
{
if (m_pWndCombo->GetSafeHwnd() != NULL && m_pWndCombo->GetParent() != NULL){
m_pWndCombo->GetParent()->InvalidateRect(m_rectCombo);
m_pWndCombo->GetParent()->UpdateWindow();
}
}
Then call this "Redraw" function after you add/delete items.
Regards,
Damir
P.S. BTW, I saw couple of your previous posts with other frustrations with
MFC Feature Pack. I had the same issues and decided it would take too much
time to convert years of code spent on old MFC derived classes. Especially
given how POORLY documented this feature pack is and how rough the code feels
compared to old MFC. Getting custom drawn Combobox to show up on toolbar was
how far I got on this...
Кисельгов
2015-09-22 08:37:39 UTC
Permalink
Post by Bogdan
Hi,
I have a combo box button (CBS_DROPDOWNLIST) with a dynamic content in a
toolbar. If I update currently selected item (DeleteItem() + AddItem()) the
change will not be reflected until I move a cursor over the box (which
causes a redraw). That is, the old/deleted item will be displayed until I
move the cursor over the control or drag another window over it. I tried
Invalidatexxx() and Redrawxxx() methods on the embedded combobox but without
any success.
I used to have a combo box in CToolBar and had no such problems so it must
be an issue in the FeaturePack library.
Any suggestions on how to tackle this one?
Thanks,
Bogdan
You should call CMFCToolbar::InvalidateButton() method. No any subclassing for CMFCToolBarComboBoxButton is required.
Loading...