當前位置: 首頁>>代碼示例>>C++>>正文


C++ AfxGetMainWnd函數代碼示例

本文整理匯總了C++中AfxGetMainWnd函數的典型用法代碼示例。如果您正苦於以下問題:C++ AfxGetMainWnd函數的具體用法?C++ AfxGetMainWnd怎麽用?C++ AfxGetMainWnd使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AfxGetMainWnd函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: AfxGetMainWnd

//叫分按鈕
void CGameClientView::OnBrightCard()
{
	AfxGetMainWnd()->SendMessage(IDM_LAND_SCORE,5,5);
	return;
}
開發者ID:Michael-Z,項目名稱:qipai-game,代碼行數:6,代碼來源:GameClientView.cpp

示例2: switch


//.........這裏部分代碼省略.........

			return true;
		}
	case SUB_GP_LOGON_ERROR:		//登錄失敗
		{
			//效驗參數
			CMD_GP_LogonError *pLogonError = (CMD_GP_LogonError *)pData;
			ASSERT(wDataSize>=(sizeof(CMD_GP_LogonError)-sizeof(pLogonError->szErrorDescribe)));
			if (wDataSize<(sizeof(CMD_GP_LogonError)-sizeof(pLogonError->szErrorDescribe))) return false;

			//關閉連接
			g_GlobalAttemper.DestroyStatusWnd(this);
			m_ClientSocket->CloseSocket();

			//顯示消息
			WORD wDescribeSize=wDataSize-(sizeof(CMD_GP_LogonError)-sizeof(pLogonError->szErrorDescribe));
			if (wDescribeSize>0)
			{
				pLogonError->szErrorDescribe[wDescribeSize-1]=0;
				ShowMessageBox(pLogonError->szErrorDescribe,MB_ICONINFORMATION);
			}

			//發送登錄
			SendLogonMessage();

			return true;
		}
	case SUB_GP_LOGON_FINISH:		//登錄完成
		{
			//關閉提示
			g_GlobalAttemper.DestroyStatusWnd(this);

			//展開類型
			INT_PTR nIndex=0;
			CListType * pListType=NULL;
			do
			{
				pListType=g_GlobalUnits.m_ServerListManager.EnumTypeItem(nIndex++);
				if (pListType==NULL) break;
				g_GlobalUnits.m_ServerListManager.ExpandListItem(pListType);
			} while (true);

			//展開列表
			nIndex=0;
			CListInside * pListInside=NULL;
			do
			{
				pListInside=g_GlobalUnits.m_ServerListManager.EnumInsideItem(nIndex++);
				if (pListInside==NULL) break;
				g_GlobalUnits.m_ServerListManager.ExpandListItem(pListInside);
			} while (true);

			//記錄信息
			m_bLogonPlaza=true;
			m_DlgLogon.OnLogonSuccess();
			m_pHtmlBrower->EnableBrowser(true);

			//記錄信息
			g_GlobalUnits.WriteUserCookie();

			//顯示頭像
			((CGameFrame*)AfxGetMainWnd())->m_UserInfoView.ShowUserInfo(true);

			//自定義判斷
			tagGlobalUserData &GlobalUserData = g_GlobalUnits.GetGolbalUserData();
			if ( GlobalUserData.dwCustomFaceVer!=0)
			{
				//頭像名稱
				CString strDirName = CString(g_GlobalUnits.GetWorkDirectory()) + TEXT("\\CustomFace");
				CString strFileName;
				strFileName.Format(TEXT("\\%ld_%d.bmp"), GlobalUserData.dwUserID, GlobalUserData.dwCustomFaceVer);

				//讀取文件
				CImage FaceImage;
				HRESULT hResult = FaceImage.Load(strDirName + strFileName);
				if (SUCCEEDED(hResult))
				{
					//關閉連接
					m_ClientSocket->CloseSocket();

					FaceImage.Destroy();
				}
				//下載頭像
				else
				{
					PostMessage(WM_DOWN_LOAD_FACE, LPARAM(GlobalUserData.dwCustomFaceVer), WPARAM(GlobalUserData.dwUserID));
				}
			}
			else
			{
				//關閉連接
				m_ClientSocket->CloseSocket();
			}

			return true;
		}
	}

	return true;
}
開發者ID:codercold,項目名稱:whgame,代碼行數:101,代碼來源:PlazaViewItem.cpp

示例3: ASSERT

