Click here to Skip to main content
15,920,801 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How does a modal dialog work (message pump)? Pin
Joaquín M López Muñoz29-May-02 5:49
Joaquín M López Muñoz29-May-02 5:49 
GeneralRe: How does a modal dialog work (message pump)? Pin
29-May-02 5:28
suss29-May-02 5:28 
GeneralRe: How does a modal dialog work (message pump)? Pin
Joaquín M López Muñoz29-May-02 8:29
Joaquín M López Muñoz29-May-02 8:29 
GeneralRe: How does a modal dialog work (message pump)? Pin
29-May-02 13:13
suss29-May-02 13:13 
GeneralRe: How does a modal dialog work (message pump)? Pin
29-May-02 18:20
suss29-May-02 18:20 
GeneralRe: How does a modal dialog work? Code snippets Pin
29-May-02 13:36
suss29-May-02 13:36 
GeneralRe: How does a modal dialog work? Code snippets Pin
Joaquín M López Muñoz29-May-02 23:12
Joaquín M López Muñoz29-May-02 23:12 
GeneralRe: How does a modal dialog work? Workaround Pin
30-May-02 0:50
suss30-May-02 0:50 
Thx, Joaquín.

Oops, the main important line in CBlueSharkEngine::Run() is what I commented out previously: Big Grin | :-D
EngineMain(m_timer.GetElapsedSeconds());

This method will render the OpenGL scene (depending from elapsed time). Right now I called it from inside my message loop CBlueSharkEngine::Run(). I need to call this method regular (and as fast as possible to get a high frame rate). Hmm, I think I found a possible replacement, when couldn't start my main message loop. With some structure changes:

// Engine message callback handler
LRESULT CALLBACK Wnd_ProcMessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	
	//... more messages handled here
	
	case WM_PAINT:
		if(pEngine->m_bEngineRunning)
			pEngine->EngineMain(pEngine->m_timer->GetElapsedSeconds());
		//return DefWindowProc(hWnd,uMsg,wParam,lParam);
		//note: last line commented out on purpose to get endless WM_PAINT messages
		break;
		
	default:
		return DefWindowProc(hWnd,uMsg,wParam,lParam);
	}
	return 0;
}


The "trick" above is to get repeated WM_PAINT messages to render my frames with EngineMain(). The rendering starts, when I set m_bEngineRunning=TRUE (and Invalidate()). It works in a test project, I will do more testings soon.

Some questions:
* How efficient is it to request repeated WM_PAINT messages generally, don't I loose CPU performance compared to my direct calling message loop? In a game engine or a 3D visualisation you want to reach highest frame rate.
* There is one negative side effect with this new type of message handling. The handling of the system menu became very "blocky", anything else negative that could happen?

Thx again, Moak
GeneralRe: How does a modal dialog work? Workaround Pin
Joaquín M López Muñoz30-May-02 2:36
Joaquín M López Muñoz30-May-02 2:36 
GeneralRe: How does a modal dialog work? Workaround Pin
30-May-02 6:59
suss30-May-02 6:59 
GeneralRe: How does a modal dialog work? Workaround Pin
Joaquín M López Muñoz1-Jun-02 5:28
Joaquín M López Muñoz1-Jun-02 5:28 
AnswerRe: How does a modal dialog work (message pump)? Pin
Paul M Watt29-May-02 7:24
mentorPaul M Watt29-May-02 7:24 
GeneralFile Type Association Pin
moobob29-May-02 4:34
moobob29-May-02 4:34 
GeneralRe: File Type Association Pin
Mauricio Ritter29-May-02 6:27
Mauricio Ritter29-May-02 6:27 
GeneralRe: File Type Association Pin
moobob29-May-02 7:06
moobob29-May-02 7:06 
GeneralCombo box without dropdown button Pin
ed987129-May-02 4:03
ed987129-May-02 4:03 
GeneralRe: Combo box without dropdown button Pin
dlhson29-May-02 6:09
dlhson29-May-02 6:09 
GeneralRe: Combo box without dropdown button Pin
ed987129-May-02 7:15
ed987129-May-02 7:15 
GeneralRe: Combo box without dropdown button Pin
aldeba29-May-02 23:48
aldeba29-May-02 23:48 
GeneralConvert a HRESULT to a string Pin
Anders Molin29-May-02 3:32
professionalAnders Molin29-May-02 3:32 
GeneralRe: Convert a HRESULT to a string Pin
Philippe Mori29-May-02 3:49
Philippe Mori29-May-02 3:49 
GeneralRe: Convert a HRESULT to a string Pin
CodeGuy29-May-02 3:44
CodeGuy29-May-02 3:44 
GeneralSubclassing a static control Pin
Cathy29-May-02 3:03
Cathy29-May-02 3:03 
GeneralRe: Subclassing a static control Pin
Roger Allen29-May-02 4:58
Roger Allen29-May-02 4:58 
GeneralRe: Subclassing a static control Pin
Cathy29-May-02 11:45
Cathy29-May-02 11:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.