| 92 | } |
| 93 | |
| 94 | LRESULT CComboWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 95 | { |
| 96 | if( uMsg == WM_CREATE ) { |
| 97 | m_pm.Init(m_hWnd); |
| 98 | // The trick is to add the items to the new container. Their owner gets |
| 99 | // reassigned by this operation - which is why it is important to reassign |
| 100 | // the items back to the righfull owner/manager when the window closes. |
| 101 | m_pLayout = new CVerticalLayoutUI; |
| 102 | m_pm.UseParentResource(m_pOwner->GetManager()); |
| 103 | m_pLayout->SetManager(&m_pm, NULL, true); |
| 104 | LPCTSTR pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(_T("VerticalLayout")); |
| 105 | if( pDefaultAttributes ) { |
| 106 | m_pLayout->ApplyAttributeList(pDefaultAttributes); |
| 107 | } |
| 108 | m_pLayout->SetInset(CDuiRect(1, 1, 1, 1)); |
| 109 | m_pLayout->SetBkColor(0xFFFFFFFF); |
| 110 | m_pLayout->SetBorderColor(0xFFC6C7D2); |
| 111 | m_pLayout->SetBorderSize(1); |
| 112 | m_pLayout->SetAutoDestroy(false); |
| 113 | m_pLayout->EnableScrollBar(); |
| 114 | m_pLayout->ApplyAttributeList(m_pOwner->GetDropBoxAttributeList()); |
| 115 | for( int i = 0; i < m_pOwner->GetCount(); i++ ) { |
| 116 | m_pLayout->Add(static_cast<CControlUI*>(m_pOwner->GetItemAt(i))); |
| 117 | } |
| 118 | m_pm.AttachDialog(m_pLayout); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | else if( uMsg == WM_CLOSE ) { |
| 123 | m_pOwner->SetManager(m_pOwner->GetManager(), m_pOwner->GetParent(), false); |
| 124 | m_pOwner->SetPos(m_pOwner->GetPos()); |
| 125 | m_pOwner->SetFocus(); |
| 126 | } |
| 127 | else if( uMsg == WM_LBUTTONUP ) { |
| 128 | POINT pt = { 0 }; |
| 129 | ::GetCursorPos(&pt); |
| 130 | ::ScreenToClient(m_pm.GetPaintWindow(), &pt); |
| 131 | CControlUI* pControl = m_pm.FindControl(pt); |
| 132 | if( pControl && _tcscmp(pControl->GetClass(), _T("ScrollBarUI")) != 0 ) PostMessage(WM_KILLFOCUS); |
| 133 | } |
| 134 | else if( uMsg == WM_KEYDOWN ) { |
| 135 | switch( wParam ) { |
| 136 | case VK_ESCAPE: |
| 137 | m_pOwner->SelectItem(m_iOldSel, true); |
| 138 | EnsureVisible(m_iOldSel); |
| 139 | // FALL THROUGH... |
| 140 | case VK_RETURN: |
| 141 | PostMessage(WM_KILLFOCUS); |
| 142 | break; |
| 143 | default: |
| 144 | TEventUI event; |
| 145 | event.Type = UIEVENT_KEYDOWN; |
| 146 | event.chKey = (TCHAR)wParam; |
| 147 | m_pOwner->DoEvent(event); |
| 148 | EnsureVisible(m_pOwner->GetCurSel()); |
| 149 | return 0; |
| 150 | } |
| 151 | } |
nothing calls this directly
no test coverage detected