//用戶消息
bool CPlazaViewItem::OnSocketMainUser(CMD_Command Command, void * pBuffer, WORD wDataSize)
{
	ASSERT(Command.wMainCmdID == MDM_GP_USER);
	switch(Command.wSubCmdID)
	{
	case SUB_GP_USER_DOWNLOAD_FACE:			//下載頭像
		{
			//類型轉換
			CMD_GP_DownloadFaceSuccess *pDownloadFaceSuccess = (CMD_GP_DownloadFaceSuccess*)pBuffer;

			//參數驗證
			WORD wSendSize = WORD(pDownloadFaceSuccess->dwCurrentSize + sizeof(CMD_GP_DownloadFaceSuccess) - sizeof(pDownloadFaceSuccess->bFaceData));
			ASSERT(wDataSize == wSendSize);
			if ( wDataSize != wSendSize ) return false;

			//第一次判斷
			if ( m_CustomFace.pFaceData == NULL )
			{
				if ( m_CustomFace.pFaceData != NULL ) delete[] m_CustomFace.pFaceData;
				m_CustomFace.pFaceData = new BYTE[pDownloadFaceSuccess->dwToltalSize];
				if ( m_CustomFace.pFaceData == NULL ) return true;
				m_CustomFace.dwFaceSize = pDownloadFaceSuccess->dwToltalSize;
				m_CustomFace.dwUserID = pDownloadFaceSuccess->dwUserID;
			}

			//拷貝數據
			CopyMemory(m_CustomFace.pFaceData+m_CustomFace.dwCurrentSize, pDownloadFaceSuccess->bFaceData, pDownloadFaceSuccess->dwCurrentSize);
			m_CustomFace.dwCurrentSize += pDownloadFaceSuccess->dwCurrentSize;

			//下載完畢
			if ( m_CustomFace.dwFaceSize == m_CustomFace.dwCurrentSize )
			{
				tagDownloadInfo &DownloadInfo = m_DownloadInfoArrary[0];

				//創建目錄
				CString strDirName = CString(g_GlobalUnits.GetWorkDirectory()) + TEXT("\\CustomFace");
				CreateDirectory(strDirName, NULL) ;

				//寫入文件
				CFile fileFace;
				CString strZipFileName, strBmpFileName;
				strZipFileName.Format(TEXT("\\%ld_%d.zip"), DownloadInfo.dwUserID, DownloadInfo.bFaceVer);
				strBmpFileName.Format(TEXT("\\%ld_%d.bmp"), DownloadInfo.dwUserID, DownloadInfo.bFaceVer);
				if ( fileFace.Open(strDirName + strZipFileName, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary) )
				{
					fileFace.Write(m_CustomFace.pFaceData, m_CustomFace.dwFaceSize);
					fileFace.Close();

					//解壓文件
					CUnzip oUnzip( strDirName + strZipFileName );
					oUnzip.SwapSize( strDirName + strBmpFileName );

					//刪除文件
					CFile::Remove(strDirName + strZipFileName);
				}

				//自己判斷
				tagGlobalUserData &GlobalUserData = g_GlobalUnits.GetGolbalUserData();
				if ( GlobalUserData.dwUserID ==  DownloadInfo.dwUserID )
				{
					//更新界麵
					((CGameFrame*)AfxGetMainWnd())->m_UserInfoView.UpdateUserInfo();
				}

				//重置變量
				m_CustomFace.Clear();

				//刪除元素
				m_DownloadInfoArrary.RemoveAt(0);

				//繼續判斷
				if ( 0 < m_DownloadInfoArrary.GetCount() )
				{
					//狀態判斷
					if ( m_ClientSocket->GetSocketStatus() != SOCKET_STATUS_CONNECT )
					{
						//鏈接網絡
						if ( ! ConnectServer() ) return true;

						//設置標識
						m_bDownloadConnect = true;
					}

					//投遞請求
					tagDownloadInfo &DownloadInfo = m_DownloadInfoArrary[0];

					CMD_GP_DownloadFace DownloadFace;
					DownloadFace.dwUserID = DownloadInfo.dwUserID;
					m_ClientSocket->SendData(MDM_GP_USER, SUB_GP_USER_DOWNLOAD_FACE, &DownloadFace, sizeof(DownloadFace));
				}
				else
				{
					//關閉鏈接
					m_ClientSocket->CloseSocket();

					//設置變量
					m_bStartDownloadFace=false;
				}
			}
//.........這裏部分代碼省略.........
開發者ID:codercold,項目名稱:whgame,代碼行數:101,代碼來源:PlazaViewItem.cpp

示例4: ThreadFun

// 用於應用程序“關於”菜單項的 CAboutDlg 對話框
UINT ThreadFun(LPVOID pParam){  //線程要調用的函數
   WSADATA wsd;
   int len=sizeof(struct sockaddr_in);
   int ret;
	TCHAR recvbuf[BUFSIZE];
   if(WSAStartup(MAKEWORD(2,2),&wsd)!=0)
   {
	   printf("WSAStartup()failed\n");
	   return -1;
   }
   if((sock=WSASocket(AF_INET,SOCK_DGRAM,0,NULL,0,
	   WSA_FLAG_MULTIPOINT_C_LEAF|WSA_FLAG_MULTIPOINT_D_LEAF|
	   WSA_FLAG_OVERLAPPED))==INVALID_SOCKET)
   {
	   printf("socket failed with :%d\n",WSAGetLastError());
	   WSACleanup();
	   return -1;
   }
   //將sock綁定到本機端口上
   local.sin_family=AF_INET;
   local.sin_port=htons(MCASTPORT);
   local.sin_addr.s_addr=INADDR_ANY;

   if(bind(sock,(struct sockaddr*)&local,sizeof(local))==SOCKET_ERROR)
   {
	   printf("bind failed with %d\n",WSAGetLastError());
	   closesocket(sock);
	   WSACleanup();
	   return -1;
   
   
   }
   //加入多播組

   remote.sin_family=AF_INET;
   remote.sin_port=htons(MCASTPORT);
   remote.sin_addr.s_addr=inet_addr(MCASTADDR);

   if((sockM=WSAJoinLeaf(sock,(SOCKADDR*)&remote,sizeof(remote),
	   NULL,NULL,NULL,NULL,
	   JL_BOTH))==INVALID_SOCKET)
   {
     printf("WSAJoinLeaf()failed:%d\n",WSAGetLastError());
     closesocket(sock);
	 WSACleanup();
	 return -1;
   }
   //接收多播數據,當收到的數據為QUIT時退出

   while(1)
   {
	   if((ret=recvfrom(sock,recvbuf,BUFSIZE,0,
		   (struct sockaddr*)&from,&len))==SOCKET_ERROR)
	   {
		   //printf("recvfrom failed with :%d\n",WSAGetLastError());
		   closesocket(sockM);
		   closesocket(sock);
		   WSACleanup();
		   return -1;
	   }
	   if(strcmp(recvbuf,"QUIT")==0)  break;
	   else{
		   recvbuf[ret]='\0';
		   Str+=inet_ntoa(from.sin_addr);
		   Str+=":";
		   Str+=recvbuf;
		   Str+="\r\n";
		   HWND hWnd = GetDlgItem(AfxGetMainWnd()->m_hWnd,IDC_EDIT1);
		   CWnd *pWnd = CWnd::FromHandle(hWnd);
		   pWnd->SetWindowText(_T(Str));

	   }
   }

   closesocket(sockM);
   closesocket(sock);
   WSACleanup();
   return 0;
}
開發者ID:SilentTTxo,項目名稱:CurriculumDesign,代碼行數:80,代碼來源:Ip3Dlg.cpp

示例5: OnEditPaste

void CDataView::OnEditPaste() 
{
	m_Grid.OnEditPaste();
	CGAMDoc *pDoc = (CGAMDoc*)(((CMainFrame *)AfxGetMainWnd())->GetActiveDocument());
	pDoc->SetModifiedFlag();
}
開發者ID:WisemanLim,項目名稱:femos,代碼行數:6,代碼來源:DataView.cpp

示例6: AfxGetMainWnd

void CFMDischargedPaidPatientListByDay::OnDeptListSelectChange(int nOldItem, int nNewItem){
	CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd();
	
} 
開發者ID:smithgold53,項目名稱:HMSReportForms,代碼行數:4,代碼來源:FMDischargedPaidPatientListByDay.cpp

示例7: AfxGetMainWnd

void CMyClientMainView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;
	AfxGetMainWnd()->PostMessage
		(WM_CLIENTMAINRCLICK,IDR_MENU_CLIENT_MANAGER,NULL);
}
開發者ID:lzm-cn,項目名稱:PCShare,代碼行數:6,代碼來源:MyClientMainView.cpp

示例8: CreateRect

//建立消息
int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (__super::OnCreate(lpCreateStruct)==-1) return -1;

	//創建控件
	CRect CreateRect(0,0,0,0);

	//創建撲克
	for (WORD i=0;i<3;i++)
	{
		//用戶撲克
		if ( i == 1 )
			m_UserCardControl[i].SetDirection(true);
		else
			m_UserCardControl[i].SetDirection(false);
			
		m_UserCardControl[i].SetDisplayFlag(true);	
		m_UserCardControl[i].SetCardSpace( 16, 20, 16 );

		m_UserCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,20+i);

		//用戶撲克
		if (i!=1)
		{
			m_HandCardControl[i].SetCardSpace(0,18,0);
			m_HandCardControl[i].SetDirection(false);
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
		else
		{
			m_HandCardControl[i].SetDirection(true);
			m_HandCardControl[i].SetDisplayFlag(false);
			m_HandCardControl[i].Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,30+i);
		}
	}

	//設置撲克
	m_BackCardControl.SetCardSpace(85,0,0);
	m_BackCardControl.SetDisplayFlag(false);
	m_HandCardControl[1].SetSinkWindow(AfxGetMainWnd());
	m_BackCardControl.Create(NULL,NULL,WS_VISIBLE|WS_CHILD,CreateRect,this,41);

	//創建按鈕
	m_btStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_START);
	m_btOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_OUT_CARD);
	m_btPassCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_PASS_CARD);
	m_btOneScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_ONE_SCORE);
	m_btTwoScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_TWO_SCORE);
	m_btGiveUpScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_GIVE_UP_SCORE);
	m_btAutoOutCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTO_OUTCARD);
	m_btThreeScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_THREE_SCORE);
	m_btAutoPlayOn.Create(TEXT(""), WS_CHILD ,CreateRect,this,IDC_AUTOPLAY_ON);
	m_btAutoPlayOff.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_AUTOPLAY_OFF);
	m_btSortCard.Create(NULL,WS_CHILD|WS_DISABLED|WS_VISIBLE,CreateRect,this,IDC_SORT_CARD);

	//擴展按鈕
	m_btSnatchLand.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_SNATCH_LAND);
	m_btBrightCard.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_BRIGHT_CARD);	
	m_btBrightStart.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_BRIGHT_START);
	m_btDoubleScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_DOUBLE_SCORE);
	m_btNotDoubleScore.Create(TEXT(""),WS_CHILD,CreateRect,this,IDC_NOT_DOUBLE_SCORE);
    
	//設置按鈕
	HINSTANCE hInstance=AfxGetInstanceHandle();
	m_btStart.SetButtonImage(IDB_START,hInstance,false);
	m_btOutCard.SetButtonImage(IDB_OUT_CARD,hInstance,false);
	m_btPassCard.SetButtonImage(IDB_PASS,hInstance,false);
	m_btOneScore.SetButtonImage(IDB_ONE_SCORE,hInstance,false);
	m_btTwoScore.SetButtonImage(IDB_TWO_SCORE,hInstance,false);
	m_btGiveUpScore.SetButtonImage(IDB_GIVE_UP,hInstance,false);
	m_btAutoOutCard.SetButtonImage(IDB_AUTO_OUT_CARD,hInstance,false);
	m_btThreeScore.SetButtonImage(IDB_THREE_SCORE,hInstance,false);
	m_btAutoPlayOn.SetButtonImage  (IDB_AUTOPLAY_ON,hInstance,false);
	m_btAutoPlayOff.SetButtonImage (IDB_AUTOPLAY_OFF,hInstance,false);
	m_btSortCard.SetButtonImage(IDB_COUNT_SORT,hInstance,false);
	m_btSnatchLand.SetButtonImage(IDB_SNATCH_LAND,hInstance,false);
	m_btBrightCard.SetButtonImage(IDB_BRIGHT_CARD,hInstance,false);
	m_btBrightStart.SetButtonImage(IDB_BRIGHT_CARD_START, hInstance, false);
	m_btDoubleScore.SetButtonImage(IDB_DOUBLE_SCORE, hInstance, false);
	m_btNotDoubleScore.SetButtonImage(IDB_NOT_DOUBLE_SCORE, hInstance, false);
    
    m_btAutoPlayOn.ShowWindow(SW_SHOW);
    m_btAutoPlayOff.ShowWindow(SW_HIDE);

	//創建控件
	m_ScoreView.Create(IDD_GAME_SCORE,this);

	//隱藏撲克
	//m_HandCardControl[ 0 ].ShowWindow( SW_HIDE );
	//m_HandCardControl[ 2 ].ShowWindow( SW_HIDE );

