Skip to main content
gamedev.net
🔒 Locked

render while not focused

Started by barakus 3 replies 600+ views
Original Post
barakus
barakus
This has been bugging me for a while and as yet i have found no solution for it. Im making a level editor, and i have a main window that uses Direct3D to render it. However, i have an option to open a tile set, which creates a new window that is drawn using nothing more than gdi.The problem is that the main window isnt being refreshed, until i close the other one. Ive debugged it and noticed that the render method is occuring, so im not sure whats happening. Anyone have any ideas? EDIT: Let me rephrase it. How can I keep rendering to a window while its lost focus? Actually im not sure if its even that as it will render as long as the other window is completely covered up. EDIT #2: Actually it does render when its not focused.... Just not when the tile set window from the same program is in display [Edited by - barakus on January 10, 2005 6:30:39 AM]
Samurai Jack
Samurai Jack
Isolate the Render method out of the WindowProc function?
If focused or not, if you call Render it has to render, regardles if it is active or not. That is a fact.

The horror case:
WindowProc(...)
switch (wm_message)
case WM_PAINT: open device, render, close device; ScreenFlip(); break;
..........

make it better:
WM_PAINT: render();break;

Try to call Render() from anywhere else, or from another window! It has to work.

I believe what you seek is "Timer". You can bind a "function" to a timer, let us say your window shall update, regardless active or not, every 250 miliseconds, that is 4x times a second. Check the "SetTimer" function and some examples. Even if your window might get inactive it will be rendered by the timer, if the MESSAGE connected to the timer event would call Render!

Edit1:
MSDN - SetTimer API
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/settimer.asp

MSDN - Creating a timer SAMPLE
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/usingtimers.asp
Samurai Jack
Samurai Jack
Hm, you might call Present with (NULL, NULL, NULL, NULL) since every parameter is NULL directx takes the default. Since the window that you would like to render isn't active anymore it also isn't default. Try to pass the HWND from your render window to Present (See help on parameters) and perhaps you should transfer the client rectange (GetClientRect or GetWindowRect) too?

I hope it will help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.