static int cmd_rechan(ClientData cd_, Tcl_Interp* ip_, int objc_, Tcl_Obj*const* objv_) { ReflectingChannel *rc; int mode; char buffer [20]; if (objc_ != 3) { Tcl_WrongNumArgs(ip_, 1, objv_, "command mode"); return TCL_ERROR; } if (Tcl_ListObjLength(ip_, objv_[1], &mode) == TCL_ERROR || Tcl_GetIntFromObj(ip_, objv_[2], &mode) == TCL_ERROR) return TCL_ERROR; Tcl_MutexLock(&rechanMutex); sprintf(buffer, "rechan%d", ++mkChanSeq); Tcl_MutexUnlock(&rechanMutex); rc = rcCreate (ip_, objv_[1], mode, buffer); rc->_chan = Tcl_CreateChannel(&reChannelType, buffer, (ClientData) rc, mode); Tcl_RegisterChannel(ip_, rc->_chan); Tcl_SetChannelOption(ip_, rc->_chan, "-buffering", "none"); Tcl_SetChannelOption(ip_, rc->_chan, "-blocking", "0"); Tcl_SetResult(ip_, buffer, TCL_VOLATILE); return TCL_OK; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件区域 CRect CreateRect( 0, 0, 40, 30 ); //变量定义 enDirection Direction[]={Direction_North,Direction_East,Direction_South,Direction_West}; //设置控件 for (WORD i=0;i<4;i++) { //用户麻将 m_HeapCard[i].SetDirection(Direction[i]); m_TableCard[i].SetDirection(Direction[i]); m_DiscardCard[i].SetDirection(Direction[i]); //组合麻将 m_WeaveCard[i][0].SetDisplayItem(true); m_WeaveCard[i][1].SetDisplayItem(true); m_WeaveCard[i][2].SetDisplayItem(true); m_WeaveCard[i][3].SetDisplayItem(true); m_WeaveCard[i][0].SetDirection(Direction[i]); m_WeaveCard[i][1].SetDirection(Direction[i]); m_WeaveCard[i][2].SetDirection(Direction[i]); m_WeaveCard[i][3].SetDirection(Direction[i]); } //设置控件 m_UserCard[0].SetDirection(Direction_North); m_UserCard[1].SetDirection(Direction_East); m_UserCard[2].SetDirection(Direction_West); //创建控件 CRect rcCreate(0,0,0,0); m_GameScoreWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,100); m_ControlWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,10,NULL); //创建控件 m_btStart.Create(NULL,WS_CHILD,rcCreate,this,IDC_START); m_btStart.SetButtonImage(IDB_BT_START,AfxGetInstanceHandle(),false); //听按钮 m_btTingCard.Create(NULL,WS_CHILD,rcCreate,this,IDC_TING_CARD); m_btTingCard.SetButtonImage(IDB_BT_TING_CARD,AfxGetInstanceHandle(),false); //时钟控件 m_Timer.SetBitmap( IDB_TIMERBACK, IDB_TIMERARROW ); m_Timer.SetSinkWindow( AfxGetMainWnd() ); m_Timer.SetDesOrder( false ); m_Timer.Create( NULL, NULL, WS_VISIBLE|WS_CHILD, CreateRect, this, 20 ); m_Timer.ShowWindow( SW_HIDE); return 0; }
//启动服务 bool CServiceUnits::StartService() { //效验状态 ASSERT(m_ServiceStatus==ServiceStatus_Stop); if (m_ServiceStatus!=ServiceStatus_Stop) return false; //设置状态 SetServiceStatus(ServiceStatus_Config); //创建窗口 if (m_hWnd==NULL) { CRect rcCreate(0,0,0,0); Create(NULL,NULL,WS_CHILD,rcCreate,AfxGetMainWnd(),100); } //创建模块 if (CreateServiceDLL()==false) { ConcludeService(); return false; } //调整参数 if (RectifyServiceParameter()==false) { ConcludeService(); return false; } //配置服务 if (InitializeService()==false) { ConcludeService(); return false; } //启动内核 if (StartKernelService()==false) { ConcludeService(); return false; } //加载配置 SendControlPacket(CT_LOAD_SERVICE_CONFIG,NULL,0); //启动比赛 if (m_GameMatchServiceManager.GetInterface()!=NULL && m_GameMatchServiceManager->StartService()==false) return false; return true; }
//创建消息 INT CUserInfoView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; CRect rcCreate(0,0,0,0); m_btExchange.Create(NULL, WS_CHILD|WS_VISIBLE, rcCreate, this, IDC_EXCHANGE); m_btExchange.EnableWindow(FALSE); //加载资源 UpdateSkinResource(); return 0; }
//浏览函数 VOID CWebPublicize::Navigate(LPCTSTR pszURL, VARIANT * Flags, VARIANT * TargetFrameName, VARIANT * PostData, VARIANT * Headers) { //创建窗口 if (m_WebBrowser.m_hWnd==NULL) { CRect rcCreate(0,0,0,0); m_WebBrowser.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_WEB_BROWSER); } //浏览页面 m_WebBrowser.Navigate(pszURL,NULL,NULL,NULL,NULL); return; }
//浏览函数 VOID CWebPublicize::Navigate(LPCTSTR pszURL) { //创建窗口 if (m_WebBrowser.m_hWnd==NULL) { CRect rcCreate(0,0,0,0); m_WebBrowser.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_WEB_BROWSER); } //浏览页面 m_WebBrowser.Navigate(pszURL,NULL,NULL,NULL,NULL); return; }
//配置连接 bool CProcessControl::InitializeLink() { //效验参数 ASSERT(m_pIProcessControlSink!=NULL); if (m_pIProcessControlSink==NULL) return false; //创建窗口 if (m_hWnd==NULL) { CRect rcCreate(0,0,0,0); Create(NULL,NULL,WS_CHILD,rcCreate,GetDesktopWindow(),IDC_PROCESS_CONTROL); } return true; }
//建立消息 int CControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建按钮 CRect rcCreate(0,0,0,0); m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_GIVEUP); m_btChiHu.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_CHIHU); //设置位图 m_btChiHu.SetButtonImage(IDB_BT_CHIHU,AfxGetInstanceHandle(),false); m_btGiveUp.SetButtonImage(IDB_BT_GIVEUP,AfxGetInstanceHandle(),false); return 0; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件 CRect rcCreate(0,0,0,0); m_ScoreView.Create(IDD_GAME_SCORE,this); m_Prompt.Create(IDD_DIALOG2,this); m_GoldControl.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,8); //创建按钮 m_btStart.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_START); m_btExit.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_EXIT); m_btAdd.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_ADD); m_btGiveUp.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_GIVEUP); m_btShowHand.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_SHOWHAND); m_btFollow.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_FOLLOW); m_btPassCard.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_PASS); m_btAutoStart.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_AUTO_START); m_btOpenCard.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_OPEN_CARD); for(int i=0;i<GAME_PLAYER;i++) m_btSitDown[i].Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_SIT_DOWN+i); //加载位图 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btStart.SetButtonImage(IDB_BT_START,hInstance,false); m_btExit.SetButtonImage(IDB_BT_EXIT,hInstance,false); m_btAdd.SetButtonImage(IDB_BT_ADD,hInstance,false); m_btGiveUp.SetButtonImage(IDB_BT_GIVEUP,hInstance,false); m_btShowHand.SetButtonImage(IDB_BT_SHOWHAND,hInstance,false); m_btFollow.SetButtonImage(IDB_BT_FOLLOW,hInstance,false); m_btPassCard.SetButtonImage(IDB_BT_PASS_CARD,hInstance,false); m_btAutoStart.SetButtonImage(IDB_AUTO_START_FALSE,hInstance,false); m_btOpenCard.SetButtonImage(IDB_BT_OPEN_CARD,hInstance,false); for(int i=0;i<GAME_PLAYER;i++) m_btSitDown[i].SetButtonImage(IDB_BT_SITDOWN,hInstance,false); m_CenterCardControl.SetDisplayItem(true); //用户扑克 for (WORD i=0;i<GAME_PLAYER;i++) { m_CardControl[i].SetDisplayItem(true); m_SmallCardControl[i].SetCardDistance(5,0,0); } m_CenterCardControl.SetCardDistance(57+10,0,0); return 0; }
//建立消息 INT CControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建按钮 CRect rcCreate(0,0,0,0); m_btMaxScore.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_MAX_SCORE); m_btLessScore.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_LESS_SCORE); //设置按钮 HINSTANCE hResInstance=AfxGetInstanceHandle(); m_btMaxScore.SetButtonImage(IDB_BT_CONTROL_MAX,hResInstance,false); m_btLessScore.SetButtonImage(IDB_BT_CONTROL_LESS,hResInstance,false); return 0; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件 CRect rcCreate(0,0,0,0); m_GoldControl.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS,CRect(50,50,66,66),this,8); m_ScoreView.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,rcCreate,this,10); //创建按钮 m_btStart.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_START); m_btMaxScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_MAX_SCORE); m_btMinScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_MIN_SCORE); m_btConfirm.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_CONFIRM); m_btCancel.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_CANCEL_ADD); m_btOpenCard.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_OPEN_CARD); m_btAddScore.Create(TEXT(""),WS_CHILD|WS_DISABLED,rcCreate,this,IDC_ADD_SCORE); m_btCompareCard.Create(TEXT(""),WS_CHILD|WS_DISABLED,rcCreate,this,IDC_COMPARE_CARD); m_btGiveUp.Create(TEXT(""),WS_CHILD|WS_DISABLED,rcCreate,this,IDC_GIVE_UP); m_btLookCard.Create(TEXT(""),WS_CHILD|WS_DISABLED,rcCreate,this,IDC_LOOK_CARD); m_btFollow.Create(TEXT(""),WS_CHILD|WS_DISABLED,rcCreate,this,IDC_FOLLOW); //加载位图 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btStart.SetButtonImage(IDB_START,hInstance,false); m_btMaxScore.SetButtonImage(IDB_USERCONTROL_MAX,hInstance,false); m_btMinScore.SetButtonImage(IDB_USERCONTROL_MIN,hInstance,false); m_btAddScore.SetButtonImage(IDB_USERCONTROL_INVEST,hInstance,false); m_btConfirm.SetButtonImage(IDB_CONFIRM,hInstance,false); m_btCancel.SetButtonImage(IDB_USERCONTROL_CLEAR,hInstance,false); m_btCompareCard.SetButtonImage(IDB_COMPARE_CARD,hInstance,false); m_btOpenCard.SetButtonImage(IDB_OPEN_CARD,hInstance,false); m_btGiveUp.SetButtonImage(IDB_GIVE_UP,hInstance,false); m_btLookCard.SetButtonImage(IDB_LO0K_CARD,hInstance,false); m_btFollow.SetButtonImage(IDB_FOLLOW,hInstance,false); //创建控件 for (WORD i=0;i<GAME_PLAYER;i++) { m_CardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,rcCreate,this,20+i); m_CardControl[i].SetCommandID(i,IDM_COMPARE_USER); } return 0; }
//创建函数 BOOL CDlgCustomFace::OnInitDialog() { __super::OnInitDialog(); //获取大小 CRect rcClient; GetClientRect(&rcClient); //设置标题 SetWindowText(TEXT("更换头像")); //变量定义 CGlobalUserInfo * pGlobalUserInfo=CGlobalUserInfo::GetInstance(); tagGlobalUserData * pGlobalUserData=pGlobalUserInfo->GetGlobalUserData(); //设置变量 m_wFaceID=pGlobalUserData->wFaceID; CopyMemory(&m_CustomFaceInfo,&pGlobalUserData->CustomFaceInfo,sizeof(m_CustomFaceInfo)); //设置控件 m_FaceItemSelectWnd.SetAllowItemFull(); //设置控件 m_TabControl.SetItemSize(CSize(150,25)); // m_TabControl.InsertItem(FACE_CUSTOM_EDIT,TEXT(" 自定头像 ")); m_TabControl.InsertItem(FACE_SELECT_ITEM,TEXT(" 系统头像 ")); //创建窗口 CRect rcCreate(0,0,0,0); m_FaceItemSelectWnd.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rcCreate,&m_TabControl,IDC_FACE_SELECT_WND); m_FaceItemCustomWnd.Create(NULL,NULL,WS_CHILD,rcCreate,&m_TabControl,IDC_FACE_CUSTOM_WND); //调整位置 CRect rcTabCtrl(10,40,rcClient.Width()-110,rcClient.Height()-45); m_FaceItemCustomWnd.SetWindowPos(NULL,1,27,rcTabCtrl.Width()-2,rcTabCtrl.Height()-28,SWP_NOZORDER); m_FaceItemSelectWnd.SetWindowPos(NULL,1,27,rcTabCtrl.Width()-2,rcTabCtrl.Height()-28,SWP_NOZORDER); m_TabControl.SetWindowPos(NULL,rcTabCtrl.left,rcTabCtrl.top,rcTabCtrl.Width(),rcTabCtrl.Height(),SWP_NOZORDER); m_btOk.GetWindowRect(&rcCreate); m_btOk.MoveWindow(rcClient.Width()-246,rcClient.Height()-32,rcCreate.Width(),rcCreate.Height(),SWP_NOZORDER|SWP_NOMOVE); m_btCancel.MoveWindow(rcClient.Width()-146,rcClient.Height()-32,rcCreate.Width(),rcCreate.Height(),SWP_NOZORDER|SWP_NOMOVE); return TRUE; }
//创建窗口 bool CGameFrameView::CreateGameViewWnd(CWnd * pParentWnd, UINT nID) { //效验状态 ASSERT(m_hWnd==NULL); if (m_hWnd!=NULL) return false; //获取对象 ASSERT(CGlobalUnits::GetInstance()!=NULL); CGlobalUnits * pGlobalUnits=CGlobalUnits::GetInstance(); //创建窗口 CRect rcCreate(0,0,0,0); Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,rcCreate,pParentWnd,nID); //查询接口 m_pIGameLevelParser=(IGameLevelParser *)pGlobalUnits->QueryGlobalModule(MODULE_GAME_LEVEL_PARSER,IID_IGameLevelParser,VER_IGameLevelParser); return true; }
//建立消息 int CHuCardDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; ////移动窗口 //CImageHandle BackImageHandle(&m_ImageBack); //SetWindowPos(NULL,0,0,m_ImageBack.GetWidth(),m_ImageBack.GetHeight(),SWP_NOZORDER|SWP_NOREPOSITION); //创建按钮 CRect rcCreate(0,0,0,0); m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_GIVEUP); m_btChiHu.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_CHIHU); //设置位图 m_btChiHu.SetButtonImage(IDB_BT_CHIHU,AfxGetInstanceHandle(),false); m_btGiveUp.SetButtonImage(IDB_BT_GIVEUP,AfxGetInstanceHandle(),false); return TRUE; }
//建立消息 INT CWndUserInfoCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //注册事件 CPlatformEvent * pPlatformEvent=CPlatformEvent::GetInstance(); if (pPlatformEvent!=NULL) pPlatformEvent->RegisterEventWnd(m_hWnd); //加载资源 CBitImage ImageTitleM; ImageTitleM.LoadFromResource(AfxGetInstanceHandle(),IDB_USER_INFO_M); //创建按钮 CRect rcCreate(0,0,0,0); m_btUserInfo1.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_1); m_btUserInfo2.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_2); m_btUserInfo3.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_3); m_btUserInfoSet.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,rcCreate,this,IDC_USER_INFO_SET); //设置按钮 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btUserInfo1.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_1"),hInstance,true,false); m_btUserInfo2.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_2"),hInstance,true,false); m_btUserInfo3.SetButtonImage(IDB_BK_USER_INFO,TEXT("BT_USER_INFO_3"),hInstance,true,false); m_btUserInfoSet.SetButtonImage(IDB_BK_USER_INFO_SET,TEXT("BT_USER_INFO_SET"),hInstance,true,false); //移动窗口 CRect rcUserInfo; GetWindowRect(&rcUserInfo); SetWindowPos(NULL,0,0,rcUserInfo.Width(),ImageTitleM.GetHeight(),SWP_NOMOVE|SWP_NOZORDER); //提示控件 m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(&m_btUserInfo1,TEXT("上传头像")); m_ToolTipCtrl.AddTool(&m_btUserInfo2,TEXT("锁定本机")); m_ToolTipCtrl.AddTool(&m_btUserInfo3,TEXT("魅力兑换")); m_ToolTipCtrl.AddTool(&m_btUserInfoSet,TEXT("个人信息设置")); return 0; }
//创建函数 BOOL CDlgBrowser::OnInitDialog() { __super::OnInitDialog(); //设置标题 SetWindowText(m_strWindowTitle); //设置资源 AfxSetResourceHandle(GetModuleHandle(NULL)); //创建控件 CRect rcCreate(0,0,0,0); m_WebPublicize.Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,rcCreate,this,IDC_BROWSER); //调整大小 if ((m_SizeWindow.cx>0)&&(m_SizeWindow.cy>0)) { SetWindowPos(NULL,0,0,m_SizeWindow.cx,m_SizeWindow.cy,SWP_NOZORDER|SWP_NOMOVE); } //居中窗口 CenterWindow(); //调整控件 CRect rcClient; GetClientRect(&rcClient); RectifyControl(rcClient.Width(),rcClient.Height()); //构造地址 CGlobalServer * pGlobalServer=CGlobalServer::GetInstance(); TCHAR szBrowser[256]=TEXT(""); _sntprintf(szBrowser,CountArray(szBrowser),TEXT("%s/%s"),pGlobalServer->GetPlatformServer(3),m_strBrowserURL); //连接页面 m_WebPublicize.Navigate(szBrowser,NULL,NULL,NULL,NULL); return FALSE; }
//内核配置 bool __cdecl CClientKernel::InitClientKernel(LPCTSTR lpszComLine, IUnknownEx * pIUnknownEx) { //效验参数 ASSERT(lpszComLine!=NULL); if (lpszComLine==NULL) return false; //创建窗口 if (m_hWnd==NULL) { CRect rcCreate(0,0,0,0); Create(NULL,NULL,WS_CHILD,rcCreate,GetDesktopWindow(),100); } //获取框架 m_pIClientKernelSink=GET_OBJECTPTR_INTERFACE(pIUnknownEx,IClientKernelSink); if (m_pIClientKernelSink==NULL) return false; m_hWndGameFrame=m_pIClientKernelSink->GetFrameWnd(); //读取配置 m_bAllowUserLookon=AfxGetApp()->GetProfileInt(TEXT("GameOption"),TEXT("AllowLookon"),FALSE)?true:false; //视频设置 CVideoServiceManager * pVideoServiceManager=CVideoServiceManager::GetInstance(); if (pVideoServiceManager!=NULL) pVideoServiceManager->SetClientKernel(GET_OBJECTPTR_INTERFACE(this,IUnknownEx)); //命令行处理 if (lpszComLine[0]!=0) { //提出 TOKEN int nStringLength=0; CString strRoomToken; LPCTSTR pszRoomToken=TEXT("/RoomToken:"); LPCTSTR lpszBeginString=lpszComLine; while (true) { LPCTSTR lpszEndString=_tcschr(lpszBeginString,TEXT(' ')); nStringLength=(lpszEndString==NULL)?lstrlen(lpszBeginString):(int)(lpszEndString-lpszBeginString); //判断标识 const int nTokenLength=lstrlen(pszRoomToken); if ((nStringLength>=nTokenLength)&&(memcmp(lpszBeginString,pszRoomToken,nTokenLength*sizeof(TCHAR))==0)) { CopyMemory(strRoomToken.GetBufferSetLength(nStringLength-nTokenLength),lpszBeginString+nTokenLength, (nStringLength-nTokenLength)*sizeof(TCHAR)); strRoomToken.ReleaseBuffer(); break; } //设置变量 if (lpszEndString==NULL) break; lpszBeginString=(lpszEndString+1); } //共享内存 if (strRoomToken.GetLength()>0) { m_hShareMemory=OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,strRoomToken); if (m_hShareMemory==NULL) return false; m_pShareMemory=(tagShareMemory *)MapViewOfFile(m_hShareMemory,FILE_MAP_ALL_ACCESS,0,0,0); if (m_pShareMemory==NULL) return false; if (m_pShareMemory->wDataSize<sizeof(tagShareMemory)) return false; m_pShareMemory->hWndGameFrame=m_hWndGameFrame; } //信道模块 if (m_hShareMemory!=NULL) { ASSERT(m_pShareMemory->hWndGameServer!=NULL); IUnknownEx * pIUnknownEx=GET_MYSELF_INTERFACE(IUnknownEx); if (m_ChannelServiceHelper.CreateInstance()==false) return false; if (m_ChannelServiceHelper->SetChannelMessageSink(pIUnknownEx)==false) return false; if (m_ChannelServiceHelper->CreateChannel(m_pShareMemory->hWndGameServer)==false) return false; } } //更新标题 UpdateGameTitle(); return true; }
//配置函数 BOOL CDlgEnquire::OnInitDialog() { __super::OnInitDialog(); //设置标题 SetWindowText(TEXT("温馨提示")); //加载资源 CPngImage ImageBack; ImageBack.LoadImage(AfxGetInstanceHandle(),TEXT("DLG_ENQUIRE_BACK")); //设置大小 CSize SizeWindow(ImageBack.GetWidth(),ImageBack.GetHeight()); SetWindowPos(NULL,0,0,SizeWindow.cx,SizeWindow.cy,SWP_NOZORDER|SWP_NOMOVE|SWP_NOREDRAW); //控制按钮 CPlatformFrame * pPlatformFrame=CPlatformFrame::GetInstance(); //m_btCloseServer.EnableWindow((pPlatformFrame->GetActiveItem()>=1)?TRUE:FALSE); //设置按钮 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btCancel.SetButtonImage(IDB_BT_ENQUIRE_CANCEL,hInstance,false,false); m_btClosePlaza.SetButtonImage(IDB_BT_ENQUIRE_PLAZA,hInstance,false,false); m_btCloseServer.SetButtonImage(IDB_BT_ENQUIRE_SERVER,hInstance,false,false); m_btSwitchAccounts.SetButtonImage(IDB_BT_ENQUIRE_SWITCH,hInstance,false,false); //关闭按钮 CRect rcCancel; m_btCancel.GetWindowRect(&rcCancel); m_btCancel.SetWindowPos(NULL,SizeWindow.cx-rcCancel.Width()-8,3,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW); //按钮大小 CRect rcButton; m_btClosePlaza.GetWindowRect(&rcButton); //功能按钮 INT nButtonSpace=(SizeWindow.cx-rcButton.Width()*3-2*LAYERED_SIZE)/4; m_btClosePlaza.SetWindowPos(NULL,LAYERED_SIZE+nButtonSpace*3+rcButton.Width()*2,158,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW); m_btCloseServer.SetWindowPos(NULL,LAYERED_SIZE+nButtonSpace*2+rcButton.Width()*1,158,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW); m_btSwitchAccounts.SetWindowPos(NULL,LAYERED_SIZE+nButtonSpace*1+rcButton.Width()*0,158,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW); //广告控件 CRect rcCreate(0,0,0,0); //m_PlatformPublicize.SetBackColor(RGB(19,69,103)); m_PlatformPublicize.Create(NULL,NULL,WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN,rcCreate,this,IDC_WEB_PUBLICIZE); //变量定义 CGlobalUnits * pGlobalUnits = (CGlobalUnits *)CGlobalUnits::GetInstance(); ASSERT(pGlobalUnits!=NULL); //工作目录 TCHAR szDirectory[MAX_PATH]=TEXT(""); CWHService::GetWorkDirectory(szDirectory,CountArray(szDirectory)); //构造地址 TCHAR szBillUrl[256]=TEXT(""); _sntprintf(szBillUrl,CountArray(szBillUrl),TEXT("%s\\Web\\LobbyTopNotice.htm"),szDirectory); //设置广告 if(pGlobalUnits!=NULL && pGlobalUnits->LocalFileExist(szBillUrl)) { m_PlatformPublicize.Navigate(szBillUrl); m_PlatformPublicize.SetWindowPos(NULL,50,9,SizeWindow.cx-100,18,SWP_NOZORDER|SWP_NOCOPYBITS|SWP_NOACTIVATE); } else m_PlatformPublicize.SetWindowPos(NULL,50,9,SizeWindow.cx-100,18,SWP_NOZORDER|SWP_NOCOPYBITS|SWP_HIDEWINDOW|SWP_NOACTIVATE); //居中窗口 CenterWindow(this); //获取窗口 CRect rcWindow; GetWindowRect(&rcWindow); //计算位置 CRect rcUnLayered; rcUnLayered.top=LAYERED_SIZE; rcUnLayered.left=LAYERED_SIZE; rcUnLayered.right=rcWindow.Width()-LAYERED_SIZE; rcUnLayered.bottom=rcWindow.Height()-LAYERED_SIZE; //设置区域 CRgn RgnWindow; RgnWindow.CreateRoundRectRgn(LAYERED_SIZE,LAYERED_SIZE,SizeWindow.cx-LAYERED_SIZE+1,SizeWindow.cy-LAYERED_SIZE+1,ROUND_CX,ROUND_CY); //设置区域 SetWindowRgn(RgnWindow,FALSE); //分层窗口 m_SkinLayered.CreateLayered(this,rcWindow); m_SkinLayered.InitLayeredArea(ImageBack,255,rcUnLayered,CPoint(ROUND_CX,ROUND_CY),false); return FALSE; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件 CRect rcCreate(0,0,0,0); //m_GoldControl.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS,CRect(50,50,66,66),this,8); m_ScoreView.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,rcCreate,this,10); //创建按钮 m_btHintOx.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_HINT_OX); m_btStart.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_START); m_btReSort.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_RESORT); m_btOpenCard.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_READY); m_btOx.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_OX); m_btShortcut.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_SHORTCUT); m_btOneScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_ONE_SCORE); m_btTwoScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_TWO_SCORE); m_btThreeScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_THREE_SCORE); m_btFourScore.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_FOUR_SCORE); m_btBanker.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_BANKER); m_btIdler.Create(TEXT(""),WS_CHILD,rcCreate,this,IDC_IDLER); m_btOpenAdmin.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(4,4,11,11),this,IDC_BT_ADMIN); m_btOpenAdmin.ShowWindow(SW_HIDE); m_AdminDlg.Create(IDD_DIALOG_ADMIN,this); m_AdminDlg.ShowWindow(SW_HIDE); // m_btBegin.Create(TEXT(""), WS_CHILD, CRect(0,0,50,50),this, IDC_BT_BEGIN); //加载位图 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btHintOx.SetButtonImage(IDB_HINT_OX,hInstance,false); m_btStart.SetButtonImage(IDB_START,hInstance,false); m_btReSort.SetButtonImage(IDB_RESOCT,hInstance,false); m_btOpenCard.SetButtonImage(IDB_OPENCARD,hInstance,false); m_btOx.SetButtonImage(IDB_COW,hInstance,false); m_btShortcut.SetButtonImage(IDB_ShortCut,hInstance,false); m_btOneScore.SetButtonImage(IDB__MONEY,hInstance,false); m_btTwoScore.SetButtonImage(IDB__MONEY,hInstance,false); m_btThreeScore.SetButtonImage(IDB__MONEY,hInstance,false); m_btFourScore.SetButtonImage(IDB__MONEY,hInstance,false); m_btBanker.SetButtonImage(IDB_BANKER,hInstance,false); m_btIdler.SetButtonImage(IDB_IDLER,hInstance,false); //创建控件 for (WORD i=0;i<GAME_PLAYER;i++) { m_CardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,rcCreate,this,20+i); m_CardControlOx[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,rcCreate,this,20+GAME_PLAYER+i); m_CardControlOx[i].SetDrawHeight(30); } //按钮提示 m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); m_ToolTipCtrl.AddTool(&m_btShortcut,TEXT("牛提示快捷键")); #ifdef VIDEO_GAME //创建视频 for (WORD i=0;i<GAME_PLAYER;i++) { //创建视频 m_DlgVideoService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,200+i); m_DlgVideoService[i].InitVideoService(i==2,i!=2); //设置视频 g_VideoServiceManager.SetVideoServiceControl(i,&m_DlgVideoService[i]); } #endif return 0; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件 CRect rcCreate(0,0,0,0); m_ScoreView.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,10); m_GoldControl.Create(NULL,NULL,WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,40); //创建按钮 m_btStart.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_START); m_btNoAdd.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_NO_ADD); m_btFollow.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_FOLLOW); m_btGiveUp.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_GIVE_UP); m_btShowHand.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_SHOW_HAND); m_btAddScore.Create(TEXT(""),WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,IDC_ADD_SCORE); //加载位图 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btStart.SetButtonImage(IDB_BT_START,hInstance,false); m_btNoAdd.SetButtonImage(IDB_BT_BUJIA,hInstance,false); m_btFollow.SetButtonImage(IDB_BT_FOLLOW,hInstance,false); m_btGiveUp.SetButtonImage(IDB_BT_FANGQI,hInstance,false); m_btShowHand.SetButtonImage(IDB_BT_SOHA,hInstance,false); m_btAddScore.SetButtonImage(IDB_BT_JIAZHU,hInstance,false); //创建控件 for (WORD i=0;i<GAME_PLAYER;i++) { m_CardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS,rcCreate,this,20+i); } // m_PlayerJeton[GAME_PLAYER].SetDrawMode(enDrawMode_Rand); //test //BYTE byCard[] = //{ // 0x01,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K // 0x11,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K // 0x21,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K // 0x31,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //}; //for( WORD i = 0; i < GAME_PLAYER; i++ ) //{ // m_CardControl[i].SetCardData(byCard,5); // m_PlayerJeton[i].SetScore(123456L); // m_lTableScore[i] = 10000L; //} //m_PlayerJeton[GAME_PLAYER].SetScore(123456L); ////m_btStart.ShowWindow(SW_SHOW); //m_btNoAdd.ShowWindow(SW_SHOW); //m_btFollow.ShowWindow(SW_SHOW); //m_btGiveUp.ShowWindow(SW_SHOW); //m_btShowHand.ShowWindow(SW_SHOW); //m_btAddScore.ShowWindow(SW_SHOW); //for( i = 0; i < GAME_PLAYER; i++ ) //{ // m_ScoreView.SetGameScore(i,TEXT("S"),(i%2!=0)?1L:-1L); // m_ScoreView.SetGameTax(i,i%2==0?-1:1); //} //m_ScoreView.SetGameScore(2,TEXT("sssssssssssS"),0); //m_ScoreView.ShowWindow(SW_SHOW); //m_lCellScore = 93L; //m_GoldControl.SetCellScore(93L); //m_GoldControl.ShowWindow(SW_SHOW); ////end test return 0; }
//建立消息 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; }
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; }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct)==-1) return -1; //变量定义 enDirection Direction[]={Direction_North,Direction_East,Direction_South,Direction_West}; //设置控件 for (WORD i=0;i<4;i++) { //用户扑克 m_HeapCard[i].SetDirection(Direction[i]); m_TableCard[i].SetDirection(Direction[i]); m_DiscardCard[i].SetDirection(Direction[i]); //组合扑克 m_WeaveCard[i][0].SetDisplayItem(true); m_WeaveCard[i][1].SetDisplayItem(true); m_WeaveCard[i][2].SetDisplayItem(true); m_WeaveCard[i][3].SetDisplayItem(true); m_WeaveCard[i][0].SetDirection(Direction[i]); m_WeaveCard[i][1].SetDirection(Direction[i]); m_WeaveCard[i][2].SetDirection(Direction[i]); m_WeaveCard[i][3].SetDirection(Direction[i]); } //设置控件 m_UserCard[0].SetDirection(Direction_North); m_UserCard[1].SetDirection(Direction_East); m_UserCard[2].SetDirection(Direction_West); //创建控件 CRect rcCreate(0,0,0,0); m_ControlWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,10,NULL); m_DrawSiceWnd.Create(NULL,NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,11,NULL); m_DrawSiceWnd.SetWindowSink(AfxGetMainWnd()); //创建控件 m_btStart.Create(NULL,WS_CHILD|WS_CLIPCHILDREN,rcCreate,this,IDC_START); m_btStart.SetButtonImage(IDB_BT_START,AfxGetInstanceHandle(),false); //托管按钮 m_btStusteeControl.Create(TEXT(""),WS_CHILD|WS_DISABLED|WS_VISIBLE,rcCreate,this,IDC_TRUSTEE_CONTROL); m_btStusteeControl.SetButtonImage(IDB_BT_START_TRUSTEE,AfxGetInstanceHandle(),false); SetTimer(IDI_DISC_EFFECT,250,NULL); //test //m_btStart.ShowWindow( SW_SHOW ); //BYTE byCard[] = { // 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, // 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, // 0x01,0x02,0x03,0x04,0x05,0x06 //}; //BYTE byCardCount = 14; //m_HandCardControl.SetDisplayItem(true); //m_HandCardControl.SetPositively(true); //m_HandCardControl.SetCardData(byCard,MAX_COUNT-1-3,byCard[MAX_COUNT-1]); //for( BYTE i = 0; i < GAME_PLAYER; i++ ) //{ // m_HeapCard[i].SetCardData(0,0,HEAP_FULL_COUNT); // m_TableCard[i].SetCardData(byCard,byCardCount); // m_DiscardCard[i].SetCardData(byCard,byCardCount); // m_WeaveCard[i][0].SetCardData(byCard,3); // if( i < 3 ) // m_UserCard[i].SetCardData(MAX_COUNT-1,false); // m_bTrustee[i] = true; // m_cbUserAction[i] = WIK_PENG; // m_cbWinOrder[i] = i+1; //} //m_bWaitOther = true; //m_bOutCard = true; //m_wOutCardUser = 0; //m_cbCardData = 0x01; //m_cbUserAction[0] = WIK_NULL; //m_wDiscUser = 1; //SetBombEffect(true); //tagScoreInfo si; //ZeroMemory( &si,sizeof(si) ); //for( WORD i = 0; i < GAME_PLAYER; i++ ) // lstrcpy( si.szUserName[i],TEXT("杨杨得意") ); //for( WORD i = 0; i < GAME_PLAYER; i++ ) //{ // si.wMeChairId = i; // si.cbGenCount = i+1; // si.cbWinOrder= i+1; // if( i%2==0 ) // { // si.dwChiHuRight[0] = CHR_QING_LONG_QI_DUI; // si.lGameScore = 1234L; // } // else si.lGameScore = -1234L; // si.wLostFanShu[(i+1)%GAME_PLAYER] = 5; // si.wLostFanShu[(i+2)%GAME_PLAYER] = 6; // si.lGameTax = 1234L; // si.lGangScore = 124L; // si.wProvideUser = 3; // m_ScoreControl[i].SetScoreInfo( si ); //} //end test return 0; }
//创建函数 INT CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (__super::OnCreate(lpCreateStruct) == -1) return -1; //创建控件 CRect rcCreate(0, 0, 0, 0); m_ScoreControl.Create(NULL, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rcCreate, this, 100); m_ManualList.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY, rcCreate, this, IDC_MANUAL_LIST); //设置控件 m_UserRequestPeace.m_cbRequestType = REQUEST_PEACE; m_UserRequestRegret.m_cbRequestType = REQUEST_REGRET; //m_ManualList.SetFont(&CSkinResourceManager::GetDefaultFont()); //控制按钮 m_btManual.Create(NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, rcCreate, this, IDC_MANUAL); m_btStart.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_START); m_btPeace.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_PEACE); m_btRegret.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_REGRET); m_btGiveUp.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_GIVEUP); m_btPreserve.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS, rcCreate, this, IDC_PRESERVE); //棋谱按钮 m_btManualOpen.Create(NULL, WS_CHILD | WS_VISIBLE, rcCreate, this, IDC_MANUAL_BT_OPEN); m_btManualHead.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_HEAD); m_btManualLast.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_LAST); m_btManualNext.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_NEXT); m_btManualTail.Create(NULL, WS_CHILD | WS_VISIBLE | WS_DISABLED, rcCreate, this, IDC_MANUAL_BT_TAIL); //控制按钮 HINSTANCE hResInstance = AfxGetInstanceHandle(); m_btStart.SetButtonImage(IDB_BT_START, hResInstance, false); m_btPeace.SetButtonImage(IDB_BT_PEACE, hResInstance, false); m_btManual.SetButtonImage(IDB_BT_MANUAL, hResInstance, false); m_btGiveUp.SetButtonImage(IDB_BT_GIVEUP, hResInstance, false); m_btRegret.SetButtonImage(IDB_BT_REGRET, hResInstance, false); m_btPreserve.SetButtonImage(IDB_BT_PRESERVE, hResInstance, false); //棋谱按钮 m_btManualHead.SetButtonImage(IDB_MANUAL_BT_HEAD, hResInstance, false); m_btManualNext.SetButtonImage(IDB_MANUAL_BT_NEXT, hResInstance, false); m_btManualTail.SetButtonImage(IDB_MANUAL_BT_TAIL, hResInstance, false); m_btManualOpen.SetButtonImage(IDB_MANUAL_BT_OPEN, hResInstance, false); m_btManualLast.SetButtonImage(IDB_MANUAL_BT_LAST, hResInstance, false); //建立提示 m_ToolTipCtrl.Create(this); m_ToolTipCtrl.Activate(TRUE); //控制提示 m_ToolTipCtrl.AddTool(&m_btStart, TEXT("开始")); m_ToolTipCtrl.AddTool(&m_btPeace, TEXT("求和")); m_ToolTipCtrl.AddTool(&m_btManual, TEXT("棋谱")); m_ToolTipCtrl.AddTool(&m_btGiveUp, TEXT("认输")); m_ToolTipCtrl.AddTool(&m_btRegret, TEXT("悔棋")); m_ToolTipCtrl.AddTool(&m_btPreserve, TEXT("保存")); //棋谱提示 m_ToolTipCtrl.AddTool(&m_btManualHead, TEXT("最前")); m_ToolTipCtrl.AddTool(&m_btManualLast, TEXT("前一步")); m_ToolTipCtrl.AddTool(&m_btManualOpen, TEXT("打开棋谱")); m_ToolTipCtrl.AddTool(&m_btManualNext, TEXT("下一步")); m_ToolTipCtrl.AddTool(&m_btManualTail, TEXT("最后")); #ifdef VIDEO_GAME //创建视频 for (WORD i = 0; i < GAME_PLAYER; i++) { //创建视频 m_DlgVideoService[i].Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rcCreate, this, 200 + i); m_DlgVideoService[i].InitVideoService(i == 1, i == 1); //设置视频 g_VideoServiceManager.SetVideoServiceControl(i, &m_DlgVideoService[i]); } #endif //创建窗口 //CDlgUserRequest * pDlgUserHint=&m_UserRequestRegret; //if (pDlgUserHint->m_hWnd==NULL) pDlgUserHint->Create(IDD_USER_REQUEST,this); ////显示窗口 //pDlgUserHint->ShowWindow(SW_SHOW); //pDlgUserHint->SetForegroundWindow(); ////创建窗口 //CDlgHint * pDlgUserHint=&m_UserHint; //if (pDlgUserHint->m_hWnd==NULL) pDlgUserHint->Create(IDD_USER_HINT,this); //////显示窗口 //pDlgUserHint->ShowWindow(SW_SHOW); //pDlgUserHint->SetForegroundWindow(); //m_ScoreControl.ShowWindow(5); return 0; }
//建立消息 INT CGameFrameWnd::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); //变量定义 ASSERT(CGlobalUnits::GetInstance()!=NULL); CGlobalUnits * pGlobalUnits=CGlobalUnits::GetInstance(); //查询接口 m_pIClientKernel=(IClientKernel *)pGlobalUnits->QueryGlobalModule(MODULE_CLIENT_KERNEL,IID_IClientKernel,VER_IClientKernel); m_pIGameFrameView=(IGameFrameView *)pGlobalUnits->QueryGlobalModule(MODULE_GAME_FRAME_VIEW,IID_IGameFrameView,VER_IGameFrameView); //创建按钮 CRect rcCreate(0,0,0,0); 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_btOption.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_OPTION); m_btMuteContrl.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_MUTE); m_btRule.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_RULE); m_btControl.Create(NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_CONTROL); //设置按钮 HINSTANCE hInstance=GetModuleHandle(GAME_FRAME_DLL_NAME); m_btMin.SetButtonImage(IDB_BT_MIN,hInstance,false,false); m_btMax.SetButtonImage(IDB_BT_MAX,hInstance,false,false); m_btClose.SetButtonImage(IDB_BT_CLOSE,TEXT("BT_CLOSE"),hInstance,false,false); m_btOption.SetButtonImage(IDB_BT_OPTION,hInstance,false,false); m_btMuteContrl.SetButtonImage((pGlobalUnits->m_bMuteStatuts==false)?IDB_BT_MUTE:IDB_BT_SLIENT,hInstance,false,false); m_btRule.SetButtonImage(IDB_BT_RULE,hInstance,false,false); m_btControl.SetButtonImage(IDB_BT_CONTROL_BACK,(m_bShowControl==false)?TEXT("BT_GAME_LIST_SHOW"):TEXT("BT_GAME_LIST_HIDE"),hInstance,true,false); //控制窗口 AfxSetResourceHandle(hInstance); m_GameFrameControl.Create(IDD_GAME_CONTROL,this); m_SkinSplitter.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,rcCreate,this,IDC_SKIN_SPLITTER); //提示控件 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("关闭游戏")); //设置位置 CSize SizeRestrict; SizeRestrict.SetSize(LESS_SCREEN_CX,LESS_SCREEN_CY); //设置分辨率 m_ScreenMetrics.cx = ::GetSystemMetrics(SM_CXSCREEN); m_ScreenMetrics.cy = ::GetSystemMetrics(SM_CYSCREEN); //窗口位置 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); //创建视图 ASSERT(m_pIGameFrameView!=NULL); if (m_pIGameFrameView!=NULL) m_pIGameFrameView->CreateGameViewWnd(this,IDC_GAME_CLIENT_VIEW); //动画控件 IUnknownEx * pIUnknownEx=QUERY_ME_INTERFACE(IFlashControlSink); m_FlashControl.CreateControl(this,CRect(0,0,FALSH_MOVIE_CX,FALSH_MOVIE_CY),pIUnknownEx); m_FlashControl.ShowControl(SW_HIDE); //设置控件 m_btControl.SetParent(&m_SkinSplitter); m_SkinSplitter.SetSplitterEvent(this); m_SkinSplitter.SetSplitterType(SplitterType_Vor); m_SkinSplitter.SetSplitterColor(RGB(165,113,0)); //注册接口 m_pIClientKernel->SetClientPropertySink(QUERY_ME_INTERFACE(IClientPropertySink)); //显示窗口 //MaxSizeWindow(); //设置滚动 m_SkinScrollBar.InitScroolBar(this); return 0L; }