#ifdef VIDEO_GAME

	//創建視頻
	for (WORD i=0; i<GAME_PLAYER; i++)
	{
		//創建視頻
		m_DlgVedioService[i].Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,200+i);
//.........這裏部分代碼省略.........
開發者ID:Michael-Z,項目名稱:qipai-game,代碼行數:101,代碼來源:GameClientView.cpp

示例9: UNREFERENCED_PARAMETER


//.........這裏部分代碼省略.........
		{
			CPen line(PS_INSIDEFRAME, 1, bkg);
			CPen* old = dc.SelectObject(&line);
			dc.MoveTo( cur , r.top );
			dc.LineTo( r.right, r.top );
			dc.MoveTo( cur , r.top + CORBARS - 1);
			dc.LineTo( r.right, r.top + CORBARS - 1);
		}
		CRect rFilled(r);
		rFilled.left =   cur;
		rFilled.top++;
		rFilled.bottom--;
		dc.FillSolidRect(&rFilled,  havntplayed ); //fEnabled ?
		
		//r = GetChannelRect();
		for(int i = 0; i < CORBARS ; i++){
			CPen line(PS_INSIDEFRAME, 1, Bars[i]);
			CPen* old = dc.SelectObject(&line);
			dc.MoveTo( r.left , r.top + i);
			dc.LineTo( cur, r.top + i);
		}

		{
			COLORREF P2 = s.GetColorFromTheme(_T("SeekBarBorder1"), 0x000d3324);
			COLORREF P1 = s.GetColorFromTheme(_T("SeekBarBorder2"),0x00091611);
			dc.SetPixel(r.left-1, r.top+1, P2);
			dc.SetPixel(r.left, r.top, P2);
			dc.SetPixel(r.left-1, r.bottom-2, P2);
			dc.SetPixel(r.left, r.bottom-1, P2);
			dc.SetPixel(cur+1, r.top+1, P2);
			dc.SetPixel(cur, r.top, P2);
			dc.SetPixel(cur+1, r.bottom-2, P2);
			dc.SetPixel(cur, r.bottom-1, P2);
			dc.SetPixel(cur+1, r.top, P1);
			dc.SetPixel(cur+1, r.bottom-1, P1);
			dc.SetPixel(r.left-1, r.top, P1);
			dc.SetPixel(r.left-1, r.bottom-1, P1);

			CPen line(PS_INSIDEFRAME, 1, Bars[0]);
			CPen* old = dc.SelectObject(&line);

			dc.MoveTo( r.left-1 , r.top + 2);
			dc.LineTo( r.left-1 , r.bottom-2);
			dc.MoveTo( cur+1 , r.top + 2);
			dc.LineTo( cur+1 , r.bottom-2);
		}

		CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
		if( pFrame->m_aRefTime > 0){
			CRect rFilled(r);
			
			rFilled.left += (__int64)r.Width() * (pFrame->m_aRefTime - m_start) / (m_stop - m_start) ;
			if( pFrame->m_aRefTime < pFrame->m_bRefTime )
				rFilled.right = r.left + (__int64)r.Width() * (pFrame->m_bRefTime - m_start) / (m_stop - m_start) ;
			else
				rFilled.right = rFilled.left + 1;

			rFilled.top+=2;
			rFilled.bottom-=2;

			CBrush nBrush(HS_DIAGCROSS,  s.GetColorFromTheme(_T("SeekBarABArea"), 0x003fff9a ));
			dc.FillRect(&rFilled,&nBrush ); //fEnabled ?
		}
		
		/*
		switch( cur % 4 ){
					case 3:
						cur--;
						break;
					case 2:
						cur+=2;
						break;
					case 1:
						cur++;
						break;
				}
				for(int drawPos = cur ; drawPos < r.right; drawPos +=2){
					CRect step(drawPos,r.top, drawPos+2, r.bottom);
					if(drawPos % 4){
						dc.FillSolidRect( &step, NEWUI_COLOR_TOOLBAR_UPPERBG);
					}else{
						dc.FillSolidRect( &step, white);
					}
				}*/
		
		//r.InflateRect(1, 1);
		//dc.Draw3dRect(&r, shadow, light);
		dc.ExcludeClipRect(&r);
	}

	// background
	{
		CRect r;
		GetClientRect(&r);
		dc.FillRect(&r, &bBkg);
	}


	// Do not call CDialogBar::OnPaint() for painting messages
}
開發者ID:Fluffiest,項目名稱:splayer,代碼行數:101,代碼來源:PlayerSeekBar.cpp

