Exemple #1
0
bool KGUIWin32Wnd::ShowModal()
{
	HWND hWndParent = GetWindow(m_hWnd, GW_OWNER);
	if (hWndParent == NULL && m_pOwner != NULL)
	{
		hWndParent = m_pOwner->GetHWND();
	}

	::ShowWindow(m_hWnd, SW_SHOWNORMAL);
	::EnableWindow(hWndParent, FALSE);
	MSG msg = { 0 };
	while (::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0))
	{
		if (msg.message == WM_CLOSE )
		{
			::EnableWindow(hWndParent, TRUE);
			::SetFocus(hWndParent);
		}
		if (!PreTranslateMessage(&msg))
		{
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		if( msg.message == WM_QUIT )
			break;
	}
	::EnableWindow(hWndParent, TRUE);
	::SetFocus(hWndParent);
	if (msg.message == WM_QUIT)
		::PostQuitMessage(msg.wParam);
	return true;
}
Exemple #2
0
void CreateSplash(DWORD time,char* prog,char* vers,ROMEString* author,int numAuthor)
{
    programName = prog;
    version = vers;
    authorNames = author;
    numberOfAuthors = numAuthor;
    MSG msg;
    if (MyRegisterClass(hInst) != 0)
        bClassRegistered = TRUE;
    if(time > 0) {
        bSplash = TRUE;
        DelayVal = time * 1000;
    }
    else return;
    // Create the splash screen
    if (bSplash)
        CreateSplashScreen(NULL);

    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0)) {
        PreTranslateMessage(&msg);
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    HideSplashScreen();
}
bool CExtThemeSwitcherToolControlBar::OnHookWndMsg(
	LRESULT & lResult,
	HWND hWndHooked,
	UINT nMessage,
	WPARAM & wParam,
	LPARAM & lParam
	)
{
	__PROF_UIS_MANAGE_STATE;
MSG msg;
	::memset( &msg, 0, sizeof(MSG) );
	msg.hwnd = hWndHooked;
	msg.message = nMessage;
	msg.wParam = wParam;
	msg.lParam = lParam;
	if( PreTranslateMessage( &msg ) )
		return true;
	return 
		CExtHookSink::OnHookWndMsg(
			lResult,
			hWndHooked,
			nMessage,
			wParam,
			lParam
			);
}
Exemple #4
0
BOOL CNetwork::OnRun(DWORD nReserved)
{
	CSingleLock pLock( &m_pSection );
	
	while ( m_bThread )
	{
		WaitForSingleObject( m_pWakeup, 50 );
		
		if ( ! m_bThread ) break;
		if ( pLock.Lock( 250 ) )
		{
			RunNeighbours();
			pLock.Unlock();
		}
		
		if ( ! m_bThread ) break;
		{
			Datagrams.OnRun();
		}
		
		MSG msg;
		while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
		{
			if ( GetMessage( &msg, 0, 0, 0 ) ) PreTranslateMessage(&msg);
		}
	}
	
	return TRUE;
}
void CConfigShortcuts::keyReleaseEvent(QKeyEvent *event)
{
   MSG msg;
   msg.hwnd = (HWND)this;
   msg.message = WM_KEYUP;
   msg.wParam = event->key();
   PreTranslateMessage(&msg);
}
Exemple #6
0
 void SMessageLoop::OnMsg(LPMSG pMsg)
 {
     if(!PreTranslateMessage(pMsg))
     {
         ::TranslateMessage(pMsg);
         ::DispatchMessage(pMsg);
     }
 }
