void MainDialog::OnTrayIconNotify(WPARAM wParam, LPARAM lParam) { if (wParam != m_niData.uID) return; switch (LOWORD(lParam)) { case WM_RBUTTONUP: { POINT point; GetCursorPos(&point); // 获取鼠标指针位置(屏幕坐标) CMenuWnd* pMenu = new CMenuWnd(m_hWnd); //ScreenToClient(m_hWnd, &point); // 将鼠标指针位置转换为窗口坐标 //ClientToScreen(m_hWnd, &point); STRINGorID xml(_T("menu\\TrayIconMenu.xml")); pMenu->Init(NULL, xml, _T("xml"), point); } break; case WM_LBUTTONDOWN: BringToTop(); StopNewMsgTrayEmot(); break; case WM_LBUTTONDBLCLK: break; default: break; } }
void MainDialog::OnClick(TNotifyUI& msg) { PTR_VOID(msg.pSender); if (msg.pSender == m_pbtnSysConfig) { //系统设置 module::getSysConfigModule()->showSysConfigDialog(m_hWnd); } else if (msg.pSender == m_pbtnOnlineStatus) { CMenuWnd* pMenu = new CMenuWnd(m_hWnd); DuiLib::CPoint point = msg.ptMouse; ClientToScreen(m_hWnd, &point); STRINGorID xml(_T("menu\\lineStatus.xml")); pMenu->Init(NULL, xml, _T("xml"), point); } else if (msg.pSender == m_pbtnMyFace) { } else if (msg.pSender == m_pbtnClose || msg.pSender == m_pbtnMinMize) { ShowWindow(false); return; } __super::OnClick(msg); }
void CFrameWnd::Notify( TNotifyUI& msg ) { if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("btnMenu") ) { POINT pt = {msg.ptMouse.x, msg.ptMouse.y}; CMenuWnd *pMenu = new CMenuWnd(_T("Menu/menu.xml")); pMenu->Init(*this, pt); pMenu->ShowWindow(TRUE); } } else if(msg.sType == _T("selectchanged")) { CDuiString strName = msg.pSender->GetName(); CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(_T("tabTest"))); if(strName == _T("OptionDemo1")) pControl->SelectItem(0); else if(strName == _T("OptionDemo2")) pControl->SelectItem(1); else if(strName == _T("OptionDemo3")) pControl->SelectItem(2); } __super::Notify(msg); }
LRESULT CMenuWnd::OnKillFocus( UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled ) { HWND hFocusWnd = (HWND)wParam; BOOL bInMenuWindowList = FALSE; ContextMenuParam param; param.hWnd = GetHWND(); ContextMenuObserver::Iterator<BOOL, ContextMenuParam> iterator(s_context_menu_observer); ReceiverImplBase<BOOL, ContextMenuParam>* pReceiver = iterator.next(); while( pReceiver != NULL ) { CMenuWnd* pContextMenu = dynamic_cast<CMenuWnd*>(pReceiver); if( pContextMenu != NULL && pContextMenu->GetHWND() == hFocusWnd ) { bInMenuWindowList = TRUE; break; } pReceiver = iterator.next(); } if( !bInMenuWindowList ) { param.wParam = 1; s_context_menu_observer.RBroadcast(param); } bHandled=false; return 0; }
void CFrameWnd::Notify( TNotifyUI& msg ) { if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("btnMenu") ) { CMenuWnd* pMenu = new CMenuWnd(); CPoint point = msg.ptMouse; ClientToScreen(m_hWnd, &point); pMenu->Init(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo); //左侧打开菜单 //pMenu->Init(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo, eMenuAlignment_Right ); //左上侧打开菜单 //pMenu->Init(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo, eMenuAlignment_Right | eMenuAlignment_Bottom); } else if (msg.pSender->GetName() == _T("Menu_btn") ) { DUI__Trace(_T("你单击了按钮")); } } __super::Notify(msg); }
LRESULT CMenuWnd::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { HWND hFocusWnd = (HWND)wParam; BOOL bInMenuWindowList = FALSE; ContextMenuParam param; param.hWnd = GetHWND(); MenuObserverImpl::Iterator iterator(CMenuWnd::GetGlobalContextMenuObserver()); MenuMenuReceiverImplBase* pReceiver = iterator.next(); while( pReceiver != NULL ) { CMenuWnd* pContextMenu = dynamic_cast<CMenuWnd*>(pReceiver); if( pContextMenu != NULL && pContextMenu->GetHWND() == hFocusWnd ) { bInMenuWindowList = TRUE; break; } pReceiver = iterator.next(); } if( !bInMenuWindowList ) { param.wParam = 1; CMenuWnd::GetGlobalContextMenuObserver().RBroadcast(param); return 0; } return 0; }
void MainFrame::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, kWindowInit) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, kClick) == 0) { if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MINIMIZE); #else SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MAXIMIZE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(true); #else SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_RESTORE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(false); #else SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), _T("btn_menu")) == 0) { CMenuWnd* pMenu = new CMenuWnd(m_hWnd); CPoint point = msg.ptMouse; ClientToScreen(m_hWnd, &point); STRINGorID xml(IDR_XML_MENU); pMenu->Init(NULL, xml, _T("xml"), point); } } else if (_tcsicmp(msg.sType, kTimer) == 0) { return OnTimer(msg); } }
void CFrameWnd::Notify( TNotifyUI& msg ) { if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("btnMenu") ) { CPoint point(0, 0); GetCursorPos(&point); CMenuWnd* pMenu = CMenuWnd::CreateMenu(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo); //左侧打开菜单 //CMenuWnd* pMenu = CMenuWnd::CreateMenu(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo, eMenuAlignment_Right ); //左上侧打开菜单 //CMenuWnd* pMenu = CMenuWnd::CreateMenu(NULL, _T("menutest.xml"), point, &m_PaintManager, &m_MenuCheckInfo, eMenuAlignment_Right | eMenuAlignment_Bottom); // 先获取到根项,然后就可以使用rootMenu插到到菜单内的任意子菜单项,然后做添加删除操作 CMenuUI* rootMenu = pMenu->GetMenuUI(); if (rootMenu != NULL) { CMenuElementUI* pNew = new CMenuElementUI; pNew->SetName(_T("Menu_Dynamic")); pNew->SetText(_T("动态一级菜单")); pNew->SetShowExplandIcon(true); pNew->SetIcon(_T("WebSit.png")); pNew->SetIconSize(16,16); CMenuElementUI* pSubNew = new CMenuElementUI; pSubNew->SetText(_T("动态二级菜单")); pSubNew->SetName(_T("Menu_Dynamic")); pSubNew->SetIcon(_T("Virus.png")); pSubNew->SetIconSize(16,16); pNew->Add(pSubNew); rootMenu->Add(pNew); CMenuElementUI* pNew2 = new CMenuElementUI; pNew2->SetName(_T("Menu_Dynamic")); pNew2->SetText(_T("动态一级菜单2")); rootMenu->AddAt(pNew2,2); } // 动态添加后重新设置菜单的大小 pMenu->ResizeMenu(); } else if (msg.pSender->GetName() == _T("Menu_btn") ) { DUI__Trace(_T("你单击了按钮")); } } __super::Notify(msg); }
// ------------------------------------------------------------------------ // return, click. int CZiMainFrame::OnClickRightButton(TNotifyUI & msg) { CMenuWnd * pMenu = new CMenuWnd(); if(!pMenu) return -1; POINT pt = { msg.ptMouse.x, msg.ptMouse.y }; ::ClientToScreen(*this, &pt); pMenu->Init(msg.pSender, pt); return 0; }
void MsgBubbleItem::PopupMenu(bool copy, bool recall, bool retweet/* = true*/) { if(!action_menu_) return; POINT point; ::GetCursorPos(&point); CMenuWnd* pMenu = new CMenuWnd(NULL); STRINGorID xml(L"bubble_menu.xml"); pMenu->Init(xml, _T("xml"), point); CMenuElementUI* cop = (CMenuElementUI*) pMenu->FindControl(L"copy"); cop->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); cop->SetVisible(copy); CMenuElementUI* del = (CMenuElementUI*)pMenu->FindControl(L"delete"); del->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); CMenuElementUI* transform = (CMenuElementUI*)pMenu->FindControl(L"transform"); transform->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); transform->SetVisible(typeid(*this) == typeid(MsgBubbleAudio)); CMenuElementUI* rec = (CMenuElementUI*)pMenu->FindControl(L"recall"); rec->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); rec->SetVisible(my_msg_ && recall && msg_.receiver_accid_ != LoginManager::GetInstance()->GetAccount()); CMenuElementUI* ret = (CMenuElementUI*)pMenu->FindControl(L"retweet"); ret->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); ret->SetVisible(retweet); pMenu->Show(); }
virtual void Notify(TNotifyUI& msg) { if (msg.sType == DUI_MSGTYPE_CLICK) { if (msg.pSender->GetName() == "w_close") this->Close(); } else if (msg.sType == _T("menu")) { if (msg.pSender->GetName() != _T("AddressList")) return; CMenuWnd* pMenu = new CMenuWnd(); if (pMenu == NULL) { return; } POINT pt = { msg.ptMouse.x, msg.ptMouse.y }; ::ClientToScreen(*this, &pt); pMenu->Init(msg.pSender, pt); } };
void MsgBubbleItem::PopupMenu( bool copy ) { if(!action_menu_) return; POINT point; ::GetCursorPos(&point); CMenuWnd* pMenu = new CMenuWnd(NULL); STRINGorID xml(L"bubble_menu.xml"); pMenu->Init(xml, _T("xml"), point); CMenuElementUI* cop = (CMenuElementUI*) pMenu->FindControl(L"copy"); cop->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); cop->SetVisible(copy); CMenuElementUI* del = (CMenuElementUI*)pMenu->FindControl(L"delete"); del->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); CMenuElementUI* transform = (CMenuElementUI*)pMenu->FindControl(L"transform"); transform->AttachSelect(nbase::Bind(&MsgBubbleItem::OnMenu, this, std::placeholders::_1)); transform->SetVisible(typeid(*this) == typeid(MsgBubbleAudio)); pMenu->Show(); }
LRESULT CMenuWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if( uMsg == WM_CREATE ) { if( m_pOwner != NULL) { LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); styleValue &= ~WS_CAPTION; ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); RECT rcClient; ::GetClientRect(*this, &rcClient); ::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, \ rcClient.bottom - rcClient.top, SWP_FRAMECHANGED); m_pm.Init(m_hWnd); // The trick is to add the items to the new container. Their owner gets // reassigned by this operation - which is why it is important to reassign // the items back to the righfull owner/manager when the window closes. m_pLayout = new CMenuUI(); m_pm.UseParentResource(m_pOwner->GetManager()); m_pLayout->SetManager(&m_pm, NULL, true); LPCTSTR pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(kMenuUIInterfaceName); if( pDefaultAttributes ) { m_pLayout->ApplyAttributeList(pDefaultAttributes); } m_pLayout->SetBkColor(0xFFFFFFFF); m_pLayout->SetBorderColor(0xFF85E4FF); m_pLayout->SetBorderSize(0); m_pLayout->SetAutoDestroy(false); m_pLayout->EnableScrollBar(); for( int i = 0; i < m_pOwner->GetCount(); i++ ) { if(m_pOwner->GetItemAt(i)->GetInterface(kMenuElementUIInterfaceName) != NULL ){ (static_cast<CMenuElementUI*>(m_pOwner->GetItemAt(i)))->SetOwner(m_pLayout); m_pLayout->Add(static_cast<CControlUI*>(m_pOwner->GetItemAt(i))); } } m_pm.AttachDialog(m_pLayout); // Position the popup window in absolute space RECT rcOwner = m_pOwner->GetPos(); RECT rc = rcOwner; int cxFixed = 0; int cyFixed = 0; #if defined(WIN32) && !defined(UNDER_CE) MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); CDuiRect rcWork = oMonitor.rcWork; #else CDuiRect rcWork; GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWork); #endif SIZE szAvailable = { rcWork.right - rcWork.left, rcWork.bottom - rcWork.top }; for( int it = 0; it < m_pOwner->GetCount(); it++ ) { if(m_pOwner->GetItemAt(it)->GetInterface(kMenuElementUIInterfaceName) != NULL ){ CControlUI* pControl = static_cast<CControlUI*>(m_pOwner->GetItemAt(it)); SIZE sz = pControl->EstimateSize(szAvailable); cyFixed += sz.cy; if( cxFixed < sz.cx ) cxFixed = sz.cx; } } cyFixed += 4; cxFixed += 4; RECT rcWindow; GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWindow); rc.top = rcOwner.top; rc.bottom = rc.top + cyFixed; ::MapWindowRect(m_pOwner->GetManager()->GetPaintWindow(), HWND_DESKTOP, &rc); rc.left = rcWindow.right; rc.right = rc.left + cxFixed; rc.right += 2; bool bReachBottom = false; bool bReachRight = false; LONG chRightAlgin = 0; LONG chBottomAlgin = 0; RECT rcPreWindow = {0}; ContextMenuObserver::Iterator<BOOL, ContextMenuParam> iterator(s_context_menu_observer); ReceiverImplBase<BOOL, ContextMenuParam>* pReceiver = iterator.next(); while( pReceiver != NULL ) { CMenuWnd* pContextMenu = dynamic_cast<CMenuWnd*>(pReceiver); if( pContextMenu != NULL ) { GetWindowRect(pContextMenu->GetHWND(), &rcPreWindow); bReachRight = rcPreWindow.left >= rcWindow.right; bReachBottom = rcPreWindow.top >= rcWindow.bottom; if( pContextMenu->GetHWND() == m_pOwner->GetManager()->GetPaintWindow() || bReachBottom || bReachRight ) break; } pReceiver = iterator.next(); } if (bReachBottom) { rc.bottom = rcWindow.top; rc.top = rc.bottom - cyFixed; } if (bReachRight) { rc.right = rcWindow.left; rc.left = rc.right - cxFixed; } if( rc.bottom > rcWork.bottom ) { rc.bottom = rc.top; rc.top = rc.bottom - cyFixed; } if (rc.right > rcWork.right) { rc.right = rcWindow.left; rc.left = rc.right - cxFixed; rc.top = rcWindow.bottom; rc.bottom = rc.top + cyFixed; } if( rc.top < rcWork.top ) { rc.top = rcOwner.top; rc.bottom = rc.top + cyFixed; } if (rc.left < rcWork.left) { rc.left = rcWindow.right; rc.right = rc.left + cxFixed; } MoveWindow(m_hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE); } else { m_pm.Init(m_hWnd); CDialogBuilder builder; CMenuBuilderCallback menuCallback; CControlUI* pRoot = builder.Create(m_xml, m_sType.GetData(), &menuCallback, &m_pm); m_pm.AttachDialog(pRoot); #if defined(WIN32) && !defined(UNDER_CE) MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); CDuiRect rcWork = oMonitor.rcWork; #else CDuiRect rcWork; GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWork); #endif SIZE szAvailable = { rcWork.right - rcWork.left, rcWork.bottom - rcWork.top }; szAvailable = pRoot->EstimateSize(szAvailable); m_pm.SetInitSize(szAvailable.cx, szAvailable.cy); DWORD dwAlignment = eMenuAlignment_Left | eMenuAlignment_Top; SIZE szInit = m_pm.GetInitSize(); CDuiRect rc; CDuiPoint point = m_BasedPoint; rc.left = point.x; rc.top = point.y; rc.right = rc.left + szInit.cx; rc.bottom = rc.top + szInit.cy; int nWidth = rc.GetWidth(); int nHeight = rc.GetHeight(); if (dwAlignment & eMenuAlignment_Right) { rc.right = point.x; rc.left = rc.right - nWidth; } if (dwAlignment & eMenuAlignment_Bottom) { rc.bottom = point.y; rc.top = rc.bottom - nHeight; } SetForegroundWindow(m_hWnd); MoveWindow(m_hWnd, rc.left, rc.top, rc.GetWidth(), rc.GetHeight(), FALSE); SetWindowPos(m_hWnd, HWND_TOPMOST, rc.left, rc.top, rc.GetWidth(), rc.GetHeight(), SWP_SHOWWINDOW); } return 0; } else if( uMsg == WM_CLOSE ) { if( m_pOwner != NULL ) { m_pOwner->SetManager(m_pOwner->GetManager(), m_pOwner->GetParent(), false); m_pOwner->SetPos(m_pOwner->GetPos()); m_pOwner->SetFocus(); } } else if( uMsg == WM_RBUTTONDOWN || uMsg == WM_CONTEXTMENU || uMsg == WM_RBUTTONUP || uMsg == WM_RBUTTONDBLCLK ) { return 0L; } else if( uMsg == WM_KILLFOCUS ) { HWND hFocusWnd = (HWND)wParam; BOOL bInMenuWindowList = FALSE; ContextMenuParam param; param.hWnd = GetHWND(); ContextMenuObserver::Iterator<BOOL, ContextMenuParam> iterator(s_context_menu_observer); ReceiverImplBase<BOOL, ContextMenuParam>* pReceiver = iterator.next(); while( pReceiver != NULL ) { CMenuWnd* pContextMenu = dynamic_cast<CMenuWnd*>(pReceiver); if( pContextMenu != NULL && pContextMenu->GetHWND() == hFocusWnd ) { bInMenuWindowList = TRUE; break; } pReceiver = iterator.next(); } if( !bInMenuWindowList ) { param.wParam = 1; param.lParam = NULL; s_context_menu_observer.RBroadcast(param); return 0; } } else if( uMsg == WM_KEYDOWN) { if( wParam == VK_ESCAPE) { Close(); } } LRESULT lRes = 0; if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }
void Notify(TNotifyUI& msg) { if( msg.sType == _T("windowinit") ) OnPrepare(msg); else if( msg.sType == _T("click") ) { if( msg.pSender == m_pCloseBtn ) { PostQuitMessage(0); return; } else if( msg.pSender == m_pMinBtn ) { SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); return; } else if( msg.pSender == m_pMaxBtn ) { SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; } else if( msg.pSender == m_pRestoreBtn ) { SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; } else if(msg.pSender == m_pSearch) { OnSearch(); } } else if(msg.sType==_T("setfocus")) { } else if( msg.sType == _T("itemclick") ) { } else if( msg.sType == _T("itemactivate") ) { int iIndex = msg.pSender->GetTag(); CStdString sMessage = _T("Click: ");; #ifdef _UNICODE int iLen = domain[iIndex].length(); LPWSTR lpText = new WCHAR[iLen + 1]; ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); ::MultiByteToWideChar(CP_ACP, 0, domain[iIndex].c_str(), -1, (LPWSTR)lpText, iLen) ; sMessage += lpText; delete[] lpText; #else sMessage += domain[iIndex].c_str(); #endif ::MessageBox(NULL, sMessage.GetData(), _T("提示(by tojen)"), MB_OK); } else if(msg.sType == _T("menu")) { if( msg.pSender->GetName() != _T("domainlist") ) return; CMenuWnd* pMenu = new CMenuWnd(); if( pMenu == NULL ) { return; } POINT pt = {msg.ptMouse.x, msg.ptMouse.y}; ::ClientToScreen(*this, &pt); pMenu->Init(msg.pSender, pt); } else if( msg.sType == _T("menu_Delete") ) { CListUI* pList = static_cast<CListUI*>(msg.pSender); int nSel = pList->GetCurSel(); if( nSel < 0 ) return; pList->RemoveAt(nSel); domain.erase(domain.begin() + nSel); desc.erase(desc.begin() + nSel); } }
void CMenuWnd::ResizeSubMenu() { // Position the popup window in absolute space RECT rcOwner = m_pOwner->GetPos(); RECT rc = rcOwner; int cxFixed = 0; int cyFixed = 0; #if defined(WIN32) && !defined(UNDER_CE) MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); CDuiRect rcWork = oMonitor.rcWork; #else CDuiRect rcWork; GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWork); #endif SIZE szAvailable = { rcWork.right - rcWork.left, rcWork.bottom - rcWork.top }; for( int it = 0; it < m_pOwner->GetCount(); it++ ) { if(m_pOwner->GetItemAt(it)->GetInterface(_T("MenuElement")) != NULL ){ CControlUI* pControl = static_cast<CControlUI*>(m_pOwner->GetItemAt(it)); SIZE sz = pControl->EstimateSize(szAvailable); cyFixed += sz.cy; if( cxFixed < sz.cx ) cxFixed = sz.cx; } } RECT rcWindow; GetWindowRect(m_pOwner->GetManager()->GetPaintWindow(), &rcWindow); rc.top = rcOwner.top; rc.bottom = rc.top + cyFixed; ::MapWindowRect(m_pOwner->GetManager()->GetPaintWindow(), HWND_DESKTOP, &rc); rc.left = rcWindow.right; rc.right = rc.left + cxFixed; rc.right += 2; bool bReachBottom = false; bool bReachRight = false; LONG chRightAlgin = 0; LONG chBottomAlgin = 0; RECT rcPreWindow = {0}; MenuObserverImpl::Iterator iterator(CMenuWnd::GetGlobalContextMenuObserver()); MenuMenuReceiverImplBase* pReceiver = iterator.next(); while( pReceiver != NULL ) { CMenuWnd* pContextMenu = dynamic_cast<CMenuWnd*>(pReceiver); if( pContextMenu != NULL ) { GetWindowRect(pContextMenu->GetHWND(), &rcPreWindow); bReachRight = rcPreWindow.left >= rcWindow.right; bReachBottom = rcPreWindow.top >= rcWindow.bottom; if( pContextMenu->GetHWND() == m_pOwner->GetManager()->GetPaintWindow() || bReachBottom || bReachRight ) break; } pReceiver = iterator.next(); } if (bReachBottom) { rc.bottom = rcWindow.top; rc.top = rc.bottom - cyFixed; } if (bReachRight) { rc.right = rcWindow.left; rc.left = rc.right - cxFixed; } if( rc.bottom > rcWork.bottom ) { rc.bottom = rc.top; rc.top = rc.bottom - cyFixed; } if (rc.right > rcWork.right) { rc.right = rcWindow.left; rc.left = rc.right - cxFixed; } if( rc.top < rcWork.top ) { rc.top = rcOwner.top; rc.bottom = rc.top + cyFixed; } if (rc.left < rcWork.left) { rc.left = rcWindow.right; rc.right = rc.left + cxFixed; } MoveWindow(m_hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top + m_pLayout->GetInset().top + m_pLayout->GetInset().bottom, FALSE); }
void MainForm::PopupMainMenu(POINT point) { //创建菜单窗口 CMenuWnd* pMenu = new CMenuWnd(NULL); STRINGorID xml(L"main_menu.xml"); pMenu->Init(xml, _T("xml"), point); //注册回调 CMenuElementUI* look_log = (CMenuElementUI*)pMenu->FindControl(L"look_log"); look_log->AttachSelect(nbase::Bind(&MainForm::LookLogMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* file_trans = (CMenuElementUI*)pMenu->FindControl(L"file_helper"); file_trans->AttachSelect(nbase::Bind(&MainForm::FileTransMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* address = (CMenuElementUI*)pMenu->FindControl(L"address"); address->AttachSelect(nbase::Bind(&MainForm::AddressMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* export_msglog = (CMenuElementUI*)pMenu->FindControl(L"export_msglog"); export_msglog->AttachSelect(nbase::Bind(&MainForm::ExportMsglogMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* import_msglog = (CMenuElementUI*)pMenu->FindControl(L"import_msglog"); import_msglog->AttachSelect(nbase::Bind(&MainForm::ImportMsglogMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* clear_chat_record = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record"); clear_chat_record->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordMenuItemClick, this, true, std::placeholders::_1)); CMenuElementUI* clear_chat_record_ex = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record_ex"); clear_chat_record_ex->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordMenuItemClick, this, false, std::placeholders::_1)); CMenuElementUI* clear_chat_record_p2p = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record_p2p"); clear_chat_record_p2p->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordBySessionTypeMenuItemClick, this, true, nim::kNIMSessionTypeP2P, std::placeholders::_1)); CMenuElementUI* clear_chat_record_p2p_ex = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record_p2p_ex"); clear_chat_record_p2p_ex->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordBySessionTypeMenuItemClick, this, false, nim::kNIMSessionTypeP2P, std::placeholders::_1)); CMenuElementUI* clear_chat_record_team = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record_team"); clear_chat_record_team->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordBySessionTypeMenuItemClick, this, true, nim::kNIMSessionTypeTeam, std::placeholders::_1)); CMenuElementUI* clear_chat_record_team_ex = (CMenuElementUI*)pMenu->FindControl(L"clear_chat_record_team_ex"); clear_chat_record_team_ex->AttachSelect(nbase::Bind(&MainForm::ClearChatRecordBySessionTypeMenuItemClick, this, false, nim::kNIMSessionTypeTeam, std::placeholders::_1)); CMenuElementUI* vchat_setting = (CMenuElementUI*)pMenu->FindControl(L"vchat_setting"); vchat_setting->AttachSelect(nbase::Bind(&MainForm::VChatSettingMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* rts_replay = (CMenuElementUI*)pMenu->FindControl(L"rts_replay"); rts_replay->AttachSelect(nbase::Bind(&MainForm::RtsReplayMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* about = (CMenuElementUI*)pMenu->FindControl(L"about"); about->AttachSelect(nbase::Bind(&MainForm::AboutMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* logoff = (CMenuElementUI*)pMenu->FindControl(L"logoff"); logoff->AttachSelect(nbase::Bind(&MainForm::LogoffMenuItemClick, this, std::placeholders::_1)); CMenuElementUI* quit = (CMenuElementUI*)pMenu->FindControl(L"quit"); quit->AttachSelect(nbase::Bind(&MainForm::QuitMenuItemClick, this, std::placeholders::_1)); //显示 pMenu->Show(); }
void CDuiFrameWnd::OnClick( TNotifyUI& msg ) { if( msg.pSender->GetName() == _T("btnPlaylistShow") ) { ShowPlaylist(true); } else if( msg.pSender->GetName() == _T("btnPlaylistHide") ) { ShowPlaylist(false); } else if( msg.pSender->GetName() == _T("btnFastBackward") ) { m_cAVPlayer.SeekBackward(); ::PostMessage(*this, WM_USER_POS_CHANGED, 0, m_cAVPlayer.GetPos()); } else if( msg.pSender->GetName() == _T("btnFastForward") ) { m_cAVPlayer.SeekForward(); ::PostMessage(*this, WM_USER_POS_CHANGED, 0, m_cAVPlayer.GetPos()); } else if( msg.pSender->GetName() == _T("btnPrevious") ) { Play(GetNextPath(false)); } else if( msg.pSender->GetName() == _T("btnNext") ) { Play(GetNextPath(true)); } else if( msg.pSender->GetName() == _T("btnPlay") ) { Play(true); } else if( msg.pSender->GetName() == _T("btnPause") ) { Play(false); } else if( msg.pSender->GetName() == _T("btnStop") ) { Stop(); } else if( msg.pSender->GetName() == _T("btnOpen") || msg.pSender->GetName() == _T("btnOpenMini") ) { OpenFileDialog(); } else if( msg.pSender->GetName() == _T("btnRefresh") ) { CEditUI* pUI = static_cast<CEditUI*>(m_PaintManager.FindControl(_T("editURL"))); Play(pUI->GetText()); } else if( msg.pSender->GetName() == _T("btnScreenFull") ) { FullScreen(true); } else if( msg.pSender->GetName() == _T("btnScreenNormal") ) { FullScreen(false); } else if( msg.pSender->GetName() == _T("btnVolume") ) { m_cAVPlayer.Volume(0); m_PaintManager.FindControl(_T("btnVolumeZero"))->SetVisible(true); msg.pSender->SetVisible(false); } else if( msg.pSender->GetName() == _T("btnVolumeZero") ) { CSliderUI* pUI = static_cast<CSliderUI*>(m_PaintManager.FindControl(_T("sliderVol"))); m_cAVPlayer.Volume(pUI->GetValue()); m_PaintManager.FindControl(_T("btnVolume"))->SetVisible(true); msg.pSender->SetVisible(false); } else if( msg.pSender->GetName() == _T("btnPlayMode") ) { CMenuWnd *pMenu = new CMenuWnd(_T("menu.xml")); POINT pt = {msg.ptMouse.x, msg.ptMouse.y}; CDuiRect rc = msg.pSender->GetPos(); pt.x = rc.left; pt.y = rc.bottom; pMenu->Init(&m_PaintManager, pt); pMenu->ShowWindow(TRUE); } else if (msg.pSender->GetName() == _T("btnAdd")) { OpenFileDialog(); } else if (msg.pSender->GetName() == _T("btnDelete")) { DeleteFileItem(); } else if (msg.pSender->GetTag() == U_TAG_PLAYLIST) { CDuiString strPath = msg.pSender->GetName(); Play(strPath.GetData()); } __super::OnClick(msg); }
LRESULT CMainWindow::OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; CControlUI * pControl = this->paint_manager_.FindControl(pt); if (pControl != NULL) { if (pControl == m_pRecvEdit) { m_ptRBtnDown = pt; CMenuWnd* pMenu = new CMenuWnd(m_hWnd); ::ClientToScreen(m_hWnd, &pt); pMenu->Init(NULL, _T("RecvEditMenu.xml"), _T("xml"), pt, pControl); BOOL bSel = (m_pRecvEdit->GetSelectionType() != SEL_EMPTY); pMenu->EnableMenuItem(_T("Menu_Copy"), bSel); pMenu->CheckMenuItem(m_strCheckMenu.c_str(), TRUE); ITextServices * pTextServices = m_pRecvEdit->GetTextServices(); IImageOle * pImageOle = NULL; BOOL bRet = RichEdit_GetImageOle(pTextServices, m_ptRBtnDown, &pImageOle); BOOL bSaveAs = (bRet && pImageOle != NULL); pMenu->EnableMenuItem(_T("Menu_SaveAs"), bSaveAs); if (pImageOle != NULL) pImageOle->Release(); pTextServices->Release(); } else if (pControl == m_pSendEdit) { m_ptRBtnDown = pt; CMenuWnd* pMenu = new CMenuWnd(m_hWnd); ::ClientToScreen(m_hWnd, &pt); pMenu->Init(NULL, _T("SendEditMenu.xml"), _T("xml"), pt, pControl); BOOL bSel = (m_pSendEdit->GetSelectionType() != SEL_EMPTY); pMenu->EnableMenuItem(_T("Menu_Cut"), bSel); pMenu->EnableMenuItem(_T("Menu_Copy"), bSel); BOOL bPaste = m_pSendEdit->CanPaste(); pMenu->EnableMenuItem(_T("Menu_Paste"), bPaste); ITextServices * pTextServices = m_pSendEdit->GetTextServices(); IImageOle * pImageOle = NULL; BOOL bRet = RichEdit_GetImageOle(pTextServices, m_ptRBtnDown, &pImageOle); BOOL bSaveAs = (bRet && pImageOle != NULL); pMenu->EnableMenuItem(_T("Menu_SaveAs"), bSaveAs); if (pImageOle != NULL) pImageOle->Release(); pTextServices->Release(); } } return 0; }
void MainFrame::OnClick(TNotifyUI& msg) { WindowImplBase::OnClick(msg); if (_tcsicmp(msg.pSender->GetName(), kHideLeftMainPannelControlName) == 0) { CControlUI* left_main_pannel = m_PaintManager.FindControl(kLeftMainPannelControlName); CControlUI* hide_left_main_pannel = m_PaintManager.FindControl(kHideLeftMainPannelControlName); CControlUI* show_left_main_pannel = m_PaintManager.FindControl(kShowLeftMainPannelControlName); if ((left_main_pannel != NULL) && (show_left_main_pannel != NULL) && (hide_left_main_pannel != NULL)) { hide_left_main_pannel->SetVisible(false); left_main_pannel->SetVisible(false); show_left_main_pannel->SetVisible(true); } } else if (_tcsicmp(msg.pSender->GetName(), kShowLeftMainPannelControlName) == 0) { CControlUI* left_main_pannel = m_PaintManager.FindControl(kLeftMainPannelControlName); CControlUI* hide_left_main_pannel = m_PaintManager.FindControl(kHideLeftMainPannelControlName); CControlUI* show_left_main_pannel = m_PaintManager.FindControl(kShowLeftMainPannelControlName); if ((left_main_pannel != NULL) && (show_left_main_pannel != NULL) && (hide_left_main_pannel != NULL)) { hide_left_main_pannel->SetVisible(true); left_main_pannel->SetVisible(true); show_left_main_pannel->SetVisible(false); } } else if (_tcsicmp(msg.pSender->GetName(), kSignatureTipsControlName) == 0) { msg.pSender->SetVisible(false); CEditUI* signature = static_cast<CEditUI*>(m_PaintManager.FindControl(kSignatureControlName)); if (signature != NULL) { signature->SetText(msg.pSender->GetText()); signature->SetVisible(true); } } else if (_tcsicmp(msg.pSender->GetName(), kSearchEditTipControlName) == 0) { msg.pSender->SetVisible(false); CEditUI* search_edit = static_cast<CEditUI*>(m_PaintManager.FindControl(kSearchEditControlName)); if (search_edit != NULL) { search_edit->SetText(msg.pSender->GetText()); search_edit->SetVisible(true); } } else if (_tcsicmp(msg.pSender->GetName(), kChangeBkSkinControlName) == 0) { CControlUI* background = m_PaintManager.FindControl(kBackgroundControlName); if (background != NULL) { TCHAR szBuf[MAX_PATH] = { 0 }; ++bk_image_index_; if (kBackgroundSkinImageCount < bk_image_index_) bk_image_index_ = 0; _stprintf_s(szBuf, MAX_PATH - 1, _T("file='bg%d.png' corner='600,200,1,1'"), bk_image_index_); background->SetBkImage(szBuf); SkinChangedParam param; CControlUI* background = m_PaintManager.FindControl(kBackgroundControlName); if (background != NULL) { param.bkcolor = background->GetBkColor(); if (_tcslen(background->GetBkImage()) > 0) { _stprintf_s(szBuf, MAX_PATH - 1, _T("bg%d.png"), bk_image_index_); } param.bgimage = szBuf; } skin_changed_observer_.Broadcast(param); } } else if (_tcsicmp(msg.pSender->GetName(), kChangeColorSkinControlName) == 0) { CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); rcWindow.top = rcWindow.top + msg.pSender->GetPos().bottom; new ColorSkinWindow(this, rcWindow); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("phone"))) { logic::GetLogic()->asynNotifyObserver(module::KEY_LOGIN_USERID,10); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("QQpalycenter"))) { logic::GetLogic()->removeObserver(this); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("MainMenu"))) { CMenuWnd* pMenu = new CMenuWnd(m_hWnd); DuiLib::CPoint point = msg.ptMouse; ClientToScreen(m_hWnd, &point); STRINGorID xml(_T("menutest.xml")); pMenu->Init(NULL, xml, _T("xml"), point); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("ToolsBtn")))//设置按钮 { MakeGroupWnd* pFrame = new MakeGroupWnd(); if (pFrame == NULL) return; pFrame->Create(NULL, _T("MakeGroupWnd"), UI_WNDSTYLE_FRAME, WS_EX_STATICEDGE | WS_EX_APPWINDOW, 0, 0, 600, 800); pFrame->CenterWindow(); pFrame->ShowWindow(true); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("QQSafeBtn")))//安全中心 { } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("messageCenterBtn")))//消息中心 { FloatWnd* pFloatWnd = new FloatWnd(); if (pFloatWnd == NULL) return; pFloatWnd->Create(m_hWnd, _T("FloatWnd"), UI_WNDSTYLE_FRAME|WS_THICKFRAME, WS_EX_TOOLWINDOW | WS_EX_TOPMOST| WS_EX_STATICEDGE, 0, 0, 0, 0); //pFloatWnd->ShowWindow(true); pFloatWnd->BringToTop(); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("QzoneBtn"))) { } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("QQTradeCenterBtn"))) { int n = 0; n++; } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("paipaiBtn"))) { int n = 0; n++; } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("PaiPaiChongzhiBtn"))) { int n = 0; n++; } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("addBtn"))) { int n = 0; n++; } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("friend_circleBtn"))) { LoginWnd* pLoginWnd = new LoginWnd(); if (pLoginWnd == NULL) return; pLoginWnd->Create(NULL, _T("LoginWnd"), /*WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS*/UI_WNDSTYLE_FRAME | WS_POPUP, 0/*WS_EX_LAYERED*/, 0, 0, 0, 0); pLoginWnd->CenterWindow(); pLoginWnd->ShowWindow(true); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("mailBtn"))) { MainDialog* pMainDialog = new MainDialog(); if (pMainDialog == NULL) return; pMainDialog->Create(NULL, _T("MainDialog"), UI_WNDSTYLE_FRAME | WS_POPUP, 0, 0, 0, 0, 0); pMainDialog->CenterWindow(); pMainDialog->ShowWindow(true); } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("XiaoYouBtn"))) { int n = 0; n++; } else if (0 == _tcsicmp(msg.pSender->GetName(), _T("sosoBtn"))) { int n = 0; n++; } }