示例10: GetCursorPos

void CPlayerSeekBar::SetTimecodeTip(){
	CString toolTip;
	CPoint point , screenPos;
	GetCursorPos(&point);
	screenPos = point;
	ScreenToClient(&point);
	CRect rcClient;
	if( !rcClient.PtInRect(point)){

		//return;
	}
	CRect r = GetChannelRect();

	if(r.left <= r.right){

		__int64 mPos = 0;
		if(point.x < r.left) mPos = m_start;
		else if(point.x >= r.right) mPos = m_stop;
		else
		{
			__int64 w = r.right - r.left;
			if(m_start < m_stop)
				mPos = (m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w);
		}
		DVD_HMSF_TIMECODE tcNow = RT2HMSF(mPos);

		if( tcNow.bHours > 0)
			toolTip.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
		else 
			toolTip.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);


		//AfxMessageBox(toolTip);
		//if(toolTip.IsEmpty())
		//	toolTip = _T("Unkown");

		if(!toolTip.IsEmpty()){
			CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
			pFrame->m_tip.m_text = toolTip;
			CSize tipsize = pFrame->m_tip.CountSize();
			point = screenPos;
			CRect rcTip ( point.x - tipsize.cx/2 , point.y - tipsize.cy - 6,point.x + tipsize.cx/2 , point.y -  6);
			//SVP_LogMsg5(_T("Tip %d %d %d %d") , rcTip.left,rcTip.top , rcTip.right,rcTip.left);

			HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);

			MONITORINFO mi;
			mi.cbSize = sizeof(MONITORINFO);
			GetMonitorInfo(hMonitor, &mi);

			if(rcTip.left < mi.rcWork.left){
				rcTip.MoveToX(mi.rcWork.left + 3);
			}else if(rcTip.right > mi.rcWork.right){
				rcTip.MoveToX(mi.rcWork.right - rcTip.Width() - 3);
			}

			pFrame->m_tip.MoveWindow( rcTip );
			pFrame->m_tip.ShowWindow(SW_SHOWNOACTIVATE);
			pFrame->m_tip.Invalidate();
		}
	}
}
開發者ID:Fluffiest,項目名稱:splayer,代碼行數:62,代碼來源:PlayerSeekBar.cpp

