LRESULT CDeviceRenameDialog::OnClose(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CEdit wndName(GetDlgItem(IDC_DEVICE_NAME)); wndName.GetWindowText(m_szName, MAX_NAME_LEN + 1); if (IDOK == wID && 0 != ::lstrcmp(m_szOldName, m_szName)) { // // name is changed! check duplicate // ndas::DevicePtr pExistingDevice; if (ndas::FindDeviceByName(pExistingDevice, m_szName)) { AtlMessageBox( m_hWnd, IDS_ERROR_DUPLICATE_NAME, IDS_MAIN_TITLE, MB_OK | MB_ICONWARNING); m_wndName.SetFocus(); m_wndName.SetSel(0, -1); return 0; } } EndDialog(wID); return 0; }
LRESULT CRenameDialog::OnClose(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CEdit wndName(GetDlgItem(IDC_DEVICE_NAME)); _ASSERTE(NULL != wndName.m_hWnd); wndName.GetWindowText(m_szName, MAX_NAME_LEN + 1); if (IDOK == wID && 0 != ::lstrcmp(m_szOldName, m_szName)) { // name is changed! // check duplicate ndas::Device* pExistingDevice = _pDeviceColl->FindDeviceByName(m_szName); if (NULL != pExistingDevice) { pExistingDevice->Release(); AtlMessageBox( m_hWnd, IDS_ERROR_DUPLICATE_NAME, IDS_MAIN_TITLE, MB_OK | MB_ICONWARNING); m_wndName.SetFocus(); m_wndName.SetSel(0, -1); return 0; } } EndDialog(wID); return 0; }
CEGUI::String LinkButtonParser::Parse(const CEGUI::String &str) { std::string szStr = CEGUIStringToAnsiChar( str ); size_t parentWinPos,IDPos,TextPos,ColorPos,endPos; parentWinPos = IDPos = TextPos = ColorPos = endPos = CEGUI::String::npos; char ParentWinName[128] = ""; char LinkID[32] = ""; char LinkText[128] = ""; char ColorVal[32] = ""; parentWinPos = str.find("WIN:"); IDPos = str.find("ID:"); TextPos = str.find("TEXT:"); ColorPos = str.find("COLOR:"); std::string wndName("LinkBtn_"),temp; static DWORD LinkWndCounter = 0; wndName += CEGUI::PropertyHelper::intToString(LinkWndCounter++).c_str(); CEGUI::Window *linkWnd = 0; if (CEGUI::WindowManager::getSingleton().isWindowPresent(wndName) == false) { linkWnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button",wndName); linkWnd->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LinkButtonParser::OnLinkBtnClicked,this)); //解析父窗口 if (parentWinPos != CEGUI::String::npos) { temp = szStr.substr(parentWinPos+5); endPos = temp.find("'"); strcpy_s<128>(ParentWinName,temp.substr(0,endPos).c_str()); CEGUI::Window *pParentWnd = CEGUI::WindowManager::getSingleton().getWindow(ParentWinName); pParentWnd->addChildWindow(linkWnd); } //解析ID if (IDPos != CEGUI::String::npos) { temp = szStr.substr(IDPos+3); endPos = temp.find(" "); strcpy_s<32>(LinkID,temp.substr(0,endPos).c_str()); LinkMap[linkWnd] = LinkID; } //解析链接按钮文本 if (TextPos != CEGUI::String::npos) { temp = szStr.substr(TextPos+6); endPos = temp.find("'"); strcpy_s<128>(LinkText,temp.substr(0,endPos).c_str()); float fWidth = linkWnd->getFont()->getTextExtent(LinkText); float fheight = linkWnd->getFont()->getFontHeight(); linkWnd->setSize(CEGUI::UVector2(cegui_absdim(fWidth),cegui_absdim(fheight))); //解析链接按钮文本的颜色 if (ColorPos != CEGUI::String::npos) { temp = szStr.substr(ColorPos+6); endPos = temp.find(" "); strcpy_s(ColorVal,temp.substr(0,endPos).c_str()); temp = "[COLOR "; temp += ColorVal; temp += "]"; temp += CEGUI::String(LinkText).c_str(); linkWnd->setText(ToCEGUIString(temp.c_str())); } else linkWnd->setText(ToCEGUIString(LinkText)); } } return wndName; }