//----------------------------------------------------------------------------------------------------------------- //WTLExplorer : WTLized version of the explorer sample from MSDN. // Use this code at your own risk. We wrote it just for fun :-) // Tested *only* on Win2k. Requires Platform SDK headers. // // //----------------------------------------------------------------------------------------------------------------- #pragma once #ifndef _EXPLORER_COMBO_H_ #define _EXPLORER_COMBO_H_ #include "resource.H" class CExplorerCombo : public CWindowImpl { public: DECLARE_WND_SUPERCLASS(_T("WtlExplorer_ComboBox"), CComboBoxEx::GetWndClassName()) BEGIN_MSG_MAP(CExplorerCombo) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) MESSAGE_HANDLER(WM_SIZE, OnSize) END_MSG_MAP() LRESULT OnCreate(UINT, WPARAM, LPARAM, BOOL& bHandled) { ModifyStyle(0, WS_CLIPCHILDREN); m_tb = CFrameWindowImplBase::CreateSimpleToolBarCtrl(m_hWnd, IDT_GO1, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE | TBSTYLE_LIST); LPTSTR lpstrText = _T("Go\0"); ::SendMessage(m_tb, TB_ADDSTRING, 0, (LPARAM)lpstrText); RECT rect; m_tb.GetItemRect(0, &rect); m_sizeTB.cx = rect.right + 2; m_sizeTB.cy = rect.bottom; bHandled = FALSE; return 1; } LRESULT OnEraseBkgnd(UINT, WPARAM wParam, LPARAM, BOOL&) { RECT rect; GetClientRect(&rect); rect.left = rect.right - m_sizeTB.cx; FillRect((HDC)wParam, &rect, (HBRUSH)(COLOR_3DFACE + 1)); return TRUE; } LRESULT OnSize(UINT, WPARAM, LPARAM, BOOL&) { SetRedraw(FALSE); CComboBox cb = GetComboCtrl(); if(cb.m_hWnd != NULL) cb.SetRedraw(FALSE); CEdit ed = GetEditCtrl(); if(ed.m_hWnd != NULL) ed.SetRedraw(FALSE); if(m_tb.m_hWnd != NULL) m_tb.SetRedraw(FALSE); LRESULT lRet = DefWindowProc(); RECT rect; GetClientRect(&rect); if(cb.m_hWnd != NULL) { RECT rccb; cb.GetWindowRect(&rccb); rccb.right -= m_sizeTB.cx; rccb.bottom = 500; cb.SetWindowPos(NULL, &rccb, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW); } if(ed.m_hWnd != NULL) { RECT rced; ed.GetWindowRect(&rced); rced.right -= m_sizeTB.cx; ed.SetWindowPos(NULL, &rced, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW); } if(m_tb.m_hWnd != NULL) { m_tb.SetWindowPos(NULL, rect.right - m_sizeTB.cx + 2, (rect.bottom - m_sizeTB.cy) / 2, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW); } if(cb.m_hWnd != NULL) cb.SetRedraw(TRUE); if(ed.m_hWnd != NULL) ed.SetRedraw(TRUE); if(m_tb.m_hWnd != NULL) m_tb.SetRedraw(TRUE); SetRedraw(TRUE); Invalidate(); return 0; } private: CToolBarCtrl m_tb; SIZE m_sizeTB; }; #endif