示例11: GetParentFrame

void CUserListCtrl::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	//		make sure window is active
	//
	GetParentFrame()->ActivateFrame();


	///////////////////////////////
	// See ContextMenuRules.txt for order of menu commands!

	//		create an empty context menu
	//
	CP4Menu popMenu;
    popMenu.LoadMenu(IDR_USER);

	int	index;
    SetIndexAndPoint( index, point );

	if( index != -1 )
	{
		// Can only edit or delete my user
		if ( GetSelectedItemText( ) == GET_P4REGPTR( )->GetP4User( ) )
		{
            // can't switch if already there
            popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_SWITCHTOUSER,MF_BYCOMMAND);
        }
        else
        {
            // can't edit, delete, set password or set as default if not current
            popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_EDITMY,MF_BYCOMMAND);
            popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_DELETE,MF_BYCOMMAND);
            popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_PASSWORD,MF_BYCOMMAND);
            popMenu.GetSubMenu(0)->DeleteMenu(ID_SETDEFUSER,MF_BYCOMMAND);
        }
	}
    else
    {
        // can't do much if no user selected
        popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_EDITMY,MF_BYCOMMAND);
        popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_DESCRIBE,MF_BYCOMMAND);
        popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_DELETE,MF_BYCOMMAND);
        popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_SWITCHTOUSER,MF_BYCOMMAND);
        popMenu.GetSubMenu(0)->DeleteMenu(ID_USER_PASSWORD,MF_BYCOMMAND);
        popMenu.GetSubMenu(0)->DeleteMenu(ID_SETDEFUSER,MF_BYCOMMAND);
        // clobber extra separator
        popMenu.GetSubMenu(0)->DeleteMenu(1,MF_BYPOSITION);

    }

	MainFrame()->AddToolsToContextMenu((CP4Menu *)(popMenu.GetSubMenu(0)));

	popMenu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,	point.x, point.y, AfxGetMainWnd());
}
開發者ID:danieljennings,項目名稱:p4win,代碼行數:53,代碼來源:UserListCtrl.cpp

