Jump to content
  • Advertisement
Sign in to follow this  
Zoomby

draw custom menu or dropdown list?

This topic is 4535 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, Win32 API: What is the best way to draw something outside the client rect of a window, i.e. to draw menus and dropdown-lists? It tried GetDC(NULL), but the problem is to restore the stuff that was under that area. bye, Chris

Share this post


Link to post
Share on other sites
Advertisement
Top-level windows (i.e. the actual things with borders and captions that you can move around the screen) are not able to draw outside of their client areas, because the OS forces them to have the WS_CLIPSIBLINGS style. If you need to draw outside the client area of a top-level window, you need to actually create a secondary top-level window, which is how menus, drop-downs, tooltips, etc. usually are implemented.

Share this post


Link to post
Share on other sites
If you mean you want to draw something that will draw over the extents of your entire window, then the best (maybe only) way would be to create another window, and draw onto that. That's what most windows controls and popup menus do, from what I can see.

Share this post


Link to post
Share on other sites
Yeah, I already tried it with another top-level window, but the problem is that the parent window (i.e. the window where the custom drop-down control is in) looses the focus and the title bar gets gray. Do you know how to avoid that?

Share this post


Link to post
Share on other sites
What you want is an owned window. Just pass the owner window (your main window) as the hWndParent parameter of CreateWindow/CreateWindowEx, and make sure that WS_CHILD is not set.

Share this post


Link to post
Share on other sites
Hi,
I tried what you described as "owned window". No luck. The main window still looses the focus and gets gray. I really want to know how that menu and dropdown stuff is implemented!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
one fairly easy way to do it is to have your popup window subclass or hook its parent window and then respond to the WM_NCACTIVATE msg with FALSE, which will leave the parent's window's titlebar, etc., in the active state.

but there's any even easier way to do this as I've done it before for my own popup menu class. i just have to find the code as it was written years ago and I can't remember exactly what was done.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
by parent, i really meant owned, of course :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i found the following code which might do the trick:


// handle if in AOT mode - make sure we're not activated and that we stay on top
case WM_WINDOWPOSCHANGING:
if( rtProps.alwaysOnTop )
{
((LPWINDOWPOS)lParam)->flags |= SWP_NOACTIVATE;
((LPWINDOWPOS)lParam)->flags &= ~(SWP_NOOWNERZORDER | SWP_NOZORDER);
((LPWINDOWPOS)lParam)->hwndInsertAfter = HWND_TOPMOST;
}
return 0; // no default processing so no WM_GETMINMAXINFO msg is sent


i'm not sure if such an app gets keyboard focus though as this code came from an alt+tab replacement and it's using a low-level keyboard hook

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!