|
|
Comments and Discussions
|
|
 |

|
...If you explain first what you are actually trying to do yes
What do you mean with a 'hand made bar'?
|
|
|
|

|
Thanks , works perfectly for my small app.
|
|
|
|

|
Hi All
Any one please suggest me some books related to this type of programming.
|
|
|
|

|
Check out Apress. They've got many books.
ROFLOLMFAO
|
|
|
|

|
I don't used the code but here comes an example how to paint an themed Caption Button using .NET Framework 2: using System.Windows.Forms.VisualStyles; private void pictureBox1_Paint(object sender, PaintEventArgs e) { Rectangle btnRect = new Rectangle(10, 10, 20, 20); DrawCaptionButton(e.Graphics, btnRect, CaptionStates.Active); } private void DrawCaptionButton(Graphics g, Rectangle bounds, CaptionStates state) { if (!VisualStyleRenderer.IsSupported) return; //VisualStyleElement element = VisualStyleElement.Window.MinButton.Normal; VisualStyleElement element = VisualStyleElement.CreateElement("WINDOW", 15, (int)state); VisualStyleRenderer render = new VisualStyleRenderer(element); render.DrawBackground(g, bounds, bounds); Rectangle clip = new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height); clip.Inflate(-3, -3); bounds.Height += bounds.Bottom - bounds.Top; render.DrawBackground(g, bounds, clip); } public enum CaptionStates : int { Active = 1, Inactive = 2, Disabled = 3 } -- modified at 16:15 Tuesday 28th February, 2006
|
|
|
|

|
Cool, but how do you get it on the forms caption bar?
|
|
|
|

|
I don't know - never used the topic button.
|
|
|
|

