15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Disappearing ComboBox on toolbar

Harry Hahne -- hahne@epas.utoronto.ca
Thursday, June 20, 1996

VC++ 4.1, Win 95

I am using a toolbar on a MDI window.  I want to use a ComboBox on the 
toolbar.  I have successfully created the ComboBox.  What I am having trouble 
with is adjusting the width of the ComboBox to adjust itself to fit in the Window, 
when  the Window is resized.

The problem is, when the window is resized, the ComboBox appears briefly and 
then disappears.  If I change to another program and then return to my 
program, the ComboBox appears again.

In the OnCreate function of my view class (derived from CScrollView) I do the following 
to create the ComboBox:

  m_pParentFrame->RecToolBar.SetButtonInfo(5, ID_BROWSE_FLD, TBBS_SEPARATOR,
  	   100);

  CRect rect;
  m_pParentFrame->RecToolBar.GetItemRect(5, &rect);
  rect.top = 3;
  rect.bottom = rect.top + 100;
  if (!m_pParentFrame->m_ComboBox.Create(CBS_DROPDOWNLIST | WS_VISIBLE,
         rect, m_pParentFrame, ID_BROWSE_FLD))
  {
         return FALSE;
  }

This appears to create the ComboBox just fine.  I store the ComboBox object 
in the MDI frame class, so it does not have to be recreated when I change the 
view.

Then in the OnSize() function of the view class, I am adjusting the size of 
the ComboBox after the normal CScrollView::OnSize() is called:

     m_pParentFrame->m_ComboBox.MoveWindow(left,top,width,height);

Any suggestions about what is going wrong?

Harry Hahne
hahne@chass.utoronto.ca



Greg D. Tighe -- gdt@eng.aisinc.com
Monday, June 24, 1996

> The problem is, when the window is resized, the ComboBox appears briefly and 
> then disappears.  If I change to another program and then return to my 
> program, the ComboBox appears again.
> 
...
> 
> Then in the OnSize() function of the view class, I am adjusting the size of 
> the ComboBox after the normal CScrollView::OnSize() is called:
> 
>      m_pParentFrame->m_ComboBox.MoveWindow(left,top,width,height);
> 
> Any suggestions about what is going wrong?
> 
Try using SetWindowPos() instead of MoveWindow():

m_pParentFrame->m_ComboBox.SetWindowPos (&wndTop,
         left,top,width,height, SWP_SHOWWINDOW);

This will resize your combobox *and* set it to the top of the Z-order 
so it should get drawn on top of all the other controls which make up 
your toolbar.

	-Greg Tighe
	Applied Intelligent Systems, Inc.
	Ann Arbor, MI
	gdt@aisinc.com




| Вернуться в корень Архива |