Solved

Owner Drawn System Menu (Caption Bar)?

Posted on 2004-04-04
3
841 Views
Last Modified: 2013-12-03
Hello,

     This seems like a really simple problem, but seems to have a more then difficult solution.

     First let me tell you what I am aiming for.  I want to create a skinnable interface similar to shareaza (www.shareaza.com).  I am having no problem drawing over the caption bar by overriding WM_NCPAINT, the problem is skinning the system buttons (cancel, max, min, exc.).  I want to be able to change the size/shape/ownerdraw and should be able to find the location of them somehow.  I would just paint over them completely, but then in addition to lack of extra features, i dont know the true position of them to draw over.

     So what I need to have is a way to either get ahold of a handle to the system menu BUTTONS, or a way to get the exact location, size, and event (hover/down/up).

Thanks,
Richard.

(PS: Anything else that would be helpfull in doing this would be nice, im using MFC, but an expirianced WINAPI programmer.  Thanks.
0
Comment
Question by:RichardCesar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 125 total points
ID: 10757582
Well, first, I don't think you need to know their location if you just override the OnNcHitTest since you can adjust the routines to detect them wherever you want to draw them.

Also, since they aren't really buttons at all, you can't directly ownerdraw them.  Instead you need to draw them directly.  They are just simple images drawn by the system, and their entire behavior has to be imitated under WM_NCPAINT (fortunately, the behavior is simple).

Now, if you are just trying to draw the current WinXP theme, that can be done with calls to DrawThemeEdge and sundry.  See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/refentry.asp for details.

On the other hand, if you are trying to draw your own controls in a user settable theme, then under XP use the GetThemeRect function.  Under Win98/ME/2000 use GetSystemMetrics and work out the position piece by piece.

Hope this helps.
0
 

Author Comment

by:RichardCesar
ID: 10762071
Ok, I looked into it, thank you for the information.
Im going to award you the points, but if you dont mind answering a few related questions I would me more then greatfull.

I just read the MSDN on the HitTest, Im thinking at the moment your pretty much going to have to have a giant switch statement.  How many possable returns am I going to have to handle, and is there anything special (that is poorly documented) about where to get them.  Thanks.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 10765633
Well, it depends on what you are overriding.  If you are overriding everything, then yeah, you need to return every HT code that you need.  Usually a program only needs to change one or two things, so you could just call the base function and override the changes.  For example, I sometimes modify the OnNcHitTest function for tool windows where if the base returns HTCLIENT and there is no child window at that point I change it to HTCAPTION so the user can drag the window from anywere there isn't a control.

The full list of return values is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.onnchittest.asp along with a vague description of what they mean.

There are two important things to remember.  The good part is that Windows uses this return value to control behavior, so if you want a particular part of the window to size the left side all you need to do is return HTLEFT, Windows will handle all the rest of mouse tracking and redrawing automatically.

The bad news is that, to do this, Windows calls the function every time the mouse moves, so you have to write the routine to be as fast and simple as possible.

Hope this helps.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question