//鼠标消息 void CGameFrame::OnLButtonDblClk(UINT nFlags, CPoint Point) { __super::OnLButtonDblClk(nFlags,Point); //状态判断 if (Point.y>m_ImageInfoFrame.nTBorder-FRAME_EXALTATION) return; //控制窗口 if (m_bMaxShow==true) RestoreWindow(); else MaxSizeWindow(); return; }
BOOL CGameClientDlg::OnInitDialog() { __super::OnInitDialog(); //设置属性 ModifyStyle(WS_CAPTION|WS_BORDER,0,0); m_bAllowSound=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("EnableSound"),TRUE)?true:false; //创建游戏视图 CRect rcGameView; m_GameClientView.Create(NULL,NULL,WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,rcGameView,this,10); //创建组件 if (m_UserFaceResHelper.CreateInstance()==false) throw TEXT("头像组件加载失败"); if (m_ClientKernelHelper.CreateInstance()==false) throw TEXT("游戏框架内核模块加载失败"); //初始化内核 CWinApp *p=AfxGetApp(); LPCTSTR lpszCmdLine=AfxGetApp()->m_lpCmdLine; IUnknownEx * pIUnknownEx=GET_MYSELF_INTERFACE(IUnknownEx); bool bSuccess=m_ClientKernelHelper->InitClientKernel(lpszCmdLine,pIUnknownEx); if (bSuccess==false) throw TEXT("游戏框架逻辑模块初始化失败"); IUnknownEx * pIMessageProxy = GET_OBJECT_INTERFACE(m_GameClientView.m_MyListView,IUnknownEx); bSuccess=m_ClientKernelHelper->SetMessageProxy(pIMessageProxy); if (bSuccess==false) throw TEXT("获取消息输出模块失败"); //初始化游戏 m_GameClientView.m_MyListView.SetClientKernel(m_ClientKernelHelper.GetInterface()); if (InitGameFrame()==false) throw TEXT("游戏框架初始化失败"); //显示窗口 m_bInitDialog=true; m_GameClientView.ShowWindow(SW_SHOW); //显示窗口 if (GetSystemMetrics(SM_CXSCREEN)>1024) { MoveWindow(0,0,1024,748,FALSE); CenterWindow(NULL); } else MaxSizeWindow(); ShowWindow(SW_SHOW); return TRUE; }
//鼠标消息 VOID CGameFrameWnd::OnLButtonDblClk(UINT nFlags, CPoint Point) { __super::OnLButtonDblClk(nFlags,Point); //状态判断 if (Point.y>CAPTION_SIZE) return; //窗口控制 if (m_bMaxShow==true) { RestoreWindow(); } else { MaxSizeWindow(); } return; }
//鼠标左键事件 bool CSkinWndObject::OnLMouseUpEvent(CPoint ClientPoint) { //按钮搜索 if (m_cbNowDownButton!=255) { ReleaseCapture(); if ((m_rcButton[m_cbNowDownButton].PtInRect(ClientPoint)) &&(!(m_cbButtonState[m_cbNowDownButton]&BUT_DISABLE))) { switch (m_cbNowDownButton) { case BST_CLOSE: //关闭按钮 { m_cbNowDownButton=255; m_pWndHook->PostMessage(WM_CLOSE,0,0); return true; } case BST_MAX: //还原按钮 { m_cbNowDownButton=255; if (m_bMaxSize==true) RestoreWindow(); else MaxSizeWindow(); return true; } case BST_MIN: //最小化按钮 { m_cbNowDownButton=255; m_pWndHook->ShowWindow(SW_MINIMIZE); return true; } } } //默认操作 m_cbNowDownButton=255; DrawSkinView(NULL); } return true; }
//鼠标左键事件 bool CSkinWndObject::OnLMouseDoubleEvent(CPoint ClientPoint) { //判断按下 if (m_cbNowDownButton!=255) return false; //按钮搜索 for (int i=0;i<3;i++) { if ((m_cbButtonState[i]&BUT_EXIST)&&(m_rcButton[i].PtInRect(ClientPoint))) return true; } //最大化窗口 if ((ClientPoint.y<GetYExcursionPos())&&(m_cbButtonState[BST_MAX]&BUT_EXIST)&& (!(m_cbButtonState[BST_MAX]&BUT_DISABLE))) { if (m_bMaxSize==true) RestoreWindow(); else MaxSizeWindow(); } return true; }
//初始化函数 BOOL CGameFrameDlg::OnInitDialog() { __super::OnInitDialog(); //设置属性 ModifyStyle(WS_CAPTION|WS_BORDER,0,0); //读取配置 m_bAllowSound=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("EnableSound"),TRUE)?true:false; //创建控制 m_pGameFrameControl=new CGameFrameControl(this); if (m_pGameFrameControl==NULL) throw TEXT("游戏框架创建失败"); //创建组件 if (m_MessageProxyHelper.CreateInstance()==false) throw TEXT("信息组件创建失败"); m_MessageProxyHelper->SetRichEditHwnd(&m_pGameFrameControl->m_ChatMessage); //设置界面 m_VorSplitter.SetSplitterSink(this); //创建组件 if (m_UserFaceResHelper.CreateInstance()==false) throw TEXT("头像组件加载失败"); if (m_ClientKernelHelper.CreateInstance()==false) throw TEXT("游戏框架内核模块加载失败"); //创建游戏视图 CRect rcGameView(0,0,0,0); m_pGameFrameControl->Create(IDD_FRAME_CONTROL,this); if (m_pGameFrameControl->SetUserFaceRes(m_UserFaceResHelper.GetInterface())==false) throw TEXT("头像资源接口设置失败"); m_pGameFrameView->Create(NULL,NULL,WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,rcGameView,this,10); if (m_pGameFrameView->SetUserFaceRes(m_UserFaceResHelper.GetInterface())==false) throw TEXT("头像资源接口设置失败"); CVideoServiceManager * pVideoServiceManager=CVideoServiceManager::GetInstance(); if (pVideoServiceManager!=NULL && pVideoServiceManager->SetUserFaceRes(m_UserFaceResHelper.GetInterface())==false) throw TEXT("头像资源接口设置失败"); //初始化内核 LPCTSTR lpszCmdLine=AfxGetApp()->m_lpCmdLine; bool bSuccess=m_ClientKernelHelper->InitClientKernel(lpszCmdLine,m_pKernelSink); if (bSuccess==false) throw TEXT("游戏框架逻辑模块初始化失败"); bSuccess=m_ClientKernelHelper->SetMessageProxy(m_MessageProxyHelper.GetInterface()); if (bSuccess==false) throw TEXT("获取消息输出模块失败"); //初始化游戏 m_pGameFrameControl->SetClientKernel(m_ClientKernelHelper.GetInterface()); if (InitGameFrame()==false) throw TEXT("游戏框架初始化失败"); //加载资源 UpdateSkinResource(); //移动窗口 INT nXScreen=GetSystemMetrics(SM_CXSCREEN); INT nYScreen=GetSystemMetrics(SM_CYSCREEN); SetWindowPos(NULL,0,0,__min(nXScreen,1024),__min(nYScreen,730),SWP_NOZORDER|SWP_NOMOVE); //显示窗口 m_bInitDialog=true; m_pGameFrameView->ShowWindow(SW_SHOW); m_pGameFrameControl->ShowWindow(SW_SHOW); //显示窗口 CenterWindow(); MaxSizeWindow(); ShowWindow(SW_SHOW); return TRUE; }
//初始化函数 BOOL CGameFrameDlg::OnInitDialog() { __super::OnInitDialog(); CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sCGameFrameDlg.log",strTime); strTemp.Format("into OnInitDialog"); WriteLog(strFile, strTemp); //设置属性 ModifyStyle(WS_CAPTION|WS_BORDER,0,0); m_bAllowSound=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("EnableSound"),TRUE)?true:false; //创建控制 m_pGameFrameControl=new CGameFrameControl(this); if (m_pGameFrameControl==NULL) throw TEXT("游戏框架创建失败"); strTemp.Format("into OnInitDialog 2"); WriteLog(strFile, strTemp); //创建组件 if (m_MessageProxyHelper.CreateInstance()==false) throw TEXT("信息组件创建失败"); m_MessageProxyHelper->SetRichEditHwnd(&m_pGameFrameControl->m_ChatMessage); //设置界面接口 m_VorSplitter.SetSplitterSink(this); // m_VorSplitter.InitSplitBar( ); if(pOneUserInfoDlg==NULL) { pOneUserInfoDlg=new CDlgDTSound(this); pOneUserInfoDlg->Create(CDlgDTSound::IDD, this); if (pOneUserInfoDlg==NULL) throw TEXT("pOneUserInfoDlg创建失败"); } //设置按钮 HINSTANCE hInstance=GetModuleHandle(GAME_FRAME_DLL_NAME); m_BtHideList.SetButtonImage(IDB_HIDE_LIST,hInstance,false); m_BtYuYin.SetButtonImage(IDB_YU_YIN,hInstance,false); m_btGameOption.SetButtonImage(IDB_BT_OPTION,hInstance,false); m_btQuitGame.SetButtonImage(IDB_BT_QUIT,hInstance,false); m_btQuitGame.ShowWindow(false); m_btGameRule.SetButtonImage(IDB_BT_GAME_RULE,hInstance,false); //创建组件 if (m_UserFaceResHelper.CreateInstance()==false) throw TEXT("头像组件加载失败"); if (m_ClientKernelHelper.CreateInstance()==false) throw TEXT("游戏框架内核模块加载失败"); strTemp.Format("into OnInitDialog 3"); WriteLog(strFile, strTemp); //创建游戏视图 CRect rcGameView; m_pGameFrameControl->Create(IDD_FRAME_CONTROL,this); m_pGameFrameView->Create(NULL,NULL,WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,rcGameView,this,10); if (m_pGameFrameView->SetUserFaceRes(m_UserFaceResHelper.GetInterface())==false) throw TEXT("头像资源接口设置失败"); //初始化内核 LPCTSTR lpszCmdLine=AfxGetApp()->m_lpCmdLine; bool bSuccess=m_ClientKernelHelper->InitClientKernel(lpszCmdLine,m_pKernelSink); if (bSuccess==false) throw TEXT("游戏框架逻辑模块初始化失败"); bSuccess=m_ClientKernelHelper->SetMessageProxy(m_MessageProxyHelper.GetInterface()); if (bSuccess==false) throw TEXT("获取消息输出模块失败"); strTemp.Format("into OnInitDialog 4"); WriteLog(strFile, strTemp); //初始化游戏 m_pGameFrameControl->SetClientKernel(m_ClientKernelHelper.GetInterface()); if (InitGameFrame()==false) throw TEXT("游戏框架初始化失败"); //显示窗口 m_bInitDialog=true; m_pGameFrameView->ShowWindow(SW_SHOW); m_pGameFrameControl->ShowWindow(SW_SHOW); //显示窗口 MaxSizeWindow(); ShowWindow(SW_SHOW); // SetTimer( 1234, 3000, NULL); InitUserStatus(); InitToolsBar(); InitMyselfToolsBar(); m_BtHideList.ShowWindow(true); m_BtYuYin.ShowWindow(true); strTemp.Format("into OnInitDialog 5"); WriteLog(strFile, strTemp); return TRUE; }
//命令函数 BOOL CGameFrameWnd::OnCommand(WPARAM wParam, LPARAM lParam) { //变量定义 UINT nCommandID=LOWORD(wParam); //功能按钮 switch (nCommandID) { case IDC_MIN: //最小按钮 { ShowWindow(SW_MINIMIZE); return TRUE; } case IDC_MAX: //最大按钮 { //窗口控制 if (m_bMaxShow==true) { RestoreWindow(); } else { MaxSizeWindow(); } //更新界面 RedrawWindow(NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW); return TRUE; } case IDC_CLOSE: //关闭按钮 { //获取用户 ASSERT(m_pIClientKernel!=NULL); IClientUserItem * pIClientUserItem=m_pIClientKernel->GetMeUserItem(); //强退提示 if ((pIClientUserItem!=NULL)&&(pIClientUserItem->GetUserStatus()==US_PLAYING)) { //提示消息 CInformation Information(this); if (Information.ShowMessageBox(TEXT("您正在游戏中,强行退出将被扣分,确实要强退吗?"),MB_ICONQUESTION|MB_YESNO,0)!=IDYES) { return TRUE; } } //投递关闭 PostMessage(WM_CLOSE,0,0); return TRUE; } case IDC_OPTION: //选项按钮 { //显示配置 CDlgGameOption DlgGameOption; if (DlgGameOption.CreateGameOption(NULL,0)==true) { return true; } return true; } case IDC_MUTE: { //定义变量 CGlobalUnits *pGlobalUnits=CGlobalUnits::GetInstance(); pGlobalUnits->m_bMuteStatuts=!pGlobalUnits->m_bMuteStatuts; //设置按钮 HINSTANCE hInstance=GetModuleHandle(GAME_FRAME_DLL_NAME); m_btMuteContrl.SetButtonImage((pGlobalUnits->m_bMuteStatuts==false)?IDB_BT_MUTE:IDB_BT_SLIENT,hInstance,true,false); //状态处理 if(pGlobalUnits->m_bMuteStatuts) { pGlobalUnits->StopSound(); } //通知游戏 if(m_pIClientKernel) { m_pIClientKernel->OnGameOptionChange(); } return true; } case IDC_RULE: { try { //创建对象 if (m_pDlgGameRule==NULL) m_pDlgGameRule=new CDlgGameRule; //创建窗口 if (m_pDlgGameRule->m_hWnd==NULL) { AfxSetResourceHandle(GetModuleHandle(GAME_FRAME_DLL_NAME)); m_pDlgGameRule->Create(IDD_GAME_RULE,GetDesktopWindow()); AfxSetResourceHandle(GetModuleHandle(NULL)); } //显示窗口 m_pDlgGameRule->ShowWindow(SW_RESTORE); m_pDlgGameRule->SetForegroundWindow(); return true; } catch (...) { ASSERT(FALSE); return false; } return true; } case IDC_CONTROL: //控制按钮 { //设置变量 m_bShowControl = !m_bShowControl; //更新按钮 HINSTANCE hInstance=GetModuleHandle(GAME_FRAME_DLL_NAME); m_btControl.SetButtonImage(IDB_BT_CONTROL_BACK,(m_bShowControl==false)?TEXT("BT_GAME_LIST_SHOW"):TEXT("BT_GAME_LIST_HIDE"),hInstance,true,false); //调整界面 CRect rcClient; GetClientRect(&rcClient); RectifyControl(rcClient.Width(),rcClient.Height()); return true; } } return __super::OnCommand(wParam,lParam); }
INT CMyFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //设置窗口 ModifyStyle(WS_CAPTION,0,0); ModifyStyleEx(WS_BORDER|WS_EX_CLIENTEDGE|WS_EX_WINDOWEDGE,0,0); ModifyStyle(0, WS_MINIMIZEBOX); ModifyStyle(0, WS_MAXIMIZEBOX); CRect rcCreate(0,0,0,0); m_PlazaViewItem.Create(IDD_ADMINCONTROL_DIALOG,NULL/*this*/); // m_PlazaViewItem.ShowWindow(SW_SHOWMAXIMIZED); // m_btMin.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_MIN); // m_btMax.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_MAX); // m_btClose.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_CLOSE); // m_ToolTipCtrl.Create(this); // m_ToolTipCtrl.Activate(TRUE); // m_ToolTipCtrl.AddTool(&m_btMin,TEXT("最小化")); // m_ToolTipCtrl.AddTool(&m_btMax,TEXT("最大化")); // m_ToolTipCtrl.AddTool(&m_btClose,TEXT("关闭游戏")); //注册事件 CPlatformEvent * pPlatformEvent=CPlatformEvent::GetInstance(); if (pPlatformEvent!=NULL) pPlatformEvent->RegisterEventWnd(m_hWnd); //设置位置 // CSize SizeRestrict; // SizeRestrict.SetSize(LESS_SCREEN_CX,LESS_SCREEN_CY); // // //窗口位置 // CRect rcArce; // SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); // // //读取位置 // CWHRegKey InfoKeyItem; // if (InfoKeyItem.OpenRegKey(REG_INTERFACE_INFO,false)==true) // { // SizeRestrict.cx=InfoKeyItem.GetValue(TEXT("ScreenWidth"),rcArce.Width()/2); // SizeRestrict.cy=InfoKeyItem.GetValue(TEXT("ScreenHeight"),rcArce.Height()/2); // } // // //位置调整 // SizeRestrict.cx=__max(LESS_SCREEN_CX,SizeRestrict.cx); // SizeRestrict.cy=__max(LESS_SCREEN_CY,SizeRestrict.cy); // SizeRestrict.cx=__min(rcArce.Width(),SizeRestrict.cx); // SizeRestrict.cy=__min(rcArce.Height(),SizeRestrict.cy); // // //移动窗口 // m_rcNormalSize.top=(rcArce.Height()-SizeRestrict.cy)/2; // m_rcNormalSize.left=(rcArce.Width()-SizeRestrict.cx)/2; // m_rcNormalSize.right=m_rcNormalSize.left+SizeRestrict.cx; // m_rcNormalSize.bottom=m_rcNormalSize.top+SizeRestrict.cy; // SetWindowPos(NULL,m_rcNormalSize.left,m_rcNormalSize.top,m_rcNormalSize.Width(),m_rcNormalSize.Height(),SWP_NOZORDER); MaxSizeWindow(); //登录系统 SendMessage(WM_COMMAND,IDM_USER_LOGON,0); m_MissionUserInfo.m_GameUserListDlg = &m_PlazaViewItem.m_GameUserListDlg; m_MissionUserInfo.m_StockDlg = &m_PlazaViewItem.m_StockDlg; m_MissionUserInfo.m_pLogDlg = &m_PlazaViewItem.m_LogDlg; m_MissionUserInfo.m_pOnLineUserSortDlg = &m_PlazaViewItem.m_OnLineUserSortDlg; m_MissionUserInfo.m_pOffLineUserDlg = &m_PlazaViewItem.m_OffLineUserDlg; m_MissionUserInfo.m_pSilverDlg = &m_PlazaViewItem.m_SilverDlg; return 0; }
BOOL CMyFrameWnd::OnCommand(WPARAM wParam, LPARAM lParam) { //变量定义 UINT nCommandID=LOWORD(wParam); //功能按钮 switch (nCommandID) { case IDC_MIN: //最小按钮 { ShowWindow(SW_MINIMIZE); return TRUE; } case IDC_MAX: //最大按钮 { //窗口控制 if (m_bMaxShow==true) { RestoreWindow(); } else { MaxSizeWindow(); } //更新界面 RedrawWindow(NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW); return TRUE; } case IDC_CLOSE: //关闭按钮 { //PostMessage(WM_CLOSE,0,0); return TRUE; } case IDC_SKIN: //界面控制 { //创建窗口 // if (m_DlgSkinControl.m_hWnd==NULL) // { // m_DlgSkinControl.Create(IDD_SKIN_CONTROL,this); // } // // //获取位置 // CRect rcButton; // CRect rcControl; // m_btSkin.GetWindowRect(&rcButton); // m_DlgSkinControl.GetWindowRect(&rcControl); // // //显示窗口 // UINT uFlags=SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW; // m_DlgSkinControl.SetWindowPos(NULL,rcButton.right-rcControl.Width(),rcButton.bottom,0,0,uFlags); return TRUE; } // case IDC_CONTROL: //控制按钮 // { // //控制列表 // ControlServerList(ServerListControl_Turn,true); // // return TRUE; // } // case IDC_LOCK_LIST: //锁定列表 // { // //设置变量 // m_bLockGameList=!m_bLockGameList; // // //设置按钮 // HINSTANCE hInstance=AfxGetInstanceHandle(); // m_btLockList.SetButtonImage(IDB_BK_LIST,(m_bLockGameList==true)?TEXT("BT_UNLOCK_LIST"):TEXT("BT_LOCK_LIST"),hInstance,true,false); // // return TRUE; // } // case IDC_NAVIGATION+2: // { // //变量定义 // bool bGoldServer=false; // CServerViewItem * pServerViewGold=NULL; // // //查找房间 // for (INT_PTR i=0;i<m_ServerViewItemArray.GetCount();i++) // { // //获取房间 // ASSERT(m_ServerViewItemArray[i]!=NULL); // CServerViewItem * pServerViewItem=m_ServerViewItemArray[i]; // // //房间类型 // WORD wServerType=pServerViewItem->GetServerType(); // enServiceStatus ServiceStatus=pServerViewItem->GetServiceStatus(); // // //房间判断 // if (((wServerType&GAME_GENRE_GOLD)/*||(wServerType&GAME_GENRE_MATCH)*/)&&(ServiceStatus==ServiceStatus_ServiceIng)) // { // //设置变量 // bGoldServer=true; // pServerViewGold=pServerViewItem; // // break; // } // } // // //设置资源 // AfxSetResourceHandle(GetModuleHandle(SHARE_CONTROL_DLL_NAME)); // // //银行中心 // if (bGoldServer==false) // { // //广场银行 // CDlgInsurePlaza DlgInsurePlaza; // INT_PTR nResult=DlgInsurePlaza.DoModal(); // } // else // { // //房间银行 // ASSERT(pServerViewGold!=NULL); // pServerViewGold->ShowInsureView(); // } // return TRUE; // } // case IDC_NAVIGATION+0: // case IDC_NAVIGATION+1: // { // //变量定义 // // ASSERT(CParameterGlobal::GetInstance()!=NULL); // // CParameterGlobal * pParameterGlobal=CParameterGlobal::GetInstance(); // // // // //构造地址 // // TCHAR szNavigation[256]=TEXT(""); // // _sntprintf(szNavigation,CountArray(szNavigation),TEXT("%s/Navigation%ld.aspx"),szPlatformLink,(nCommandID-IDC_NAVIGATION)+1); // // // // //连接地址 // // WebBrowse(szNavigation,true); // // // // return TRUE; // } // case IDC_NAVIGATION+3: //导航按钮 // { // //变量定义 // ASSERT(CParameterGlobal::GetInstance()!=NULL); // CParameterGlobal * pParameterGlobal=CParameterGlobal::GetInstance(); // // //构造地址 // TCHAR szNavigation[256]=TEXT(""); // _sntprintf(szNavigation,CountArray(szNavigation),TEXT("%s/Navigation%ld.aspx"),szPlatformLink,(nCommandID-IDC_NAVIGATION)+1); // // //连接地址 // WebBrowse(szNavigation,true); // // return TRUE; // } // case IDC_NAVIGATION+4: //客服按钮 // { // //变量定义 // ASSERT(CParameterGlobal::GetInstance()!=NULL); // CParameterGlobal * pParameterGlobal=CParameterGlobal::GetInstance(); // // //构造地址 // TCHAR szNavigation[256]=TEXT(""); // _sntprintf(szNavigation,CountArray(szNavigation),TEXT("%s/Service/IssueList.aspx"),szPlatformLink); // /*_sntprintf(szNavigation,CountArray(szNavigation),TEXT("http://wpa.qq.com/msgrd?v=3&uin=653969305&site=qq&menu=yes"));*/ // // //连接地址 // WebBrowse(szNavigation,true); // // return TRUE; // // } } //菜单命令 switch (nCommandID) { case IDM_USER_LOGON: //用户登录 { m_MissionLogon.ShowLogon(); return TRUE; } case IDM_SWITCH_ACCOUNTS: //切换帐号 { //切换询问 // if ((m_ServerViewItemArray.GetCount()>0L)||(m_pServerViewItem!=NULL)) // { // // CInformation Information(this); // // if (Information.ShowMessageBox(TEXT("所有的游戏房间即将关闭,确实要“切换帐号”吗? "),MB_YESNO)!=IDYES) return TRUE; // // } //全局设置 // CGlobalUnits::GetInstance()->DeleteUserCookie(); // CGlobalUserInfo::GetInstance()->ResetUserInfoData(); // // //发送事件 // CPlatformEvent * pPlatformEvent=CPlatformEvent::GetInstance(); // if (pPlatformEvent!=NULL) pPlatformEvent->SendPlatformEvent(EVENT_USER_LOGOUT,0L); return TRUE; } case IDM_RESTORE: //还原 { if(IsIconic()) { ShowWindow(SW_RESTORE); } return TRUE; } case IDM_MINIMIZE: //最小化 { ShowWindow(SW_MINIMIZE); return TRUE; } case IDM_MAXIMIZE: //最大化 { if(IsIconic()) { ShowWindow(SW_RESTORE); } //MaxSizeWindow(); return TRUE; } //case SC_RESTORE : // { // if(IsIconic()) // { // ShowWindow(SW_RESTORE); // } // return TRUE; // } } return __super::OnCommand(wParam,lParam); }
//命令函数 BOOL CGameFrame::OnCommand(WPARAM wParam, LPARAM lParam) { //变量定义 UINT nCommandID=LOWORD(wParam); //切换按钮 if ((nCommandID>=IDC_BT_VIEW_ITEM)&&(nCommandID<(IDC_BT_VIEW_ITEM+CountArray(m_btViewItem)))) { ActiveRoomViewItem(m_pRoomViewItem[nCommandID-IDC_BT_VIEW_ITEM]); return TRUE; } //消息处理 switch(nCommandID) { case IDC_BT_MIN : //最小化窗 { ShowWindow(SW_MINIMIZE); return TRUE; } case IDC_BT_MAX : //最大化窗 { if (m_bMaxShow==true) RestoreWindow(); else MaxSizeWindow(); return TRUE; } case IDC_BT_BUTTON_1: //功能按钮 case IDC_BT_BUTTON_3: //功能按钮 case IDC_BT_BUTTON_4: //功能按钮 case IDC_BT_BUTTON_5: //功能按钮 { if(IDC_BT_BUTTON_1==nCommandID)WebBrowse(TEXT("http://127.0.0.1:8086/"),true); if(IDC_BT_BUTTON_3==nCommandID)WebBrowse(TEXT("http://127.0.0.1:8086/PayBuy.asp"),true); if(IDC_BT_BUTTON_4==nCommandID)WebBrowse(TEXT("http://127.0.0.1:8086/user/ExChange.asp"),true); if(IDC_BT_BUTTON_5==nCommandID)WebBrowse(TEXT("http://127.0.0.1:8086/"),true); return TRUE; } case IDC_BT_BUTTON_2: //上传头像 { //创建窗体 if ( m_DlgCustomFace.m_hWnd == NULL ) { m_DlgCustomFace.Create(IDD_CUSTOM_FACE, this); } //显示窗体 m_DlgCustomFace.CenterWindow(); m_DlgCustomFace.ShowWindow(SW_SHOW); m_DlgCustomFace.SetActiveWindow(); m_DlgCustomFace.SetForegroundWindow(); return TRUE; } case IDC_BT_PLAZA : //大厅按钮 { ActivePlazaViewItem(); return TRUE; } case IDC_BT_EXCHANGE_SINK: //换肤按钮 { g_GlobalUnits.m_PlatformResourceModule->SetResourceType(RESOURCE_RED); UpdateSkinResource(); m_DlgGamePlaza.UpdateSkinResource(); m_UserInfoView.UpdateSkinResource(); for (int i=0;i<CountArray(m_pRoomViewItem);i++) { if (m_pRoomViewItem[i]==NULL) break; m_pRoomViewItem[i]->UpdateSkinResource(); } return TRUE; } case IDC_BT_CLOSE : //关闭房间 case IDC_BT_QUIT_GAME : //退出游戏 { CloseCurrentViewItem(); return TRUE; } case IDC_BT_SYSTEM_OPTION : //系统配置 { //系统设置 ShowSystemOption(); return TRUE; } case IDC_BT_SELF_OPTION: //个人配置 { CDlgIndividualInfo DlgIndividualInfo; DlgIndividualInfo.DoModal(); return TRUE; } case IDC_BT_SWITCH_ACCOUNTS : //切换按钮 { //状态判断 tagGlobalUserData & GlobalUserData=g_GlobalUnits.GetGolbalUserData(); if (GlobalUserData.dwUserID==0L) return TRUE; //切换询问 if (m_pRoomViewItem[0]!=NULL) { const TCHAR szMessage[]=TEXT("切换用户帐号,将会关闭所有游戏房间,确实要切换用户帐号吗? "); int iResult=ShowMessageBox(szMessage,MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2); if (iResult!=IDYES) return TRUE; } else { const TCHAR szMessage[]=TEXT("确实要注销当前用户,切换用户帐号吗? "); int iResult=ShowMessageBox(szMessage,MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2); if (iResult!=IDYES) return TRUE; } //关闭房间 ActivePlazaViewItem(); CloseAllRoomViewItem(); //删除记录 g_GlobalUnits.DeleteUserCookie(); //设置变量 memset(&GlobalUserData,0,sizeof(GlobalUserData)); //投递消息 m_DlgGamePlaza.SendLogonMessage(); return TRUE; } case IDC_BT_LIST_CONTROL_1: //列表按钮 case IDC_BT_LIST_CONTROL_2: //列表按钮 { //隐藏列表 if(m_bHideGameList) { //隐藏按钮 m_btListControl1.ShowWindow(SW_HIDE); m_btListControl2.ShowWindow(SW_HIDE); m_ServerItemView.ShowWindow(SW_HIDE); m_UserCompanionList.ShowWindow(SW_HIDE); } //显示列表 else { //设置变量 m_wShowListType = nCommandID; //设置按钮 m_btListControl1.ShowWindow(SW_SHOW); m_btListControl2.ShowWindow(SW_SHOW); UINT uControl1=((IDC_BT_LIST_CONTROL_1==m_wShowListType)?GetPlatformRes().uFrameServiceBtShow1:GetPlatformRes().uFrameServiceBtHide1); UINT uControl2=((IDC_BT_LIST_CONTROL_2==m_wShowListType)?GetPlatformRes().uFrameServiceBtShow2:GetPlatformRes().uFrameServiceBtHide2); m_btListControl1.SetButtonImage(uControl1,GetResInstanceHandle(),false); m_btListControl2.SetButtonImage(uControl2,GetResInstanceHandle(),false); //判断显示 m_ServerItemView.ShowWindow((m_wShowListType==IDC_BT_LIST_CONTROL_1)?SW_SHOW:SW_HIDE); m_UserCompanionList.ShowWindow((m_wShowListType==IDC_BT_LIST_CONTROL_2)?SW_SHOW:SW_HIDE); } return TRUE; } } return __super::OnCommand(wParam,lParam); }
//建立消息 int CGameFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //设置属性 ModifyStyle(WS_CAPTION|WS_BORDER,0,0); //设置图标 HICON hIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MAINFRAME)); SetIcon(hIcon,TRUE); SetIcon(hIcon,FALSE); //设置标题 CString strTitle; strTitle.LoadString(AfxGetInstanceHandle(),IDS_MAIN_TITLE); SetWindowText(strTitle); //广告控件 m_BrowerAD.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),this,IDC_BROWER_AD,NULL); m_BrowerAD.Navigate(TEXT("http://127.0.0.1:8086/AD/GamePlazaAD.asp"),NULL,NULL,NULL,NULL); //拆分条控件 m_Splitter.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),this,IDC_SPLITTER,NULL); m_Splitter.SetSplitterSink(this); //用户视图 m_UserInfoView.Create(IDD_USER_INFO,this); m_UserInfoView.ShowWindow(SW_SHOW); //服务器视图 m_ServerItemView.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),this,IDC_SERVER_ITEM_VIEW); m_ServerItemView.InitServerItemView(this); g_GlobalUnits.m_ServerListManager.InitServerListManager(&m_ServerItemView); //好友列表 m_wShowListType = IDC_BT_LIST_CONTROL_1; m_UserCompanionList.Create(WS_CHILD,CRect(0,0,0,0),this,IDC_COMPANION_LIST); //创建按钮 m_btMin.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_MIN); m_btMax.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_MAX); m_btClose.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_CLOSE); m_btExChangeSkin.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_EXCHANGE_SINK); m_btExChangeSkin.ShowWindow(SW_HIDE); m_btButton1.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_BUTTON_1); m_btButton2.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_BUTTON_2); m_btButton3.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_BUTTON_3); m_btButton4.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_BUTTON_4); m_btButton5.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_BUTTON_5); m_btGamePlaza.Create(TEXT("游戏大厅"),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_PLAZA); m_btSelfOption.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_SELF_OPTION); m_btSwitchUser.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_SWITCH_ACCOUNTS); m_btGlobalOption.Create(TEXT(""),WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_SYSTEM_OPTION); m_btListControl1.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_LIST_CONTROL_1); m_btListControl2.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDC_BT_LIST_CONTROL_2); for (WORD i=0;i<CountArray(m_btViewItem);i++) { CRect rcCreate(0,0,0,0); m_btViewItem[i].Create(NULL,WS_CHILD,rcCreate,this,IDC_BT_VIEW_ITEM+i); } //皮肤资源 UpdateSkinResource(); //建立提示控件 m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(GetDlgItem(IDC_BT_MIN),TEXT("最小化游戏广场")); m_ToolTipCtrl.AddTool(GetDlgItem(IDC_BT_CLOSE),TEXT("退出游戏广场")); //创建控件 m_DlgGamePlaza.Create(IDD_GAME_PLAZA,this); ActivePlazaViewItem(); //注册热键 g_GlobalUnits.RegisterHotKey(m_hWnd,IDI_HOT_KEY_BOSS,g_GlobalOption.m_wBossHotKey); //窗口位置 CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); //显示窗口 MaxSizeWindow(); ShowWindow(SW_SHOW); //默认位置 m_rcNormalSize.left=(rcArce.Width()-LESS_SCREEN_X)/2; m_rcNormalSize.top=(rcArce.Height()-LESS_SCREEN_Y)/2; m_rcNormalSize.right=(rcArce.Width()+LESS_SCREEN_X)/2; m_rcNormalSize.bottom=(rcArce.Height()+LESS_SCREEN_Y)/2; return 0; }