Exemple #7
0
//**関数***************************************************************************
//	概要	:	メッセージの取得とディスパッチ
//*********************************************************************************
bool CWindow::PumpMessage()
{
	if (!::GetMessage(&m_msgCur, NULL, NULL, NULL))
		return false;

	if (!PreTranslateMessage(&m_msgCur)) 
	{
		::TranslateMessage(&m_msgCur);
		::DispatchMessage(&m_msgCur);
	}
	return true;
}
BOOL CWinThread::PumpMessage()
/****************************/
{
    MSG msg;
    if( !::GetMessage( &msg, NULL, 0, 0 ) ) {
        return( FALSE );
    }
    if( !PreTranslateMessage( &msg ) ) {
        ::TranslateMessage( &msg );
        ::DispatchMessage( &msg );
    }
    return( TRUE );
}
void cGameApplication::Run()
{
	DWORD prevTime = timeGetTime();
	DWORD curTime = prevTime;
	DWORD deltaTime = 0;
	DWORD accumTime = 0;
	int   accumFrame = 0;

	MSG msg;

	// 기본 메시지 루프입니다.
	/// todo : 가변FPS에 비의존적인 일정한 게임속도 구현
	while (true)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				break;
			/*TranslateMessage(&msg);
			DispatchMessage(&msg);*/
			PreTranslateMessage(&msg);
		}
		else
		{
			curTime = timeGetTime();
			deltaTime = curTime - prevTime;
			prevTime = curTime;

			accumTime += deltaTime;
			accumFrame++;

			static WCHAR fpsString[20] = L"";

			if (accumTime >= 1000)
			{
				_fps = (accumFrame*1000.0f) / accumTime;	// 최악의 경우 1 frame의 오차가 있을 수 있다

				accumTime -= 1000;
				accumFrame = 0;

				swprintf(fpsString, 20, L"FPS : %2.2f", _fps);
				SetWindowText(_hwnd,fpsString);
			}

			Update(deltaTime / 1000.0f);
			Render();
		}
	}
}
Exemple #10
0
// message loop
int CDUIMessageLoop::Run()
{
	BOOL bDoIdle = TRUE;
	int nIdleCount = 0;
	BOOL bRet;
	
	for(;;)
	{
		while(bDoIdle && !::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if(!OnIdle(nIdleCount++))
				bDoIdle = FALSE;
		}
		
		bRet = ::GetMessage(&m_msg, NULL, 0, 0);
		
		if(bRet == -1)
		{
			continue;   // error, don't process
		}
		else if(!bRet)
		{
			break;   // WM_QUIT, exit message loop
		}
		
		if(!PreTranslateMessage(&m_msg))
		{
			::TranslateMessage(&m_msg);
			::DispatchMessage(&m_msg);
		}
		
		if(IsIdleMessage(&m_msg))
		{
			bDoIdle = TRUE;
			nIdleCount = 0;
		}
	}
	
	return (int)m_msg.wParam;
}
Exemple #11
0
BOOL CNetwork::OnRun(DWORD nReserved)
{
	CSingleLock pLock( &m_pSection );
	
	while ( m_bThread )
	{
		WaitForSingleObject( m_pWakeup, 50 );
		
		if ( ! pLock.Lock(100) ) continue;
//TRACE("%i -> CNetwork.OnRun\n", GetTickCount());
		RunNeighbours();
//TRACE("%i -> CNetwork.OnRun out...\n", GetTickCount());
		pLock.Unlock();
		if ( ! m_bThread ) break;
		
		MSG msg;
		while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
		{
			if ( GetMessage( &msg, 0, 0, 0 ) ) PreTranslateMessage(&msg);
		}
	}
	
	return TRUE;
}
Exemple #12
0
BOOL CFrameWnd::ProcessHelpMsg(MSG& msg, DWORD* pContext)
{
	ASSERT(pContext != NULL);

	if (msg.message == WM_EXITHELPMODE ||
		(msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE))
	{
		PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE);
		return FALSE;
	}

	CPoint point;
	if ((msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) ||
		(msg.message >= WM_NCMOUSEFIRST && msg.message <= WM_NCMOUSELAST))
	{
		BOOL bDescendant;
		HWND hWndHit = SetHelpCapture(msg.pt, &bDescendant);
		if (hWndHit == NULL)
			return TRUE;

		if (bDescendant)
		{
			if (msg.message != WM_LBUTTONDOWN)
			{
				// Hit one of our owned windows -- eat the message.
				PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE);
				return TRUE;
			}
			int iHit = (int)::SendMessage(hWndHit, WM_NCHITTEST, 0,
				MAKELONG(msg.pt.x, msg.pt.y));
			if (iHit == HTMENU || iHit == HTSYSMENU)
			{
				ASSERT(::GetCapture() == m_hWnd);
				ReleaseCapture();
				// the message we peeked changes into a non-client because
				// of the release capture.
				GetMessage(&msg, NULL, WM_NCLBUTTONDOWN, WM_NCLBUTTONDOWN);
				DispatchMessage(&msg);
				GetCursorPos(&point);
				SetHelpCapture(point, NULL);
			}
			else if (iHit == HTCLIENT)
			{
				*pContext = _AfxMapClientArea(hWndHit, msg.pt);
				PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE);
				return FALSE;
			}
			else
			{
				*pContext = _AfxMapNonClientArea(iHit);
				PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE);
				return FALSE;
			}
		}
		else
		{
			// Hit one of our apps windows (or desktop) -- dispatch the message.
			PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE);

			// Dispatch mouse messages that hit the desktop!
			DispatchMessage(&msg);
		}
	}
	else if (msg.message == WM_SYSCOMMAND ||
			 (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST))
	{
		if (::GetCapture() != NULL)
		{
			ReleaseCapture();
			MSG msg;
			while (PeekMessage(&msg, NULL, WM_MOUSEFIRST,
				WM_MOUSELAST, PM_REMOVE|PM_NOYIELD));
		}
		if (PeekMessage(&msg, NULL, msg.message, msg.message, PM_NOREMOVE))
		{
			GetMessage(&msg, NULL, msg.message, msg.message);
			if (!PreTranslateMessage(&msg))
			{
				TranslateMessage(&msg);
				if (msg.message == WM_SYSCOMMAND ||
				  (msg.message >= WM_SYSKEYFIRST &&
					msg.message <= WM_SYSKEYLAST))
				{
					// only dispatch system keys and system commands
					ASSERT(msg.message == WM_SYSCOMMAND ||
						 (msg.message >= WM_SYSKEYFIRST &&
						  msg.message <= WM_SYSKEYLAST));
					DispatchMessage(&msg);
				}
			}
		}
		GetCursorPos(&point);
		SetHelpCapture(point, NULL);
	}
	else
	{
		// allow all other messages to go through (capture still set)
		if (PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE))
			DispatchMessage(&msg);
	}

	return TRUE;
}
Exemple #13
0
BOOL CWinThread::ProcessMessageFilter(int code, MSG *lpMsg) {
	if (lpMsg == NULL)
		return FALSE;   // not handled

	//!!!	CFrameWnd* pTopFrameWnd;
	CWnd* pMainWnd;
	CWnd* pMsgWnd;
	switch (code)
	{
	case MSGF_DDEMGR:
		// Unlike other WH_MSGFILTER codes, MSGF_DDEMGR should
		//  never call the next hook.
		// By returning FALSE, the message will be dispatched
		//  instead (the default behavior).
		return FALSE;

	case MSGF_MENU:
		pMsgWnd = CWnd::FromHandle(lpMsg->hwnd);
		/*!!!		if (pMsgWnd != NULL)
		{
		pTopFrameWnd = pMsgWnd->GetTopLevelFrame();
		if (pTopFrameWnd != NULL && pTopFrameWnd->IsTracking() &&
		pTopFrameWnd->m_bHelpMode)
		{
		pMainWnd = AfxGetMainWnd();
		if ((m_pMainWnd != NULL) && (IsEnterKey(lpMsg) || IsButtonUp(lpMsg)))
		{
		pMainWnd->SendMessage(WM_COMMAND, ID_HELP);
		return TRUE;
		}
		}
		}*/
		// fall through...

	case MSGF_DIALOGBOX:    // handles message boxes as well.
		pMainWnd = AfxGetMainWnd();
		/*!!!		if (afxData.nWinVer < 0x333 && pMainWnd != NULL && IsHelpKey(lpMsg))
		{
		pMainWnd->SendMessage(WM_COMMAND, ID_HELP);
		return TRUE;
		}*/
		if (code == MSGF_DIALOGBOX && m_pActiveWnd != NULL &&
			lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST)
		{
			// need to translate messages for the in-place container
			_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
			if (pThreadState->m_bInMsgFilter)
				return FALSE;
			pThreadState->m_bInMsgFilter = TRUE;    // avoid reentering this code
			MSG msg = *lpMsg;
			if (m_pActiveWnd->IsEnabled() && PreTranslateMessage(msg))
			{
				pThreadState->m_bInMsgFilter = FALSE;
				return TRUE;
			}
			pThreadState->m_bInMsgFilter = FALSE;    // ok again
		}
		break;
	}
	return FALSE;   // default to not handled
}