|
To enable themed button with XP style, change this:
public void DrawButton(Graphics g, bool pressed) {
if (VisualStyleRenderer.IsSupported)
{
Rectangle btnRect = new Rectangle(wnd_size.Width - (4 * 20) - 4, 12, 14, 14);
int status = (pressed) ? 2 : 1;
VisualStyleElement element = VisualStyleElement.CreateElement("WINDOW", 15, status);
VisualStyleRenderer render = new VisualStyleRenderer(element);
render.DrawBackground(g, btnRect, btnRect);
}
else
{
int btn_width = GetSystemMetrics(SM_CXSIZE);
int btn_height = GetSystemMetrics(SM_CYSIZE);
[...]
|
|
|
|

|
I just want to add a simple modification:
public bool MouseinBtn(Point click)
{
int btn_width = GetSystemMetrics(SM_CXSIZE);
int btn_height = GetSystemMetrics(SM_CYSIZE);
Size btn_size = new Size(btn_width, btn_height);
//what if maximize/minimize button(s) are hidden?
int numExistingButtons = ((parent.MaximizeBox || parent.MinimizeBox) ? 3 : 1);
//what if the help button is visible?
if (parent.HelpButton) ++numExistingButtons;
Point pos = new Point(wnd_size.Width - numExistingButtons * btn_width - 12 - (btn_width - 18) - 6, 5);
return click.X >= pos.X && click.X <= pos.X + btn_size.Width &&
click.Y >= pos.Y && click.Y <= pos.Y + btn_size.Height;
}
.
.
.
public void DrawButton(Graphics g, bool pressed)
{
int btn_width = GetSystemMetrics(SM_CXSIZE);
int btn_height = GetSystemMetrics(SM_CYSIZE);
//what if maximize/minimize button(s) are hidden?
int numExistingButtons = ((parent.MaximizeBox || parent.MinimizeBox) ? 3 : 1);
//what if the help button is visible?
if (parent.HelpButton) ++numExistingButtons;
Point pos = new Point(wnd_size.Width - numExistingButtons * btn_width - 12 - (btn_width - 18) - 6, 5);
if (VisualStyleRenderer.IsSupported)
{
// real button size
btn_width -= 4;
btn_height -= 4;
Rectangle btnRect = new Rectangle(pos, new Size(btn_width, btn_height));
int status = 1;
if(pressed)
status = 2;
VisualStyleElement element = VisualStyleElement.CreateElement("WINDOW", 15, status);
VisualStyleRenderer render = new VisualStyleRenderer(element);
render.DrawBackground(g, btnRect, btnRect);
}
else
{
// real button size
btn_width -= 2;
btn_height -= 4;
Rectangle btnRect = new Rectangle(pos, new Size(btn_width, btn_height));
if (pressed)
{
ControlPaint.DrawButton(g, btnRect, ButtonState.Pushed);
}
else
ControlPaint.DrawButton(g, btnRect, ButtonState.Normal);
g.FillRectangle(new SolidBrush(SystemColors.ControlText), pos.X + (float)0.5625 * btn_width + Convert.ToInt32(pressed), pos.Y + (float)0.6428 * btn_height + Convert.ToInt32(pressed), btn_width * (float)0.1875, btn_height * (float)0.143);
}
}
hope helpful
|
|
|
|

|
When i maximize MDIChild Form, It should draw that button on MDIParent Form and receive all the events of active child.
Thanks
Fayaz
|
|
|
|

|
try this:
.
.
.
public MinTrayBtn(Form parent)
{
parent.HandleCreated += new EventHandler(this.OnHandleCreated);
parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);
parent.TextChanged += new EventHandler(this.OnTextChanged);
parent.MdiChildActivate += new EventHandler(parent_MdiChildActivate);
this.parent = parent;
}
.
.
.
private void parent_MdiChildActivate(object sender, EventArgs e)
{
DrawButton();
}
|
|
|
|

|
I found this article very help full. It is great. Still i want to add this button in MDIChild Form. It is working with MDIParent Form and single Form applicatio. I am able to draw it on MDIChild Form but events are not triggered. i don't know which m.msg value will catch MDIChild window click event. Please help in this. Thanks Fayaz
|
|
|
|

|
I'm glad that you can use it
Actually I havent done anything with MDIChilds yet but I guess it should be working when you replace all the WM_NC* Messages with their corresponding non-NC Messages.
Hope that helps,
Tyron
|
|
|
|

|
I wonder how those guys at XNeat managed to make their product works with different xp skins !??!
|
|
|
|

|
Is it possible to do that for vb.NET programmers please? Thanks in advance ... btw, really great feature and useful as well
Stupid questions dictate stupid answers!
|
|
|
|

|
I haven't any experience in vb.net but maybe someone other could write it in vb.net
|
|
|
|

|
It would be very nice if someone convert to vb.NET ... thanks for the reply
Stupid questions dictate stupid answers!
|
|
|
|

|
I have created a VB.NET alternative to this article, and have enabled XP theming, multi-state buttons, and other features have been added. This will be posted in an article with in a week or two (could be longer, but not sure). Right now I am waiting for another article author to let me use some of his code so that the article can also cover transparent menus. If for some reason I am not able to submit the article I will post the code here.
|
|
|
|

|
Thanks in advance it would be nice of you ... Regards
Stupid questions dictate stupid answers!
|
|
|
|
|

|
Yes I am converting this into VB.NET. It is working file, but problem is with MDIChild Forms. I am not able to detect the Mouse Click on non-client area of window. Drawing is over.
Thanks
Fayaz
|
|
|
|

|
i think this site may help converting C# code to VB.Net
http://wwww.developerfusion.com/utilities/convertcsharptovb.aspx
|
|
|
|

|
How and where do I add Notify Icon component?
|
|
|
|

|
Depends on the Designer your using, but normally it should be where all the other windows forms (button, textbox, etc.) are.
If that doesn't help you maybe want to have a look at the demo
|
|
|
|

|
Hi,
I found your post on microsoft.public.dotnet.languages.csharp regarding using the TrackMouseEvent() function to hook up for the WM_NCMOUSELEAVE notification. I'm currently strugling with the same problem. Have you got any luck with enabling this event?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
An article on how to add a custom button to the caption bar.
| Type | Article |
| Licence | |
| First Posted | 19 Apr 2005 |
| Views | 166,371 |
| Bookmarked | 127 times |
|
|