| 31 | |
| 32 | |
| 33 | void CComboWnd::Init(CComboUI* pOwner) |
| 34 | { |
| 35 | m_pOwner = pOwner; |
| 36 | m_pLayout = NULL; |
| 37 | m_iOldSel = m_pOwner->GetCurSel(); |
| 38 | |
| 39 | // Position the popup window in absolute space |
| 40 | SIZE szDrop = m_pOwner->GetDropBoxSize(); |
| 41 | RECT rcOwner = pOwner->GetPos(); |
| 42 | RECT rc = rcOwner; |
| 43 | rc.top = rc.bottom; // ������left��bottom�������������� |
| 44 | rc.bottom = rc.top + szDrop.cy; // ���㵯�����ڸ߶� |
| 45 | if( szDrop.cx > 0 ) rc.right = rc.left + szDrop.cx; // ���㵯�����ڿ��� |
| 46 | |
| 47 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top }; |
| 48 | int cyFixed = 0; |
| 49 | for( int it = 0; it < pOwner->GetCount(); it++ ) { |
| 50 | CControlUI* pControl = static_cast<CControlUI*>(pOwner->GetItemAt(it)); |
| 51 | if( !pControl->IsVisible() ) continue; |
| 52 | SIZE sz = pControl->EstimateSize(szAvailable); |
| 53 | cyFixed += sz.cy; |
| 54 | } |
| 55 | cyFixed += 4; // CVerticalLayoutUI Ĭ�ϵ�Inset ���� |
| 56 | rc.bottom = rc.top + MIN(cyFixed, szDrop.cy); |
| 57 | |
| 58 | ::MapWindowRect(pOwner->GetManager()->GetPaintWindow(), HWND_DESKTOP, &rc); |
| 59 | |
| 60 | MONITORINFO oMonitor = {}; |
| 61 | oMonitor.cbSize = sizeof(oMonitor); |
| 62 | ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); |
| 63 | CDuiRect rcWork = oMonitor.rcWork; |
| 64 | if( rc.bottom > rcWork.bottom ) { |
| 65 | rc.left = rcOwner.left; |
| 66 | rc.right = rcOwner.right; |
| 67 | if( szDrop.cx > 0 ) rc.right = rc.left + szDrop.cx; |
| 68 | rc.top = rcOwner.top - MIN(cyFixed, szDrop.cy); |
| 69 | rc.bottom = rcOwner.top; |
| 70 | ::MapWindowRect(pOwner->GetManager()->GetPaintWindow(), HWND_DESKTOP, &rc); |
| 71 | } |
| 72 | |
| 73 | Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_POPUP, WS_EX_TOOLWINDOW, rc); |
| 74 | // HACK: Don't deselect the parent's caption |
| 75 | HWND hWndParent = m_hWnd; |
| 76 | while( ::GetParent(hWndParent) != NULL ) hWndParent = ::GetParent(hWndParent); |
| 77 | ::ShowWindow(m_hWnd, SW_SHOW); |
| 78 | ::SendMessage(hWndParent, WM_NCACTIVATE, TRUE, 0L); |
| 79 | } |
| 80 | |
| 81 | LPCTSTR CComboWnd::GetWindowClassName() const |
| 82 | { |
no test coverage detected