bool CMyList::OnTheEvent (void* pParam) { TEventUI* pEvent = (TEventUI*)pParam; CContainerUI* pContainer = NULL; if (pEvent->pSender == NULL) { return true; } if (_tcsicmp (pEvent->pSender->GetClass(), _T ("ContainerUI")) != 0) { pContainer = static_cast <CContainerUI*> (pEvent->pSender->GetParent()); } else { pContainer = static_cast <CContainerUI*> (pEvent->pSender); } if (pContainer == NULL) { return true; } if (pEvent->Type == UIEVENT_MOUSEENTER) { if (pContainer->GetBkColor() != 0x1100FF00) pContainer->SetBkColor(0x1100FF00); } else if (pEvent->Type == UIEVENT_MOUSELEAVE) { if (pContainer->GetBkColor() != 0xFFFFFFFF) pContainer->SetBkColor(0xFFFFFFFF); } return true; }
//初始化道具栏 void CRightFrame::InitProp() { CContainerUI* pPropMainCtn = static_cast<CContainerUI*>(m_pm.FindControl("Prop_Ctn_Main")); if (!pPropMainCtn) { return; } RECT rc = {0,20,1,0}; char szBuf[32] = {0}; for (int i = 0; i < MAX_PROP_NUMS; ++i) { m_pPropBtn[i] = new CButtonUI(); _stprintf(szBuf,"Prop_Btn_%d",i); m_pPropBtn[i]->SetName(szBuf); m_pPropBtn[i]->SetText(""); m_pPropBtn[i]->SetTextColor(0xFFFFFFFF); m_pPropBtn[i]->SetAttribute("align","right"); m_pPropBtn[i]->SetTextPadding(rc); m_pPropBtn[i]->SetFixedHeight(34); m_pPropBtn[i]->SetFixedWidth(34); m_pPropBtn[i]->SetFloat(true); m_pPropBtn[i]->SetTag(0); pPropMainCtn->Add(m_pPropBtn[i]); } return; }
// BOOL ViCbAddCtrl(HANDLE hCtrl, HANDLE hParent) SQInteger ViCbAddCtrl(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger hCtrl = 0; SQInteger hParent = 0; CContainerUI* pParentCtrl = NULL; CScriptMgr* pMgr = NULL; CPaintManagerUI* pPM = NULL; CControlUI* pCtrl = NULL; SQBool bRet = FALSE; if (!v || 2 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 3)) {goto _Exit_;} sq_getinteger(v, 2, &hCtrl); sq_getinteger(v, 3, &hParent); pCtrl = QiHwHandleToCtrl(hCtrl); pParentCtrl = (CContainerUI*)QiHwHandleToCtrl(hParent); if (!pCtrl) {goto _Exit_;} if (NULL == pParentCtrl) { pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} pParentCtrl = (CContainerUI*)pPM->GetRoot(); } if (!pParentCtrl || !pParentCtrl->IsContainer()) {goto _Exit_;} bRet = (SQBool)pParentCtrl->Add(pCtrl); _Exit_: sq_pushbool(v, bRet); return 1; }
CTreeTab::CTreeTab(CPaintManagerUI* ppm) { CDialogBuilder builder; CDialogBuilderCallbackEx cb (ppm); CContainerUI* pbtnTab = static_cast<CContainerUI*>(builder.Create(_T("tree.xml"), 0, &cb, ppm)); if( pbtnTab ) { this->Add(pbtnTab); } else { this->RemoveAll(); return; } CDuiTreeView* pTree1 = static_cast<CDuiTreeView*>(pbtnTab->FindSubControl(_T("Tree1"))); pTree1->OnNotify += MakeDelegate(this,&CTreeTab::OnFolderChanged); if (pTree1) { pTree1->SetDepth(4); pTree1->SetExpandImage(_T("tree_expand.png")); CDuiTreeView::Node* pCategoryNode = NULL; CDuiTreeView::Node* pGameNode = NULL; CDuiTreeView::Node* pServerNode = NULL; CDuiTreeView::Node* pRoomNode = NULL; pCategoryNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}ÍƼöÓÎÏ·")); for (int i = 0; i < 4; ++i) { pGameNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}ËÄÈ˶·µØÖ÷"), pCategoryNode); for (int i = 0; i < 3; ++i) { pServerNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}²âÊÔ·þÎñÆ÷"), pGameNode); for (int i = 0; i < 3; ++i) { pRoomNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}²âÊÔ·¿¼ä"), pServerNode); } } } pCategoryNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}×î½üÍæ¹ýµÄÓÎÏ·")); for (int i = 0; i < 2; ++i) { pTree1->AddNode(_T("Èýȱһ"), pCategoryNode); } pCategoryNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}ÆåÅÆÓÎÏ·")); for (int i = 0; i < 8; ++i) { pTree1->AddNode(_T("Ë«¿Û"), pCategoryNode); } pCategoryNode = pTree1->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}ÐÝÏÐÓÎÏ·")); for (int i = 0; i < 8; ++i) { pTree1->AddNode(_T("·ÉÐÐÆå"), pCategoryNode); } } }
bool CFriendsUI::SelectItem(int iIndex, bool bTakeFocus) { if( iIndex == m_iCurSel ) return true; // We should first unselect the currently selected item if( m_iCurSel >= 0 ) { CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { pFriendListItem->SetFixedHeight(kFriendListItemNormalHeight); CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); if (pOperatorPannel != NULL) { pOperatorPannel->SetVisible(false); } } pListItem->Select(false); } } m_iCurSel = -1; } if( iIndex < 0 ) return false; if (!__super::SelectItem(iIndex, bTakeFocus)) return false; CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { pFriendListItem->SetFixedHeight(kFriendListItemSelectedHeight); CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); if (pOperatorPannel != NULL) { pOperatorPannel->SetVisible(true); } } } return true; }
void CUIDesignerView::RedoUI(CControlUI* pControl, CControlUI* pParent) { ASSERT(pControl && pParent); if(!pControl || !pParent) return; CContainerUI* pContainer = static_cast<CContainerUI*>(pParent->GetInterface(_T("Container"))); ExtendedAttributes* pExtended = (ExtendedAttributes*)pContainer->GetTag(); pContainer->Add(pControl); m_MultiTracker.Add(CreateTracker(pControl)); InitUI(pControl, pExtended->nDepth + 1, TRUE); pContainer->SetPos(pContainer->GetPos()); }
void CBookClient::InEdit() { m_bEdit = !m_bEdit; int num = this->GetCount(); CContainerUI* pCtrl = NULL; for (int i = 0; i < num; ++i) { pCtrl = static_cast<CContainerUI*>(this->GetItemAt(i)); pCtrl = static_cast<CContainerUI*>(pCtrl->FindSubControl(_T("btnbookdel"))); ASSERT(pCtrl != NULL); pCtrl->SetVisible(m_bEdit); } }
bool CBookClient::AddNode(BOOK_INFO *item) { if (item == NULL) return false; BOOK_INFO *node = new BOOK_INFO; node->strName = item->strName; node->nImage = item->nImage; node->strPath = item->strPath; node->nBookmark = item->nBookmark; CContainerUI* pDesk = NULL; if( !m_dlgBuilder.GetMarkup()->IsValid() ) { pDesk = static_cast<CContainerUI*>(m_dlgBuilder.Create(_T("iBook.xml"), (UINT)0, NULL, &m_pm)); } else { pDesk = static_cast<CContainerUI*>(m_dlgBuilder.Create((UINT)0, &m_pm)); } if( pDesk != NULL ) { this->Add(pDesk); CButtonUI* btn = static_cast<CButtonUI*>(m_pm.FindSubControlByName(pDesk, _T("btnBookEx"))); CLabelUI *text = static_cast<CLabelUI*>(m_pm.FindSubControlByName(pDesk, _T("labelBookEx"))); CButtonUI *btnEdit = static_cast<CButtonUI*>(m_pm.FindSubControlByName(pDesk, _T("btnbookdel"))); if (btn == NULL || text == NULL || btnEdit == NULL) return false; CDuiString strImage; strImage.Format(_T("book\\%02d.png"), node->nImage); btn->SetBkImage(strImage); text->SetText(node->strName); btnEdit->SetVisible(m_bEdit); pDesk->SetTag((UINT_PTR)node); } else { delete node; node = NULL; return false; } return true; }
bool CMainDialog::OnClickItem (void* pParam) { TEventUI* pEvent = (TEventUI*)pParam; if (pEvent->Type == UIEVENT_BUTTONDOWN) { CComboUI* pcbx = static_cast <CComboUI*> (m_pm.FindControl(_T ("combo2"))); CEditUI* pedit = static_cast <CEditUI*> (m_pm.FindControl(_T ("ComboEdit"))); assert (pedit); CContainerUI* pItem = static_cast <CContainerUI*> (pcbx->GetItemAt (pEvent->pSender->GetTag())); pedit->SetText(pItem->GetItemAt(2)->GetText()); } else if (pEvent->Type == UIEVENT_MOUSEENTER) { pEvent->pSender->SetBkColor(0xFF00FF00); } else if (pEvent->Type == UIEVENT_MOUSELEAVE) { pEvent->pSender->SetBkColor(0xFFFFFFFF); } return true; }
//************************************ // 函数名称: Invalidate // 返回类型: void // 函数说明: //************************************ void CTreeNodeUI::Invalidate() { if( !IsVisible() ) return; if( GetParent() ) { CContainerUI* pParentContainer = static_cast<CContainerUI*>(GetParent()->GetInterface(_T("Container"))); if( pParentContainer ) { RECT rc = pParentContainer->GetPos(); RECT rcInset = pParentContainer->GetInset(); rc.left += rcInset.left; rc.top += rcInset.top; rc.right -= rcInset.right; rc.bottom -= rcInset.bottom; CScrollBarUI* pVerticalScrollBar = pParentContainer->GetVerticalScrollBar(); if( pVerticalScrollBar && pVerticalScrollBar->IsVisible() ) rc.right -= pVerticalScrollBar->GetFixedWidth(); CScrollBarUI* pHorizontalScrollBar = pParentContainer->GetHorizontalScrollBar(); if( pHorizontalScrollBar && pHorizontalScrollBar->IsVisible() ) rc.bottom -= pHorizontalScrollBar->GetFixedHeight(); RECT invalidateRc = m_rcItem; if( !::IntersectRect(&invalidateRc, &m_rcItem, &rc) ) return; CControlUI* pParent = GetParent(); RECT rcTemp; RECT rcParent; while( pParent = pParent->GetParent() ) { rcTemp = invalidateRc; rcParent = pParent->GetPos(); if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) return; } if( m_pManager != NULL ) m_pManager->Invalidate(invalidateRc); } else { CContainerUI::Invalidate(); } } else { CContainerUI::Invalidate(); } }
void MainFrame::EnumInstalledDriver() { // 清空界面中list中显示的打印机列表 CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); if (pDriverList != NULL) pDriverList->RemoveAll(); // 枚举本地计算机上所有安装的打印机驱动(实际使用时可以只枚举自家的打印机驱动) LPBYTE lpBuffer = NULL; DWORD dwNeeded = 0,dwReturned = 0; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 1, NULL, 0, &dwNeeded, &dwReturned); if (dwNeeded == 0) return; lpBuffer = (LPBYTE)malloc(dwNeeded); if (lpBuffer == NULL) return; EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 1, lpBuffer, dwNeeded, &dwNeeded, &dwReturned); for (DWORD dwIndex = 0; (dwIndex < dwReturned) && (pDriverList != NULL); dwIndex++) { COptionUI* pDriver = new COptionUI(); if (pDriver != NULL) { pDriver->ApplyAttributeList(_T("padding=\"15,0,0,0\" height=\"35\" textpadding=\"20,0,0,0\" align=\"left\" normalimage=\"res='124' restype='png' dest='0,10,15,25'\" hotimage=\"res='125' restype='png' dest='0,10,15,25'\" selectedimage=\"res='126' restype='png' dest='0,10,15,25'\"")); pDriver->SetText(((PRINTER_INFO_1*)lpBuffer + dwIndex)->pName); pDriverList->Add(pDriver); } } LPTSTR lpDefaultPrinter; GetDefaultPrinter(NULL, &dwNeeded); lpDefaultPrinter = (LPTSTR)malloc(dwNeeded * sizeof(TCHAR)); GetDefaultPrinter((LPTSTR)lpDefaultPrinter, &dwNeeded); free(lpDefaultPrinter); free(lpBuffer); }
void ChatDialog::OnPrepare(TNotifyUI& msg) { TCHAR szBuf[MAX_PATH] = {0}; CControlUI* background = paint_manager_.FindControl(kBackgroundControlName); if (background != NULL) { #if defined(UNDER_WINCE) _stprintf(szBuf, _T("file='%s' corner='600,200,1,1'"), bgimage_.c_str()); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("file='%s' corner='600,200,1,1'"), bgimage_.c_str()); #endif background->SetBkImage(szBuf); background->SetBkColor(bkcolor_); } CButtonUI* log_button = static_cast<CButtonUI*>(paint_manager_.FindControl(kLogoButtonControlName)); if (log_button != NULL) { #if defined(UNDER_WINCE) _stprintf(szBuf, _T("%s"), friend_.logo.c_str()); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("%s"), friend_.logo.c_str()); #endif log_button->SetNormalImage(szBuf); } CControlUI* nick_name = paint_manager_.FindControl(kNickNameControlName); if (nick_name != NULL) nick_name->SetText(friend_.nick_name.c_str()); CControlUI* desciption = paint_manager_.FindControl(kDescriptionControlName); if (desciption != NULL) desciption->SetText(friend_.description.c_str()); CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); }
void CMyList::Init(CPaintManagerUI* ppm) { CDialogBuilder builder; CContainerUI* pList = static_cast<CContainerUI*>(builder.Create(_T("mylist.xml"), 0, NULL, ppm)); if( pList != NULL ) { for(int i = 0; i < 100; ++i) { if( pList == NULL ) pList = static_cast<CContainerUI*>(builder.Create()); if( pList != NULL ) { this->Add(pList); TCHAR indexBuffer[16]; CDuiString strIndexString = _T("- "); strIndexString += _itot(i+1, indexBuffer, 10); strIndexString += _T(" -"); pList->GetItemAt(0)->SetText(strIndexString); CComboUI* pCombo = static_cast <CComboUI*> (pList->GetItemAt(1)); if (pCombo != NULL) { for (int j = 0; j < 3; ++j) { CListLabelElementUI* pComboItem = new CListLabelElementUI; pComboItem->SetText("xxx"); pCombo->Add(pComboItem); } } pList->GetItemAt(0)->OnEvent += MakeDelegate (this, &CMyList::OnTheEvent); pList->GetItemAt(1)->OnEvent += MakeDelegate (this, &CMyList::OnTheEvent); pList->GetItemAt(2)->OnEvent += MakeDelegate (this, &CMyList::OnTheEvent); pList->OnEvent += MakeDelegate (this, &CMyList::OnTheEvent); pList = NULL; } else { this->RemoveAll(); return; } } } }
void CUIDesignerView::PasteUI(LPCTSTR xml) { CDialogBuilder builder; CControlUI* pRoot=builder.Create(xml, (UINT)0, NULL, m_LayoutManager.GetManager()); if(pRoot) { CControlUI* pParent = m_MultiTracker.GetFocused(); if(pParent->GetInterface(_T("Container")) == NULL) pParent = pParent->GetParent(); if(pParent == NULL) pParent = m_LayoutManager.GetForm(); m_MultiTracker.RemoveAll(); CContainerUI* pContainer = static_cast<CContainerUI*>(pParent->GetInterface(_T("Container"))); CContainerUI* pRootContainer = static_cast<CContainerUI*>(pRoot->GetInterface(_T("Container"))); ExtendedAttributes* pExtended = (ExtendedAttributes*)pContainer->GetTag(); for(int i=0; i<pRootContainer->GetCount(); i++) { CControlUI* pControl = pRootContainer->GetItemAt(i); if(pControl->IsFloat()) { SIZE sz = pControl->GetFixedXY(); sz.cx += COPY_OFFSET_XY; sz.cy += COPY_OFFSET_XY; pControl->SetFixedXY(sz); } pContainer->Add(pControl); m_MultiTracker.Add(CreateTracker(pControl)); InitUI(pControl, pExtended->nDepth + 1); } CArray<CControlUI*,CControlUI*> arrSelected; m_MultiTracker.GetSelected(arrSelected); m_UICommandHistory.Begin(arrSelected, actionAdd); m_UICommandHistory.End(); pContainer->SetPos(pContainer->GetPos()); pRootContainer->SetAutoDestroy(false); delete pRootContainer; this->GetDocument()->SetModifiedFlag(); } }
void CMainDialog::AddComboboxItem() { CComboUI* pcbx2 = static_cast <CComboUI*> (m_pm.FindControl(_T("combo2"))); assert (pcbx2); if (pcbx2) { CDialogBuilder builder; CContainerUI* pItem = static_cast <CContainerUI*> (builder.Create(_T("comboitem.xml"), 0)); pItem->GetItemAt(0)->SetBkImage(_T ("icon_home.png")); if (pcbx2->GetCount() % 2 == 0) { pItem->GetItemAt(1)->SetText(_T ("百度一下,你就知道了")); pItem->GetItemAt(2)->SetText(_T ("http://www.baidu.com")); } else { pItem->GetItemAt(1)->SetText(_T ("360搜索 - 干净、安全、可信任的搜索引擎")); pItem->GetItemAt(2)->SetText(_T ("http://www.so.com/")); } pItem->SetTag(pcbx2->GetCount()); pItem->OnEvent += MakeDelegate (this, &CMainDialog::OnClickItem); pcbx2->Add(pItem); } }
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 || _tcsicmp(msg.pSender->GetName(), kCancelButtonControlName) == 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("select_all_btn")) == 0) { CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); for (int i = 0; (pDriverList != NULL) && (i < pDriverList->GetCount()); ++i) { COptionUI* pDriver = static_cast<COptionUI*>(pDriverList->GetItemAt(i)->GetInterface(_T("Option"))); if (pDriver != NULL) pDriver->Selected(true); } } else if (_tcsicmp(msg.pSender->GetName(), _T("uninstall_btn")) == 0) { vector<tString> deleted_printer_driver; DWORD dwError = 0; TCHAR szBuf[MAX_PATH] = {0}; CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); for (int i = 0; (pDriverList != NULL) && (i < pDriverList->GetCount()); ++i) { COptionUI* pDriver = static_cast<COptionUI*>(pDriverList->GetItemAt(i)->GetInterface(_T("Option"))); if ((pDriver != NULL) && pDriver->IsSelected()) { // 涉及到的API: DeletePrinter DeletePrinterDriver HANDLE hPrinter = NULL; _stprintf_s(szBuf, MAX_PATH - 1, pDriver->GetText().GetData()); PRINTER_DEFAULTS PrtDefault = {NULL, NULL, PRINTER_ALL_ACCESS}; OpenPrinter(szBuf, &hPrinter, &PrtDefault); if (hPrinter != NULL) { DWORD dwNeeded = 0; GetPrinter(hPrinter, 2, NULL, 0, &dwNeeded); LPBYTE lpBuffer = (LPBYTE)malloc(dwNeeded); if (lpBuffer != NULL) { GetPrinter(hPrinter, 2, lpBuffer, dwNeeded, &dwNeeded); DeletePrinter(hPrinter); dwError = GetLastError(); vector<tString>::const_iterator citer = find(deleted_printer_driver.begin(), deleted_printer_driver.end(), ((PRINTER_INFO_2*)lpBuffer)->pDriverName); if (citer == deleted_printer_driver.end()) { deleted_printer_driver.push_back(((PRINTER_INFO_2*)lpBuffer)->pDriverName); } ClosePrinter(hPrinter); free(lpBuffer); } } } } for (vector<tString>::const_iterator citer = deleted_printer_driver.begin(); citer != deleted_printer_driver.end(); ++citer) { _stprintf_s(szBuf, MAX_PATH - 1, citer->c_str()); DeletePrinterDriver(NULL, NULL, szBuf); dwError = GetLastError(); } RestartSpoolsv(); EnumInstalledDriver(); if (IDYES == DUIMessageBox(m_hWnd, _T("注意:您需要重新启动计算机使设置生效,现在需要重启计算机吗?点击“是”立即重启计算机,点击“否”稍后您自己手动重启计算机。"), _T("重新启动计算机"), MB_YESNO)) SystemReboot(); } } else if (_tcsicmp(msg.sType, kTimer) == 0) { return OnTimer(msg); } }
void CMainDlg::Notify(TNotifyUI& msg) { //throw std::exception("The method or operation is not implemented."); //单击事件 if(msg.sType == DUI_MSGTYPE_CLICK) { //点击关闭按钮 if(msg.pSender->GetName() == _T("sys_close_btn")) //退出 Close(0); //点击添加按钮 else if(msg.pSender->GetName() == _T("add_option")) { //新建一个option按钮 CDialogBuilder builder; COptionUI * p = static_cast<COptionUI *>(builder.Create(_T("option.xml"),0,NULL,&m_pm)); if(NULL == p) return; CContainerUI * pContainer = static_cast<CContainerUI *>(m_pm.FindControl(_T("main_option_layout"))); int nCount = pContainer->GetCount(); static int i = 1; CDuiString str1; str1.Format(_T("新增按钮%d"), i); p->SetText(str1); pContainer->AddAt(p, nCount - 1); CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CDuiString str2; str2.Format(_T("新增界面%d"), i); //增加一个界面,这里可以像上边option一样使用xml创建 CButtonUI * pButton = new CButtonUI; pButton->SetTextColor(0xffffffff); pButton->SetText(str2); pTab->Add(pButton); p->SetTag(pTab->GetCount() - 1); } i++; } } //切换选项卡按钮时根据不同的按钮,选中不同的界面 else if(msg.sType == DUI_MSGTYPE_SELECTCHANGED) { if(msg.pSender->GetName() == _T("option_1")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CControlUI * pControl = pTab->FindSubControl(_T("tab_01")); if(NULL != pControl) pTab->SelectItem(pControl); } } else if(msg.pSender->GetName() == _T("option_2")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); if(NULL != pTab) { CControlUI * pControl = pTab->FindSubControl(_T("tab_02")); if(NULL != pControl) pTab->SelectItem(pControl); } } else if(msg.pSender->GetName() == _T("option")) { CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab"))); pTab->SelectItem(msg.pSender->GetTag()); } } }
void CUIDesignerView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CClientDC dc(this); OnPrepareDC(&dc);//Device coordinates to Logical coordinates dc.SetWindowOrg(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates CPoint ptLogical=point-m_ptDPtoLP;//Device coordinates to Logical coordinates ptLogical.Offset(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates CControlUI* pControl=m_LayoutManager.FindControl(ptLogical); CTrackerElement* pTracker=NULL; if(pControl==NULL) pControl=m_LayoutManager.GetForm(); int nHit=m_MultiTracker.HitTest(ptLogical); int nType=GetControlType(pControl); if((nFlags&MK_CONTROL)==0&&nHit==hitNothing) m_MultiTracker.RemoveAll(); if(nHit==hitNothing) m_MultiTracker.Add(CreateTracker(pControl)); else m_MultiTracker.SetFocus(ptLogical); if(nHit>=0||nType==typeControl) { m_MultiTracker.Track(this, ptLogical, FALSE,&dc); } else { CUITracker tracker; int nClass=g_pToolBoxWnd->GetCurSel()->GetClass(); CRect rect; if (tracker.TrackRubberBand(this, point, TRUE)) { rect=tracker.GetRect(); rect.NormalizeRect(); rect.OffsetRect(-FORM_OFFSET_X,-FORM_OFFSET_Y); if(rect.Width()<10&&rect.Height()<10) rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT); } else { rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT); } if(nClass>classPointer) { CControlUI* pNewControl=m_LayoutManager.NewUI(nClass,rect,pControl); CArray<CControlUI*,CControlUI*> arrSelected; arrSelected.Add(pNewControl); m_UICommandHistory.Begin(arrSelected, actionAdd); m_UICommandHistory.End(); g_pClassView->InsertUITreeItem(pNewControl); CContainerUI *pContainer = (CContainerUI *)pNewControl->GetInterface(_T("Container")); if (pContainer != NULL) { for (int it = 0; it < pContainer->GetRowCount(); it++) { g_pClassView->InsertUITreeItem(pContainer->GetItemAt(it)); } } g_pToolBoxWnd->SetCurSel(classPointer); m_MultiTracker.RemoveAll(); m_MultiTracker.Add(CreateTracker(pNewControl)); } } g_pClassView->SelectUITreeItem(m_MultiTracker.GetFocused()); if(m_MultiTracker.GetSize()==1) g_pPropertiesWnd->ShowProperty(m_MultiTracker.GetFocused()); else g_pPropertiesWnd->HideAllProperties(TRUE,TRUE); this->Invalidate(FALSE); // __super::OnLButtonDown(nFlags, point); }
void CGroupPackFileDownloadWnd::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("click")) == 0) { CDuiString strControlName = msg.pSender->GetName(); //关闭界面 if (_tcsicmp(msg.pSender->GetName(), "btn_close_downloadwnd") == 0) { // if (NULL != m_hMainWnd) // { // ::SendMessage(m_hMainWnd, WM_GROUPDOWNLOAD_PACKFILE_CLOSED, 0, 0); // } // // Close(); ShowWindow(false); } //下载 所有文件 else if (_tcsicmp(msg.pSender->GetName(), "btn_download_packfiles") == 0) { if ( IsDownLoading() || m_bDownloaded) { return; } sPackReadReceipt* pPackReadReceipt = new sPackReadReceipt(); pPackReadReceipt->strPackID = m_pCurrPackItem->strPackID; pPackReadReceipt->strRoomName = m_strRoomID ; pPackReadReceipt->strFrom = CController::Instance()->GetXmppClient()->jid().username(); pPackReadReceipt->strPackName = m_pCurrPackItem->strPackName; pPackReadReceipt->strAttribute = m_pCurrPackItem->strPackProp; SYSTEMTIME sysTime; ::GetLocalTime(&sysTime); char* pTime = new char[128]; sprintf(pTime,"%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d",sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds,sysTime.wDayOfWeek); pPackReadReceipt->strTime = pTime; ::SendMessage(mainDlg::getInstance()->GetHWND(), WM_GROUPDOWNLOAD_PACKFILE_DOWNLOADED, (WPARAM)pPackReadReceipt, 0); OnDownLoadPackFiles(); } //打开文件所在位置 else if (_tcsicmp(msg.pSender->GetName(), "btn_open_downloaded_packfiles") == 0) { if (NULL != m_pCurrPackItem) { tstring strPackDir = CFileHelper::GetPackDir(m_pCurrPackItem->strPackName, m_pCurrPackItem->strPackID); if (!strPackDir.empty()) { ShellExecute(NULL, NULL, strPackDir.c_str(), NULL,NULL,SW_SHOWNORMAL); } } } //打开,已下载文件 else if (_tcsicmp(msg.pSender->GetName(), "btn_open_downloaded_file") == 0) { CContainerUI* pListItem = static_cast<CContainerUI*>(msg.pSender->GetParent()); if (NULL != pListItem) { char* pBuff = (char*)pListItem->GetTag(); tstring strLocalFullFileName = pBuff; if (!strLocalFullFileName.empty()) { ShellExecute(NULL, NULL, strLocalFullFileName.c_str(), NULL,NULL,SW_SHOWNORMAL); } } } } else if(_tcsicmp(msg.sType, _T("itemclick")) == 0) { //HandleItemClickEvent(msg); } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { } else if(_tcsicmp(msg.sType, _T("selectchanged")) == 0) { int bac=100; } }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); InitWindow(); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 0) { if (_tcsicmp(msg.pSender->GetName(), _T("shockbtn"))==0) { theApp->ShakeToWho(friend_); } else if (_tcsicmp(msg.pSender->GetName(), _T("trans_file"))==0) { OnTransFile(msg); } else if (_tcsicmp(msg.pSender->GetName(), _T("empty_richedit")) == 0) { int lSelBegin,lSelEnd; lSelEnd = lSelBegin = m_pMsgView->GetTextLength(); m_pMsgView->SetSel(0, lSelEnd);//选择全部 m_pMsgView->ReplaceSel(_T(""), false); } else 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*>(GetPaintMgr()->FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(GetPaintMgr()->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*>(GetPaintMgr()->FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(GetPaintMgr()->FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(false); #else SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(GetPaintMgr()->FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CDuiRect rcEmotionBtn = msg.pSender->GetPos(); RECT rcWindow; GetWindowRect( &rcWindow ); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { SendMsg(); } } else if( _tcsicmp(msg.sType, _T("return")) == 0 ) { if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0) { SendMsg(); } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { // CContainerUI* pFontbar = static_cast<CContainerUI*>(GetPaintMgr()->FindControl(kFontbarControlName)); // if (pFontbar != NULL) // { // POINT pt = {0}; // CDuiRect rcFontbar = pFontbar->GetPos(); // CDuiRect rcColorBtn = msg.pSender->GetPos(); // RECT rcWindow; // GetWindowRect( &rcWindow); // // pt.y = rcWindow.top + rcFontbar.top; // pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); // new CColorPicker(this, pt); // } static CHOOSECOLOR cc; static COLORREF crCustCoLors[16]; cc.lStructSize=sizeof(CHOOSECOLOR); cc.hwndOwner= this->m_hWnd; cc.hInstance=NULL; cc.rgbResult = RGB(0,0,0); cc.lpCustColors=crCustCoLors; cc.Flags=CC_RGBINIT|CC_FULLOPEN | CC_ANYCOLOR; cc.lCustData=0; cc.lpfnHook=NULL; cc.lpTemplateName=NULL; if(TRUE == ChooseColor(&cc)) { TCHAR szBuf[MAX_PATH] = {0}; #if defined(UNDER_CE) _stprintf(szBuf, _T("FF%02X%02X%02X"), GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)); #else _stprintf_s(szBuf, MAX_PATH - 1, _T("FF%02X%02X%02X"), GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)); #endif LPTSTR pstr = NULL; text_color_ = _tcstoul(szBuf, &pstr, 16); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }
CContainerUI * CScalableLayout::CreateLayout( CScalableNode::Ptr pNode,int nLevel ) { CContainerUI *pLayout = pNode->IsHor ? static_cast<CContainerUI*>(new CHorizontalLayoutUI) : static_cast<CContainerUI*>(new CVerticalLayoutUI); pLayout->SetBkColor(pNode->BkColor); for (CScalableNode::Iter i = pNode->ChildBegin(); i != pNode->ChildEnd(); i++) { bool bLeaf = true; for (CScalableNode::Iter j = (*i)->ChildBegin(); j != (*i)->ChildEnd(); j++) { if ((*j)->Level == nLevel) { bLeaf = false; break; } } if (bLeaf) { CContainerUI *pItemContainer = new CContainerUI; CButtonUI *pItem = new CButtonUI; pItem->SetName((*i)->Name); pItem->SetBkColor((*i)->BkColor); pItem->SetShowHtml(); pItem->SetTextStyle(DT_CENTER|DT_VCENTER); CDuiString sText; if ((*i)->Text.IsEmpty()) { sText.Format(_T("{p}{c #FFCCCCCC}%s{/c}{/p}"), (LPCTSTR)(*i)->Description); } else { sText.Format(_T("{p}%s{n}{c #FFCCCCCC}%s{/c}{/p}"), (LPCTSTR)(*i)->Text,(LPCTSTR)(*i)->Description); } pItem->SetText(sText); pItemContainer->Add(pItem); pLayout->Add(pItemContainer); } else { pLayout->Add(CreateLayout(*i,nLevel)); } } if (!pNode->Description.IsEmpty()) { CVerticalLayoutUI *pWrapper = new CVerticalLayoutUI; pWrapper->Add(pLayout); pLayout->SetInset(CDuiRect(5,5,5,0)); CLabelUI *pDescription = new CLabelUI; pDescription->SetFixedHeight(20); pDescription->SetTextStyle(DT_CENTER); pDescription->SetBkColor(pNode->BkColor); pDescription->SetText(pNode->Description); pWrapper->Add(pDescription); return pWrapper; } return pLayout; }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 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(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CRect rcEmotionBtn = msg.pSender->GetPos(); CRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) { POINT pt = {0}; CRect rcFontbar = pFontbar->GetPos(); CRect rcColorBtn = msg.pSender->GetPos(); CRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcFontbar.top; pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); new CColorPicker(this, pt); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }
//道具栏UI位置匹配 void CRightFrame::FixPropUI(int cx,int cy) { if (cy <= 0) { return; } //匹配用户信息栏位置//////////////////////////////////////////////////////////////////////////////// CContainerUI* pInfoLeft = static_cast<CContainerUI*>(m_pm.FindControl("Info_Ctn_Left")); if (pInfoLeft) { pInfoLeft->SetFixedWidth(cx <= 300 ? 5 : 100); } //匹配道具栏的位置/////////////////////////////////////////////////////////////////////////////////// CContainerUI* pPropMainCtn = static_cast<CContainerUI*>(m_pm.FindControl("Prop_Ctn_Main")); if (pPropMainCtn) { RECT rcWnd; ::GetWindowRect(m_hWnd,&rcWnd); int iWidth = rcWnd.right - rcWnd.left - 50 - 34; const int iSpace = 4; const int iHorMums = iWidth / (34 + iSpace) + 1; m_uPropPageSize = iHorMums * 2; int iCount = 0; //计算页数 m_uPropPageNums = (MAX_PROP_NUMS % m_uPropPageSize) == 0 ? MAX_PROP_NUMS / m_uPropPageSize : MAX_PROP_NUMS / m_uPropPageSize + 1; for (int iPage = 0; iPage < m_uPropPageNums; ++iPage) { for (int iCol = 0; iCol < 2; ++iCol) { for (int iRow = 0; iRow < iHorMums; ++iRow) { if (iCount < MAX_PROP_NUMS) { SIZE sz = {(34 + 4) * iRow,15 + (34 + 4) * iCol}; m_pPropBtn[iCount++]->SetFixedXY(sz); } } } } //每次重定位后,都显示第一页 ShowPropPage(0); } //匹配聊天框的位置/////////////////////////////////////////////////////////////////////////////////// int x = 0,y = 0,width = 0,height = 0; CContainerUI* pCtrl = NULL; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); x += pCtrl ? pCtrl->GetInset().left : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Ctn_Talk_Main")); x += pCtrl ? pCtrl->GetInset().left : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Info")); y += pCtrl ? pCtrl->GetFixedHeight() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_UserList")); y += pCtrl ? pCtrl->GetFixedHeight() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Prop")); y += pCtrl ? pCtrl->GetFixedHeight() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); y += pCtrl ? pCtrl->GetInset().top : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Ctn_Talk_Main")); y += pCtrl ? pCtrl->GetInset().top : 0; width = cx - x; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); width -= pCtrl ? pCtrl->GetInset().right : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Ctn_Talk_Main")); width -= pCtrl ? pCtrl->GetInset().right : 0; height = cy - y; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); height -= pCtrl ? pCtrl->GetInset().bottom : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk_Control")); height -= pCtrl ? pCtrl->GetFixedHeight() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Ctn_Talk_Main")); height -= pCtrl ? pCtrl->GetInset().bottom : 0; //调整聊天输入框位置////////////////////////////////////////////////////////////////////////////////////////// width = cx; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); width -= pCtrl ? pCtrl->GetInset().left : 0; width -= pCtrl ? pCtrl->GetInset().right : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk_Control")); width -= pCtrl ? pCtrl->GetInset().left : 0; width -= pCtrl ? pCtrl->GetInset().right : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Talk_Ctn_01")); width -= pCtrl ? pCtrl->GetFixedWidth() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Talk_Ctn_02")); width -= pCtrl ? pCtrl->GetFixedWidth() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Talk_Ctn_04")); width -= pCtrl ? pCtrl->GetFixedWidth() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Talk_Ctn_05")); width -= pCtrl ? pCtrl->GetFixedWidth() : 0; pCtrl = static_cast<CContainerUI*>(m_pm.FindControl("Talk_Ctn_03")); width -= pCtrl ? pCtrl->GetInset().left : 0; width -= pCtrl ? pCtrl->GetInset().right : 0; CEditUI* pEdtCtrl = static_cast<CEditUI*>(m_pm.FindControl("Talk_Edt_Inp")); if (pEdtCtrl) { pEdtCtrl->SetFixedWidth(width - 30); } return; }
UINT CMessageDialog::DuiMessageBox(CFrameWnd *pMainWnd, LPCTSTR lpText, LPCTSTR lpCaption ,UINT uType, UINT uIcon) { m_pMainWnd = pMainWnd; m_strXMLPath = _T("xmls\\MessageBoxDialog.xml"); Create(m_pMainWnd->GetHWND(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE); if ( uType == MB_OK) { if ( m_pButtonCancel != NULL ) { m_pButtonCancel->SetVisible(false); } } else if( uType == MB_OKCANCEL ) { //保持默认xml配置 } else return 0; CContainerUI* pTextLayout = static_cast<CContainerUI*>(m_pm.FindControl(_T("TextLayout"))); if (pTextLayout != NULL) { switch(uIcon) { case MB_ICONASTERISK: { pTextLayout->SetBkImage(_T("file='UI\\MessageDialog\\BK.png' source='222,0,333,120' corner='111,0,0,0'")); break; } case MB_ICONQUESTION: { pTextLayout->SetBkImage(_T("file='UI\\MessageDialog\\BK.png' source='111,0,222,120' corner='111,0,0,0'")); break; } case MB_ICONWARNING: { pTextLayout->SetBkImage(_T("file='UI\\MessageDialog\\BK.png' source='0,0,111,120' corner='111,0,0,0'")); break; } case MB_ICONERROR: { pTextLayout->SetBkImage(_T("file='UI\\MessageDialog\\BK.png' source='222,0,333,120' corner='111,0,0,0'")); break; } default: break; } } CTextUI* pCaption_control = static_cast<CTextUI*>(m_pm.FindControl( _T("caption"))); if (pCaption_control != NULL) { pCaption_control->SetText(lpCaption); } CTextUI* pText_control = static_cast<CTextUI*>(m_pm.FindControl( _T("text"))); if (pText_control != NULL) { SIZE m_szClient = m_pm.GetClientSize(); int nCTextUIWidth = m_szClient.cx - pTextLayout->GetChildPadding() - pTextLayout->GetInset().left - 15; pText_control->SetText(lpText); RECT rect; GetClientRect(m_hWnd, &rect); SIZE szSpace = { 0 }; HFONT hOldFont =(HFONT)::SelectObject(m_pm.GetPaintDC(),m_pm.GetFont(0)); ::GetTextExtentPoint32(m_pm.GetPaintDC(), lpText, _tcslen(lpText), &szSpace); ::SelectObject(m_pm.GetPaintDC(),(HGDIOBJ)hOldFont); rect.right = rect.right + szSpace.cx - nCTextUIWidth; if((rect.right - rect.left) < m_szClient.cx ) rect.right = rect.left + m_szClient.cx; SetWindowPos (m_hWnd, NULL, rect.left, rect.top, rect.right , rect.bottom, SWP_SHOWWINDOW ); } CenterWindow(); UINT uRet = ShowModal(); return uRet; }
void ChatDialog::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, _T("windowinit")) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, _T("killfocus")) == 0) { } else if (_tcsicmp(msg.sType, _T("click")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); } else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); } else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0) { POINT pt = {0}; CDuiRect rcEmotionBtn = msg.pSender->GetPos(); CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcEmotionBtn.top; pt.x = rcWindow.left + rcEmotionBtn.left; //emotion_list_window_.SelectEmotion(pt); new CEmotion(this,pt); } else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0) { CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName)); CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName)); if( pRichEdit == NULL ) return; pRichEdit->SetFocus(); CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength()); //CDuiString sText=pRichEdit->GetEditGifStr(); if( sText.IsEmpty() ) return; int textlen = sText.GetLength(); if (textlen > 512) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); } else { int imNum = friend_.id; TCHAR sendmesg[513] = {0}; _stprintf_s(sendmesg,512,_T("%s"),sText.GetData()); int len = strlen(sendmesg); if (len !=textlen) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); } frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen); //显示在 SendMsg(g_myself_info.nick_name,sText); pRichEdit->SetText(_T("")); //test //CDuiString strbmp; //strbmp.Format("c:\\1.gif"); //pRichEdit->InsertGif(strbmp); } } } else if( _tcsicmp(msg.sType, _T("return")) == 0 ) { if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0) { CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName)); CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName)); if( pRichEdit == NULL ) return; pRichEdit->SetFocus(); CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength()); if( sText.IsEmpty() ) return; int textlen = sText.GetLength(); if (textlen > 512) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); } else { int imNum = friend_.id; TCHAR sendmesg[513] = {0}; _stprintf_s(sendmesg,512,_T("%s"),sText.GetData()); int len = strlen(sendmesg); if (len !=textlen) { pViewEdit->SetTextColor(RGB(255,0,0)); pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); } frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen); //显示在 SendMsg(g_myself_info.nick_name,sText); pRichEdit->SetText(_T("")); } } } else if (_tcsicmp(msg.sType, _T("timer")) == 0) { return OnTimer(msg); } else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName)); if (pFontbar != NULL) { POINT pt = {0}; CDuiRect rcFontbar = pFontbar->GetPos(); CDuiRect rcColorBtn = msg.pSender->GetPos(); CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); pt.y = rcWindow.top + rcFontbar.top; pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2); new CColorPicker((ChatDialog*)this, pt); } } else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0) { COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender); if (bold_button != NULL) { bold_ = bold_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0) { COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender); if (italic_button != NULL) { italic_ = italic_button->IsSelected(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0) { COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender); if (underline_button != NULL) { underline_ = underline_button->IsSelected(); FontStyleChanged(); } } } else if (_tcsicmp(msg.sType, _T("itemselect")) == 0) { if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0) { CComboUI* font_type = static_cast<CComboUI*>(msg.pSender); if (font_type != NULL) { font_face_name_ = font_type->GetText(); FontStyleChanged(); } } else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0) { CComboUI* font_size = static_cast<CComboUI*>(msg.pSender); if (font_size != NULL) { font_size_ = _ttoi(font_size->GetText()); FontStyleChanged(); } } } }
void CMainWindow::OnBtn_Font(TNotifyUI& msg) { CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("FontBar"))); if (pFontbar != NULL) pFontbar->SetVisible(!pFontbar->IsVisible()); }
//显示消息提示 void CRightFrame::ShowMessageTip(const BzDui::CButtonUI* pButton,const CString& strMsg,EBUBLEPOS pos) { //创建窗体 if (NULL == m_pTipWnd) { m_pTipWnd = new CTipWnd(); m_pTipWnd->Create(m_hWnd,NULL,UI_WNDSTYLE_DIALOG,0,0,0,0,0,NULL); } else return; //相关区域位置 RECT rc,rect; GetClientRect(m_pTipWnd->GetHWND(),&rc); GetWindowRect(m_pRoom->GetSafeHwnd(),&rect); SIZE btXY = pButton->GetFixedXY(); //相关控件 CContainerUI *pTalk = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Talk")); CContainerUI *pProp = static_cast<CContainerUI*>(m_pm.FindControl("Hor_Prop")); //偏移量读取 int propX = 0; int propY = 0; CString strPropXY; CBcfFile bcfFile(CBcfFile::GetAppPath()+"..\\"+m_skinmgr.GetSkinBcfFileName()); //设置位置 int moveX = 0; int moveY = 0; _TAG_USERPROP* userProp = (_TAG_USERPROP*)pButton->GetTag(); switch (pos) { case BUBLE_ON_PROP_POS: { if (userProp!= NULL) { strPropXY.Format("prop_btn0%d_posX",userProp->nPropID); propX = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),strPropXY,150); strPropXY.Format("prop_btn0%d_posY",userProp->nPropID); propY = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),strPropXY,40); } else { strPropXY = "prop_btn01_posX"; propX = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),strPropXY,150); strPropXY = "prop_btn01_posY"; propY = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),strPropXY,40); } moveX = rect.right-(pProp->GetWidth()-btXY.cx)-propX; moveY = rect.bottom-pTalk->GetHeight()-(pProp->GetHeight()-btXY.cy)-propY; } break; case BUBLE_ON_BOARDCAST_POS: { propX = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),"boardcast_posX",100); propY = bcfFile.GetKeyVal(_T("CustomDuiMessagePos"),"boardcast_posY",-20); moveX = rect.right-(pProp->GetWidth()-btXY.cx)-propX; moveY = rect.bottom-(pProp->GetHeight()-btXY.cy)-propY; } break; //位置不同只须添加枚举值和对应的处理即可 default: {} } //移动位置 ::MoveWindow(m_pTipWnd->GetHWND(),moveX,moveY,rc.right-rc.left,rc.bottom-rc.top,true); //设置显示字体 TCHAR textBuf[100] = {0}; lstrcpy(textBuf,strMsg); m_pTipWnd->SetText(textBuf); m_pTipWnd->ShowWindow(SW_SHOW); //定时器按时释放窗口 ::SetTimer(m_hWnd,IDT_MESSAGE_ON_PROP,500,NULL); }