示例12: CreateLoadDialog

bool MeaPositionLogMgr::Load(LPCTSTR pathname)
{
    // If there is a modified set of positions, ask the user if
    // they should be saved before loading a new set.
    //
    if (!SaveIfModified()) {
        return false;
    }

    if (pathname != NULL) {
        m_pathname = pathname;
    } else {
        CFileDialog *dlg = CreateLoadDialog();

        if (dlg->DoModal() != IDOK) {
            return false;
        }
        m_pathname = dlg->GetPathName();
    }

    bool status = false;
    TCHAR drive[_MAX_DRIVE];
    TCHAR dir[_MAX_DIR];

    //
    // Remember the directory for persisting.
    //
    _tsplitpath_s(m_pathname, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0);
    m_initialDir = drive;
    m_initialDir += dir;

    //
    // Load the positions
    //
    if (Open(m_pathname, CFile::modeRead)) {
        //
        // Delete old positions.
        //
        ClearPositions();
    
        //
        // Parse the contents of the log file
        //
        MeaXMLParser parser(this, true);

        try {
            UINT numBytes;

            do {
                void *buf = parser.GetBuffer(kChunkSize);
                numBytes = m_stdioFile.Read(buf, kChunkSize);
                parser.ParseBuffer(numBytes, numBytes == 0);
            } while (numBytes > 0);

            status = true;
        } catch (MeaXMLParserException&) {
            // Handled by the parser.
        } catch (MeaLogFileException&) {
            CString msg(reinterpret_cast<LPCSTR>(IDS_MEA_INVALID_LOGFILE));
            MessageBox(*AfxGetMainWnd(), msg, NULL, MB_OK | MB_ICONERROR);
        } catch (...) {
            CString msg(reinterpret_cast<LPCSTR>(IDS_MEA_NO_POSITIONS));
            MessageBox(*AfxGetMainWnd(), msg, NULL, MB_OK | MB_ICONERROR);
        }

        Close();

        if (status) {
            //
            // Process the log file DOM
            //
            ProcessDOM(parser.GetDOM());

            m_modified = false;

            if (m_observer != NULL) {
                m_observer->LogLoaded();
            }
        }
    } else {
        m_pathname.Empty();
    }

    return status;
}
開發者ID:craigshaw,項目名稱:Meazure,代碼行數:85,代碼來源:PositionLogMgr.cpp

示例13: GetAbsPosition

