I want to change the title bar of my application to as shown in the attached file.
Printable View
I want to change the title bar of my application to as shown in the attached file.
Have a browse through the various topics on MSDN first, it's very easy to find things on there.VB Code:
Me.Text = "Window Title"
Parallax,he isnt asking how to change the text in the title bar.He wants to change the titlebar style itself. :) I guess you didnt notice the difference between the 2 pictures,look closely.
What either removing the caption and icon or applying a gradient to the titlebar?
Im sure hes asking about applying gradient to the title bar :)
What you may have to do is apply your own XP theme to the window but then it will apply to all windows. :(
Hmm,....
Or maybe integcept the window messages and implement your own drawing??
Must be an easier way other then making the form borderless and skinning the form. ;)
Looks like it would be the WP_CAPTION with the DrawThemeBackground or DrawThemeParentBackground APIs. ;)
I need to redraw the title bar for this application only. so i cannot use a windows theme. Can u tell me more clearly about 'the WP_CAPTION with the DrawThemeBackground or DrawThemeParentBackground APIs' How can i use this?
Can i draw using GDI+ classes?
in VB6 there is an API viewer application. can i use APIs from that in .net?
If you have the 2004 version 3.10 with the database update from 8/2004 then you will have the .NET API syntaxes in there already. Go to Options and change the format to VB.NET instead of just Visual Basic. ;)
please comeback to my main question
No, you need to use a bitmap resource of your new title bar when using the Visual Styles APIs to draw the theme for that window.
Can u tell me more clearly about 'the WP_CAPTION with the DrawThemeBackground or DrawThemeParentBackground APIs'? How can i use this?
It is a very deep subject that does not have a short answer.
You need to test your app if the VS Theme is being used. Then if it is you need to call several APIs to obtain a handle to the theme resource dll. Then a call to your bitmap resource file containing the new graphic for the title bar. Then call a few drawing APIs for the themes. It think that is about the meat of the logic.
Hey Jain..
Rob's method is best thing to do using API's,would make it look more original..
but,heres a simple way if u want....remove the existing titlebar of the form by making the form borderless.Use a label and draw a gradient over the label.Put the text on it too.
And during resize event of the form,set label width=formwidth...isnt that a simple idea? ;)
The gradient is easy to put if you download the vbpowerpack available from microsoft. :)
They have readymade classes for it
Place the label on top of the form to appear as forms titlebar and u need to make the code for clicking on it and dragging the form which isnt very hard.
And forgot to mention that you need to make your own custom buttons for maximize,minimize and close too :)..I will try making this and post the code soon if I succeed.But,I am not going to aim in making it 3d like how it is in windows XP.I will try on this,thanks for the question ;)
Dude that's an awesome theme. What's it called?
As per your title bar. What I would do, and I'm not sure if there is a specific for this in .NET, but I would get a handle to the non-client DC using the GetDCEx() API, then draw the titlebar to that. That requires intercepting the WM_NCPAINT messages in your WndProc and drawing in that procedure.
The only problem with that PG is that the VS layer is drawn from a resource bitmap "on top" of the standard titlebar. You may end up drawing beneath the theme titlebar. I will do some testing later on this but that is how it was for when I was doing custom drawing on top of a toolbar button that had the theme applied and I did it via inheriting the toolbar in a class and manipulating the OnPaint event.
by VS, I'm assuming you mean Visual Style, and not Visual Studio?
I'm pretty sure that WM_NCPAINT is sent after the theme image is drawn. If not, I think WM_PAINT is, so in WM_NCPAINT you could set a flag to do the drawing to the non-client area upon the next WM_PAINT.
Yes, sounds logical and yes I do mean Visual Style :D