Windows Develop Bookmark and Share   
 index > Windows Forms General > Button question
 

Button question

I have a tiny borderless form with tiny buttons on it. I want the buttons to not receive focus (no box around them) when you click them. Also, I want a tool tip to show when you hover over each button.

Is there a wayto allowthe user to dock this form to the top, sides, or bottom of the desktop (visible desktop area in main monitor)?
bsaucer1  Thursday, September 03, 2009 1:29 PM

Hi,

->have a tiny borderless form with tiny buttons on it. I want the buttons to not receive focus (no box around them) when you click them. Also, I want a tool tip to show when you hover over each button.

You need to create a custom button. This button will filter the button click message. For example:

private void Form1_Load(object sender, EventArgs e)

{

mybutton1.TabStop = false;

ToolTip tip1 = new ToolTip();

foreach (Control con in this.Controls)

{

if (con is mybutton)

{

tip1.SetToolTip(con, "MyButton");

}

}

}

}

public class mybutton : Button

{

const int WM_LBUTTONDOWN = 0x0201;

const int WM_LBUTTONDBLCLK = 0x203;

protected override void WndProc(ref Message m)

{

if (m.Msg != WM_LBUTTONDOWN && m.Msg != WM_LBUTTONDBLCLK)

base.WndProc(ref m);

}

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Thursday, September 10, 2009 11:30 AM
If you do not want that box, then do not use a button.
Use anything that does not use that box, get creative.

Use a custom control made from panel, with background images that represent the button in the 'unpressed' and 'pressed' state. You will need to switch the images on MouseDown events, to simulate the impression of the button being clicked.

Try a search on this forum for your second question. Someone asked that same question just a day or two ago.

Rudedog =8^D

Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Thursday, September 03, 2009 1:44 PM

Hi,

->have a tiny borderless form with tiny buttons on it. I want the buttons to not receive focus (no box around them) when you click them. Also, I want a tool tip to show when you hover over each button.

You need to create a custom button. This button will filter the button click message. For example:

private void Form1_Load(object sender, EventArgs e)

{

mybutton1.TabStop = false;

ToolTip tip1 = new ToolTip();

foreach (Control con in this.Controls)

{

if (con is mybutton)

{

tip1.SetToolTip(con, "MyButton");

}

}

}

}

public class mybutton : Button

{

const int WM_LBUTTONDOWN = 0x0201;

const int WM_LBUTTONDBLCLK = 0x203;

protected override void WndProc(ref Message m)

{

if (m.Msg != WM_LBUTTONDOWN && m.Msg != WM_LBUTTONDBLCLK)

base.WndProc(ref m);

}

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Thursday, September 10, 2009 11:30 AM

You can use google to search for other answers

Custom Search

More Threads

• closing parent window
• Progrss bar shows border in c# form when style is continuous
• Auto Resizing
• PropertyGrid - Monitoring User Inputs As Entered
• create multi form - problem
• Control
• Displaying a background image on a form in vb express
• How to print directly to printer
• if i want remove selected rows from DataGrid and back Database ???
• Strange editor behaviour, VS 2005 beta2