Sign in to follow this  

Render() on WM_PAINT crash

This topic is 4039 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

Hi! I'm programming DirectX in C++ under WinXP. My window is shown and updated, D3D object and device created and initialized. After that I use the device to clear the window to a blue color and the present. So far all is well, when run the window plopps up and is blue. But everytime the window is redrawn it goes white. So I try to fix it like this: (in the window procedure:) case WM_PAINT: Device->Clear Device->Present break; But then I can't even run the program because it "encounterd a problem and must exit". If it works in WinMain, why doesn't it work when redrawing? Thanks in advance, /Rayben

Share this post


Link to post
Share on other sites
Your device is probably null. Your window will receive WM_PAINT messages before Direct3D is set up - for instance the window recieves one while inside the CreateWindow() call, so there's nop way your device could be set up by this point.

You can prevent the window being redrawn as white by specifying NULL for the hbrBackground member of your WNDCLASS when you create the window. Then Windows won't clear the window, leaving you free to draw to it.
Alternatively, try:

case WM_PAINT:
if(Device)
{
Device->Clear
Device->Present
}
break;

Share this post


Link to post
Share on other sites

This topic is 4039 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