|
...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:
<br />
public void DrawButton(Graphics g, bool pressed) {<br />
if (VisualStyleRenderer.IsSupported)<br />
{<br />
Rectangle btnRect = new Rectangle(wnd_size.Width - (4 * 20) - 4, 12, 14, 14);<br />
<br />
int status = (pressed) ? 2 : 1;<br />
VisualStyleElement element = VisualStyleElement.CreateElement("WINDOW", 15, status);<br />
VisualStyleRenderer render = new VisualStyleRenderer(element);<br />
render.DrawBackground(g, btnRect, btnRect);<br />
}<br />
else<br />
{<br />
int btn_width = GetSystemMetrics(SM_CXSIZE);<br />
int btn_height = GetSystemMetrics(SM_CYSIZE);<br />
[...]<br />
|
|
|
|
|
I just want to add a simple modification:
public bool MouseinBtn(Point click)<br />
{<br />
int btn_width = GetSystemMetrics(SM_CXSIZE);<br />
int btn_height = GetSystemMetrics(SM_CYSIZE);<br />
Size btn_size = new Size(btn_width, btn_height);<br />
<br />
int numExistingButtons = ((parent.MaximizeBox || parent.MinimizeBox) ? 3 : 1);<br />
if (parent.HelpButton) ++numExistingButtons;<br />
Point pos = new Point(wnd_size.Width - numExistingButtons * btn_width - 12 - (btn_width - 18) - 6, 5);<br />
<br />
return click.X >= pos.X && click.X <= pos.X + btn_size.Width &&<br />
click.Y >= pos.Y && click.Y <= pos.Y + btn_size.Height;<br />
}<br />
.<br />
.<br />
.<br />
public void DrawButton(Graphics g, bool pressed)<br />
{<br />
int btn_width = GetSystemMetrics(SM_CXSIZE);<br />
int btn_height = GetSystemMetrics(SM_CYSIZE);<br />
<br />
int numExistingButtons = ((parent.MaximizeBox || parent.MinimizeBox) ? 3 : 1);<br />
if (parent.HelpButton) ++numExistingButtons;<br />
Point pos = new Point(wnd_size.Width - numExistingButtons * btn_width - 12 - (btn_width - 18) - 6, 5);<br />
<br />
if (VisualStyleRenderer.IsSupported)<br />
{<br />
btn_width -= 4;<br />
btn_height -= 4;<br />
Rectangle btnRect = new Rectangle(pos, new Size(btn_width, btn_height));<br />
int status = 1;<br />
if(pressed)<br />
status = 2;<br />
<br />
VisualStyleElement element = VisualStyleElement.CreateElement("WINDOW", 15, status);<br />
VisualStyleRenderer render = new VisualStyleRenderer(element);<br />
render.DrawBackground(g, btnRect, btnRect);<br />
}<br />
else<br />
{ <br />
btn_width -= 2;<br />
btn_height -= 4;<br />
<br />
Rectangle btnRect = new Rectangle(pos, new Size(btn_width, btn_height));<br />
if (pressed)<br />
{<br />
ControlPaint.DrawButton(g, btnRect, ButtonState.Pushed);<br />
}<br />
else<br />
ControlPaint.DrawButton(g, btnRect, ButtonState.Normal);<br />
<br />
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);<br />
}<br />
}<br />
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:
<br />
.<br />
.<br />
.<br />
public MinTrayBtn(Form parent)<br />
{<br />
parent.HandleCreated += new EventHandler(this.OnHandleCreated);<br />
parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);<br />
parent.TextChanged += new EventHandler(this.OnTextChanged);<br />
<big> parent.MdiChildActivate += new EventHandler(parent_MdiChildActivate);</big><br />
this.parent = parent;<br />
}<br />
.<br />
.<br />
.<br />
<big>private void parent_MdiChildActivate(object sender, EventArgs e)<br />
{<br />
DrawButton();<br />
}</big><br />
|
|
|
|
|
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?
|
|
|
|