Print Page | Close Window

Modifying ToolBar During Runtime

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=4171
Printed Date: 04 October 2024 at 11:26am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Modifying ToolBar During Runtime
Posted By: nguyena1
Subject: Modifying ToolBar During Runtime
Date Posted: 08 May 2006 at 3:00pm

What I'm trying to do is have a combo box on the tool bar that I can some what destroy and create during runtime in order to switch styles between CBS_DROPDOWN and CBS_DROPDOWNLIST. 

Problem is:  After its changed, i have to make a mousemove inorder for the combo box to actually come up instead of a grey area. 

What I have inside of CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl) for this works great on start up.  FYI:  I make a CXTPControlCustom and do lpCreateControl->pControl = pControlEntry.  I save a pointer to this CXTPControlCustom in my custom combo class.(call it m_pControlEntry)

Here is the code for how I change the combo box. for example from dropdown to dropdown list

//////////////////////////////////////////////////////////// /////////////////////////

 ModifyStyle(CBS_DROPDOWN, CBS_DROPDOWNLIST | WS_VSCROLL);
 
if (this == NULL)
  return FALSE;
 if (this->GetSafeHwnd() == NULL)
  return FALSE;
 CWnd* pParent = this->GetParent();
 if (pParent == NULL)
  return FALSE;
 DWORD dwStyle = this->GetStyle();
 DWORD dwStyleEx = this->GetExStyle();
 CRect rc;
 this->GetDroppedControlRect(&rc);
 pParent->ScreenToClient(&rc);
 UINT nID = this->GetDlgCtrlID();
 CFont* pFont = this->GetFont();
 CWnd* pWndAfter = this->GetNextWindow(GW_HWNDPREV);

 CComboBox comboNew;
 if (!comboNew.CreateEx(dwStyleEx, _T("COMBOBOX"), _T(""),
  dwStyle, rc, AfxGetMainWnd(), nID, lpParam))
  return FALSE;

    comboNew.ShowWindow(SW_HIDE);

    SetOwner(AfxGetMainWnd());

    comboNew.SetFont(pFont);
 this->DestroyWindow();
 HWND hWnd = comboNew.Detach();
 this->Attach(hWnd);

    if (m_pControlEntry)
    {
        m_pControlEntry->SetControl(this);
    }

//////////////////////////////////////////////////////////// ////////////////

So afterwards, theres a grey area until a little after i move my mouse, is there some kind of update i can call?  m_ComboBox for example is the name of the combobox.

I've tried m_ComboBox.RedrawWindow(), Invalidate(), Redraw(), SetVisible, and none of those will do it.

Tony




Replies:
Posted By: nguyena1
Date Posted: 09 May 2006 at 12:28pm

Here is a sample project i've done this to.  For Codejock version 10.1.

Open up ..samples\commandbars\commoncontrols and please replace the mainfrm.cpp, mainfrm.h, and resource.h files and in the res folder, replace OptionsBar.bmp with the 4 files attached here.

What I've done is added a combo box to the options tool bar.  When you click on Hide Vertically, I recreate the combo box to a dropdownlist(see line 633 of mainfrm.cpp).  When you click on Show vertically(see line 683 of mainfrm.cpp), I recreate the combo box to a dropdown style. 

Whats even funnier with this is that, when it does get recreated, the combo box doesnt show any more. If you maximize or minimize, the combo box will show up with the right attributes.  What is the key call that makes this combo box show up?

https://forum.codejock.com/uploads/nguyena1/2006-05-09_122708_FourFiles.zip - 2006-05-09_122708_FourFiles.zip




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net