// Resize parent 
void CSplitterFrame::UpdateParent()
{
  CRect rcParent;
  CRect rcMainFrame;
  CRect rcMainClientFrame;
  CPoint pt = GetAbsPosition();
  CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());

  
  CDlgTemplate &wndParent = *(CDlgTemplate*)GetParent();
  pMainFrame->GetClientRect(&rcMainClientFrame);
  pMainFrame->GetWindowRect(&rcMainFrame);

  pt.x -=rcMainFrame.left;
  pt.y -=rcMainFrame.top;

  wndParent.GetWindowRect(&rcParent);
  wndParent.ShowWindow(SW_HIDE);


  INDEX iWidth = rcParent.right - rcParent.left;
  INDEX iHeight = rcParent.bottom - rcParent.top;

  if(sp_bDockingEnabled) {
    pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top));
    // is splitter attached on left side
    if(sp_uiDockSide == AFX_IDW_DOCKBAR_LEFT) {
      SET_BAR_SIZE(wndParent,rcMainClientFrame.right - pt.x,iHeight);
    // is splitter attached on right side
    } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_RIGHT) {
      SET_BAR_SIZE(wndParent,pt.x,iHeight);
    // is splitter attached on top side
    } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_TOP) {
      SET_BAR_SIZE(wndParent,iWidth,iHeight + sp_ptStartPoint.y - pt.y);
    // is splitter attached on bottom side
    } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_BOTTOM) {
      ASSERT(FALSE);
    }

    // Chose docking side
    INDEX iDockSide = 0;
    // is splitter attached on left side
    if(sp_uiDockSide==AFX_IDW_DOCKBAR_LEFT) {
      iDockSide = AFX_IDW_DOCKBAR_RIGHT;
    // is splitter attached on right side
    } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_RIGHT) {
      iDockSide = AFX_IDW_DOCKBAR_LEFT;
    // is splitter attached on top side
    } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_TOP) {
      iDockSide = AFX_IDW_DOCKBAR_BOTTOM;
    // is splitter attached on bottom side
    } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_BOTTOM) {
      iDockSide = AFX_IDW_DOCKBAR_TOP;
    }
    pMainFrame->DockControlBar(&wndParent,iDockSide);
  } else {
      SET_BAR_SIZE(wndParent,300,300);
    // wndParent.SetWindowPos(&wndBottom,0,0,100,300,SWP_NOZORDER);
    //pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top));
    //pMainFrame->DockControlBar(&wndParent,AFX_IDW_DOCKBAR_BOTTOM);
  }
  


  wndParent.ShowWindow(SW_SHOW);
  wndParent.UpdateWindow();
}
開發者ID:EgoIncarnate,項目名稱:Serious-Engine,代碼行數:68,代碼來源:SplitterFrame.cpp

示例14: GetDocument

void COpenScrapeView::OnDraw(CDC* pDC)
{
	COpenScrapeDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	CPen		*pTempPen, oldpen;
	CBrush		*pTempBrush, oldbrush;	
	HDC			hdc = *pDC;
	HDC			hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL); 
	HDC			hdcCompatible = CreateCompatibleDC(hdcScreen);
	HBITMAP		hbmp = CreateCompatibleBitmap(hdcScreen, 
										      pDoc->attached_rect.right - pDoc->attached_rect.left, 
										      pDoc->attached_rect.bottom - pDoc->attached_rect.top);
	HBITMAP		old_bitmap1, old_bitmap2;
	CMainFrame	*pmyframe = (CMainFrame*)AfxGetMainWnd(); 
	RECT		crect;

	// Draw attached window's bitmap as background
	if (pDoc->attached_bitmap)
	{
		old_bitmap1 = (HBITMAP) SelectObject(hdcCompatible, pDoc->attached_bitmap);
		old_bitmap2 = (HBITMAP) SelectObject(hdc, hbmp);
		BitBlt(hdc, 0, 0,
			   pDoc->attached_rect.right - pDoc->attached_rect.left,
			   pDoc->attached_rect.bottom - pDoc->attached_rect.top,
			   hdcCompatible, 0, 0, SRCCOPY);
		SelectObject(hdc, old_bitmap2);
		SelectObject(hdcCompatible, old_bitmap1);
	}
	else
	{
		pTempPen = (CPen*)pDC->SelectObject(null_pen);
		oldpen.FromHandle((HPEN)pTempPen);
		pTempBrush = (CBrush*)pDC->SelectObject(white_brush);
		oldbrush.FromHandle((HBRUSH)pTempBrush);

		GetClientRect(&crect);
		pDC->Rectangle(&crect);

		pDC->SelectObject(oldpen);
		pDC->SelectObject(oldbrush);
	}

	// Draw all region rectangles
	if (pmyframe->show_regions)
	{
		for (RMapCI r_iter=p_tablemap->r$()->begin(); r_iter!=p_tablemap->r$()->end(); r_iter++)
		{
			if ( (r_iter->second.name==dragged_region && dragging) || 
				 (r_iter->second.name==drawrect_region && drawing_rect && drawing_started) )
			{
				// Set pen and brush
				pTempPen = (CPen*)pDC->SelectObject(black_dot_pen);
				oldpen.FromHandle((HPEN)pTempPen);
				pTempBrush = (CBrush*)pDC->SelectObject(GetStockObject(NULL_BRUSH));
				oldbrush.FromHandle((HBRUSH)pTempBrush);

				pDC->Rectangle(r_iter->second.left-1, r_iter->second.top-1, r_iter->second.right+2, r_iter->second.bottom+2);

				pDC->SelectObject(oldpen);
				pDC->SelectObject(oldbrush);
			}

			else
			{
				// Set pen and brush
				pTempPen = (CPen*)pDC->SelectObject(red_pen);
				oldpen.FromHandle((HPEN)pTempPen);
				pTempBrush = (CBrush*)pDC->SelectObject(GetStockObject(NULL_BRUSH));
				oldbrush.FromHandle((HBRUSH)pTempBrush);

				pDC->Rectangle(r_iter->second.left-1, r_iter->second.top-1, r_iter->second.right+2, r_iter->second.bottom+2);

				pDC->SelectObject(oldpen);
				pDC->SelectObject(oldbrush);
			}
		}
	}

	// Clean Up
	DeleteObject(hbmp);
	DeleteDC(hdcCompatible);
	DeleteDC(hdcScreen);
}
開發者ID:ohzooboy,項目名稱:oh,代碼行數:86,代碼來源:OpenScrapeView.cpp

