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
|