Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

DirectX renderer painting over child window

This topic is 1332 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 Guys,

 

I have a problem where a child window is getting painted over by the DirectX (parent) window below it.

 

I know the child window is there, because I can drag around the parent window and see the child whilst dragging.

 

This is my client window creation code -

 

hWnd=CreateWindowEx(WS_EX_TOPMOST,"Window Class","Game Window",WS_CHILD|WS_VISIBLE|WS_CAPTION|WS_OVERLAPPEDWINDOW,0,0,200,200,hWndGM,NULL,GetModuleHandle(NULL),NULL);

 

Any ideas how to overcome this?

 

Thanks in advance smile.png

Edited by DarkRonin

Share this post


Link to post
Share on other sites
Advertisement
Hmm, that is a possibility. I'll give that a try in the morning when I get in front of a PC.

Thanks for the suggestions so far guys :)

(Up voted you both)

Share this post


Link to post
Share on other sites

It's likely that DX is rendering to the full client area (which is the norm) of the main window. You'll have a bit of difficulty drawing over it without flickering (as you noticed when you moved the window). The client area of a window is not a child window - it's where child windows are drawn - and you can't achieve what you want by setting window styles.

 

Disclaimer: I've never hooked into DX apps.

 

[ EDIT: If the app presents to the full client area and ] If you want your child window to appear within the client area of the main window, you'll have to hook into the DX code and do one of the following:

 

1. If the app is DX9, change the Present area of the DX drawing itself to allow room in the client area of the main window for your window. As that's done with rectangles, the backbuffer will be Presented to a rectangle within the rectangle of the client area and the DX presentation will have a "border" of unpainted client area around it. Ugly. Direct3D 11.0 and 11.1 are different from DX9 and different from each other. That would be a whole new ball game.

 

2. Best option - draw directly to the DX backbuffer just before the device->Present call.

 

Alternatively, create a separate TOPMOST (not a child) window altogether. If the DX app goes fullscreen, that will give you problems, however.

 

EDIT: With D3D11, IF (unlikely, however) the swapchain is created GDI compatible, and you can hook the Present call, and can access the swapchain, you can get the backbuffer surface HDC and draw using GDI. After your drawing, Release the surface and do the Present call yourself.

Edited by Buckeye

Share this post


Link to post
Share on other sites

Yeah, I can't actually get to the present calls or anything like that as it is handled bythe closed source parent application.

 

I did originally have a free floating child window, but then I wanted it in the client area of the parent.

 

I guess free floating might not be too bad an option, as this is how Photoshop and the likes tend to work these days anyway.

Share this post


Link to post
Share on other sites

You can have a "free-floating" window that behaves like a child window.

 

First, make the window owned by an hidden parent (this hides the task bar button for the window).

Second, make some code that runs to poll the other app's window to see if its minimized or not, and hide your window when its min.

Third, make some code that tracks the position of the other apps window and move your window around to make it feel like its a child window. Also, make sure to not allow it to be dragged out of the other apps window rect.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!