示例15: pszConvertedAnsiString

bool PT_Network::ReadGTFFiles(GDRect network_rect)  // Google Transit files
{

	//	// step 1: read  route files
	string str0 = m_ProjectDirectory +"routes.txt";
	//string str =  "h:/routes.csv";

	CT2CA pszConvertedAnsiString (str0.c_str());
	// construct a std::string using the LPCSTR input
	std::string  strStd (pszConvertedAnsiString);
	CCSVParser parser;

	if (parser.OpenCSVFile(strStd))
	{

		//	AfxMessageBox("Start reading Google Transit Feed files...", MB_ICONINFORMATION);

		int count =0;
		PT_Route route;
		while(parser.ReadRecord())
		{


			if(parser.GetValueByFieldName("route_id",route.route_id ) == false)
				break;
			if(parser.GetValueByFieldName("route_long_name",route.route_long_name) == false)
				route.route_long_name="";
			if(parser.GetValueByFieldName("route_short_name",route.route_short_name) == false)
				route.route_short_name="";			
			if(parser.GetValueByFieldName("route_url",route.route_url) == false)
				route.route_url="";			
			if(parser.GetValueByFieldName("route_type",route.route_type) == false)
				route.route_type="";		

			// make sure there is not duplicated key
			// If the requested key is not found, find() returns the end iterator for
			//the container, so:

			if(m_PT_RouteMap.find(route.route_id)  == m_PT_RouteMap.end() )
			{ 
				m_PT_RouteMap[route.route_id] = route;  
			}
			else
			{
				AfxMessageBox("Duplicated Route ID!");
			}


			count++;

		}
		parser.CloseCSVFile ();

		CMainFrame* pMainFrame = (CMainFrame*) AfxGetMainWnd();

		pMainFrame->m_bShowLayerMap[layer_transit] = true;

	}else
	{
		return false;
	}

	CString missing_stops_message;
	// step 1: read stop information
	string str2 = m_ProjectDirectory +"stops.txt";


	CT2CA pszConvertedAnsiString2 (str2.c_str());
	// construct a std::string using the LPCSTR input
	std::string  strStd2 (pszConvertedAnsiString2);
	if (parser.OpenCSVFile(strStd2))
	{
		int count =0;
		while(parser.ReadRecord())
		{
			PT_Stop stop;

			if(parser.GetValueByFieldName("stop_id",stop.stop_id ) == false)
				break;


			bool NonnegativeFlag = false;
			if(parser.GetValueByFieldName("stop_lat",stop.m_ShapePoint.y, NonnegativeFlag) == false)
				break;

			if(parser.GetValueByFieldName("stop_lon",stop.m_ShapePoint.x , NonnegativeFlag) == false)
				break;

			if(parser.GetValueByFieldName("direction",stop.direction  ) == false)
				stop.direction="";

			if(parser.GetValueByFieldName("location_type",stop.location_type) == false)
				stop.location_type=0;

			if(parser.GetValueByFieldName("position",stop.position  ) == false)
				stop.position="";

			if(parser.GetValueByFieldName("stop_code",stop.stop_code ) == false)
				stop.stop_code=0;

//.........這裏部分代碼省略.........
開發者ID:lidapeng,項目名稱:dtalite_beta_test,代碼行數:101,代碼來源:Transit.cpp


注:本文中的AfxGetMainWnd函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。