Advertisement

User Drawn Title Bars

Started by December 31, 2000 12:22 PM
7 comments, last by ranxact 24 years ago
Using the Windows Defined Title bar is boring... therefore I would like to draw my own buttons for close, minimize, and maximize. How can i do that (I know how to make a button a Bitmap, i just need to know the ID''s for the buttons, or handles to them...) also i would like to draw the Title itself, this way i would just have a Bitmap behind the Text in the Title... Does anyone know how to do this? again, I know how to draw, I just don''t know how to get access to the Title bar... Thanx, RanXacT
RanXact@yahoo.com
I can not tell you how to do it, but I can give you a pointer towards the correct Windows Message, WM_NCPAINT. here is the page from the MSDN:

WM_NCPAINT
An application sends the WM_NCPAINT message to a window when its frame must be painted.

WM_NCPAINT
hrgn = (HRGN) wParam; // handle of update region

Parameters
hrgn
Value of wParam. Handle to the update region of the window. The update region is clipped to the window frame. When wParam is 1, the entire window frame needs to be updated.
This value can be passed to GetDCEx as in the following example.

case WM_NCPAINT:
{
HDC hdc;
hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
// Paint into this DC
ReleaseDC(hwnd, hdc);
}

Return Values
An application returns zero if it processes this message.

Remarks
The DefWindowProc function paints the window frame.

An application can intercept the WM_NCPAINT message and paint its own custom window frame. The clipping region for a window is always rectangular, even if the shape of the frame is altered.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.


If you have MSDN installed look at the index for WM_NCPAINT, there are messages for the mouse buttons as well as a few other more specific messages. If you do not have MSDN installed you could try looking at www.codeguru.com, I think they might have something close to what you want.

Another option is to not have a title bar on your window and add code to trap messages in the 'title bar' area of your application.

[EDIT]
I've just found this on the CodeGuru.com's search engine:

Question:
Pl. suggest me how to paint a user icon on the non client area of the window , and associate an event to it.

Answer:
AFAIK to paint outside the client-area of a window you have to subclass the window, trap the WM_NCACTIVATE and WM_NCPAINT messages (NC for non-client) and do the painting yourself.
To trap mouse messages intercept the WM_NCLBUTTONUP messasge in your subclassing procedure.
I recommend KB article Q99046

Dunno if that article will help you or not.
[/EDIT]

When I find my code in tons of trouble,
Friends and colleages come to me,
Speaking words of wisdom:
"Write in C."

Edited by - Steven on December 31, 2000 3:09:10 PM
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Advertisement


Hey, That certainly led me in the right direction, Thanx, it works great for drawing the Caption Area . However; I cannot modify the Min/Max/X buttons because the re-draw themselves periodically... so, if any one else has any ideas for those, what would be awesome is if they have ID''s and i could get HWND''s for them.. then I could send them messages to do my bidding....

Thanx,
RanXacT
RanXact@yahoo.com
maybe its easier to just make a popup window without a title bar if you want to draw it yourself
Well, I would, but my program is MDI (Multiple Document Interface) and doing that would mean I have to give up the whole MDI environment and write my own... hmm.. and actually now that i have tried it, the WM_NCACTIVATE and WM_NCPAINT don''t work well in the MDI either (they worked outside of it).. so maybe i''m outta luck... well.. if any one else has any other ideas, feel free to add..

Thanx for all the help so far,
RanXacT
RanXact@yahoo.com
i don''t know if this is a good way for doing it, but you could try GetWindowRect() and GetClientRect(),

GetWindowRect() gives you the entire windowsurface including title bar and windowframe,

GetClientRect() only gives you the clientarea

so you can just calculate the size of the titlebar and windowframe, and paint over it

haven''t tried it though
Advertisement
It appears that Softimage has done this type of thing quite successfully. When you get to this page, click on visuals on the left, and then click on the SOFTIMAGE|XSI screenshots, as opposed to the other screenshots.



Edited by - bishop_pass on January 1, 2001 8:21:01 PM
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
i obviously had a major hangover yesterday please pay no attention to my previous post

Petzold tells me something in the lines of what Steven described earlier, about WM_NCPAINT and GetWindowDC() but not too much

and there''s nothing there about MDI either, sorry i can''t help you
The WM_NCHITTEST will also help.
You can use DrawFrameControl() for drawing your own title bar using Window''s stuff.
Maybe WM_SYSCOMMAND is also a good thing to watch here.

I hope you have a good help ref for these

This topic is closed to new replies.

Advertisement