0

The concept of DWM window manipulation/Window Styles is a bit new to me and I am experimenting with a few new situations. I would be obliged if someone could help point me in the right direction.

Also, how do you keep the 2nd window exactly behind the 1st instead of another window from another application in between them?

enter image description here

Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73

1 Answers1

1

You need process the WM_WINDOWPOSCHANGING message on one of the windows and use SetWindowPos to make sure you keep the z-order. You can either use SetWindowPos to send the window below a message that it should precede the current window, or call it from the second window to the first one with the HWND_TOP argument when the z-order changes.

Radu Chivu
  • 1,057
  • 7
  • 17
  • How would a SetWindowPos that you are talking to look like? Can you provide the psuedocode for the parameters? – Mathew Kurian Sep 13 '13 at 06:54
  • 1
    if (msg == WM_WINDOWPOSCHANGING){if((WNDPOS*)lparam)->hwndInsertAfter != lastWindowPos) SetWindowPos(otherWindowHwnd, hwnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE)} for the upper window, you have to change the first two parameters for setwindowpos if you do this from the lower window – Radu Chivu Sep 13 '13 at 07:19
  • Thank you so much for the explanation. But when I tried to do the borderless window, I lost ability to bring it into focus/active window. So if I click on it, the window never came back to the front. Is that a normal response from a borderless window? Can I avoid it? – Mathew Kurian Sep 13 '13 at 07:23
  • would passing WS_CHILD to the CreateWindow call for the borderless window having the other window as parent HWND solve what you are trying? it would look something like borderlessWnd = CreateWindow("ClassName", "Window Title", WS_CHILD|WS_VISIBLE, 100, 100, 300, 300, parentWnd, NULL, hInstance, NULL); – Radu Chivu Sep 13 '13 at 07:30
  • By any chance do you know how to make a window transparent and draw opaque pixels onto the transparent surface using direct2d? – Mathew Kurian Sep 16 '13 at 06:40
  • You can't mix stuff that direct2d draws with what win32 draws, you have to make a direct2d surface and do everything from there. – Radu Chivu Sep 16 '13 at 08:28
  • I posted this question on stack. Can you please take a look at it, that would be so appreciated: http://stackoverflow.com/questions/18836921/id2d1hwndrendertarget-always-having-black-background-instead-of-transparent – Mathew Kurian Sep 16 '13 at 20:45