LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // center the dialog on the screen CenterWindow(); // set icons hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); SetIcon(hIcon, TRUE); hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); SetIcon(hIconSmall, FALSE); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); UIAddChildWindowContainer(m_hWnd); CButton hGroupBox = GetDlgItem(IDC_GROUPBOXPC); hGroupBox.SetWindowTextW(L"在线监控端"); hGroupBox = GetDlgItem(IDC_GROUPBOXLAMP); hGroupBox.SetWindowTextW(L"在线节点"); hLampList = GetDlgItem(IDC_LISTCITYLAMP); hLampList.SetWindowLong(GWL_STYLE, LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE); hLampList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_FLATSB); hLampList.AddColumn(L"节点ID", 0); hLampList.AddColumn(L"SOCKET", 1); hLampList.SetColumnWidth(0, 80); hLampList.SetColumnWidth(1, 60); hPCList = GetDlgItem(IDC_LISTPCCLIENT); hPCList.SetWindowLong(GWL_STYLE, LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE); hPCList.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_FLATSB); hPCList.AddColumn(L"IP地址", 0); hPCList.AddColumn(L"主机名", 1); hPCList.SetColumnWidth(0, 100); hPCList.SetColumnWidth(1, 60); //初始化系统托盘 pnid.cbSize = (DWORD)sizeof(NOTIFYICONDATA);//该结构体大小 pnid.hWnd = m_hWnd; //窗口句柄 pnid.uID = (UINT)hIcon; //图标句柄 pnid.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP ; //图标有效|自定义消息有效|鼠标指向显示文字有效 pnid.uCallbackMessage = WM_SHOWWINDOW_MESSAGE;//自定义的消息名称 pnid.hIcon = hIconSmall; //图标句柄 wcscpy_s(pnid.szTip,L"城市景观灯监控系统服务器");//鼠标指向所显示的文字 return TRUE; }
void CCgxDlg::OnBnClickedStart() { CComboBox* gameList = (CComboBox*)GetDlgItem(IDC_GAME_LIST); CButton* startBtn = (CButton *)GetDlgItem(IDC_START); CEdit* script = (CEdit *)GetDlgItem(IDC_SCRIPT); CString strLine; int index = gameList->GetCurSel(); if(gameManager.gameSize == 0 || index > gameManager.gameSize) return; if(gameManager.games[index]->isAIStart) { gameManager.games[index]->stopAI(); startBtn->SetWindowTextW(TEXT("启动")); } else { script->GetWindowTextW(strLine); gameManager.games[index]->script.loadScript((LPCWSTR)strLine); gameManager.games[index]->startAI(); startBtn->SetWindowTextW(TEXT("停止")); } }