Sign in to follow this  

WinApi controls cleared together with screen in DirectX

This topic is 2064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,
So I'm not creating a game but a map editor for my game and this is my main message loop:
[CODE]while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if(!Render())
{
MessageBox(NULL, "Failed to render", "Error", MB_OK | MB_ICONEXCLAMATION);
break;
}
}[/CODE]
Here is my Render() function:
[CODE]bool Graphics::Render()
{
HRESULT hr = Input::Obj().d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
if(FAILED(hr)) return false;

hr = Input::Obj().d3dDevice->Present(NULL, NULL, NULL, NULL);
if(FAILED(hr)) return false;

return true;
}[/CODE]

I have created a scrollbar also on my window and when I'm putting my function Render() to my main message loop as above the scrollbar is being cleared all the time. How to make scrollbar refresh together with clearing a screen?

Share this post


Link to post
Share on other sites
Is the scroll bar parented to the same window that draw to with D3D? If so, it's not going to work. D3D assumes that it owns the entire client area of the window and won't play nice with other controls trying to render to the same client area. You should put your scroll bars beside the D3D window, perhaps parented to same window that the D3D window is parented to.

Also you should change your message loop so that you pump all queued messages before rendering. Otherwise you can end up with messages building up in the queue quicker than you pull them out.

Share this post


Link to post
Share on other sites
hmm so how should the common message loop for normal programs(not games) look? Where rendering should be done? I can't find a good example, every refer to game message loop ;/.
And yea the scrollbar is parented to the same window where D3D draws. I'm not sure if I understood well the matter connected with scrollbar, should I put the scrollbars on another window? Could you explain it wider?

Share this post


Link to post
Share on other sites
For the D3D render area make another control of type STATIC. Then you use the HWND of that static control for the D3D creation. Then the scrollbar is parented to the main window, and the static is also parented to the main window, but D3D won't clear the main window, just the static control.

Share this post


Link to post
Share on other sites

This topic is 2064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this