Windows Develop Bookmark and Share   
 index > Windows Forms General > Left mouse click on a borderless windows form taskbar button
• Windows Forms General
• Windows Forms Designer
• ClickOnce and Setup & Deployment Projects
• Windows Forms Data Controls and Databinding
• Windows Forms Sample Applications

Left mouse click on a borderless windows form taskbar button

Hi,

I've developed an application that contains a few borderless windows forms. I had included all the code necessary for the form move, close and minimize operations. However, when I left-click on the window button on the taskbar, I'm not able to hook in the events that happen in the case of the normal window (such as minimize and restore on clicking on the window button on the taskbar). After quite a bit of hunt online, I could find that hexadecimal code for mouse right click to be 0x0313 and I was able to bring a context menu. I'm still looking out for the hexadecimal code for left mouse click, using which, I believe I can hook in the minimize and restore events. Can anyone please help me out? Also, please suggest other ideas if I'm going about in a wrong direction.

Thanks in Advance,
ramz_g
  • Moved byOmegaManMVPMonday, July 27, 2009 4:55 PMUnable to move thread
  • Moved byOmegaManMVPMonday, July 27, 2009 5:06 PM (From:Visual C# General)
  •  
ramz_g  Friday, July 24, 2009 8:17 AM
I'm guessing your are talking about the system menu. A borderless form indeed doesn't have one. Get it back by pasting this code anywhere in your form:

protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.Style |= 0x80000; // Turn on WS_SYSMENU
return cp;
}
}

Hans Passant.
  • Marked As Answer byramz_g Tuesday, July 28, 2009 6:06 AM
  •  
nobugz  Monday, July 27, 2009 4:30 PM
Hi,

Could you tell us how do you create these borderless forms?

Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Monday, July 27, 2009 2:56 AM
Hi Harry,

I just set the FormBorderStyle to None to get a borderless form.

Thanks,
ramz_g
ramz_g  Monday, July 27, 2009 3:01 PM
I'm guessing your are talking about the system menu. A borderless form indeed doesn't have one. Get it back by pasting this code anywhere in your form:

protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.Style |= 0x80000; // Turn on WS_SYSMENU
return cp;
}
}

Hans Passant.
  • Marked As Answer byramz_g Tuesday, July 28, 2009 6:06 AM
  •  
nobugz  Monday, July 27, 2009 4:30 PM
Please post any winform/control related questions to the Windows Forms General forum. The C# forum is for C# related questions on the language constructs and not indirect component usage. thx I will move it this time....
William Wegerson (www.OmegaCoder.Com)
OmegaMan  Monday, July 27, 2009 4:54 PM
Hi,

Thanks for the reply... That helped a lot... However, I have another issue with the system menu... Currently, when I try to maximize my form, a part of the form is cut off on the right side... I guess I should override the events in the system menu... Please suggest on How I can override the events of the system menu items?

Thanks,
ramz_g
ramz_g  Tuesday, July 28, 2009 6:06 AM
Hi All,

This issue has been resolved. This helped a lot :

protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= 0x80000; // Turn on WS_SYSMENU
return cp;
}
}

Thanks a lot for your help,
ramz_g
ramz_g  Tuesday, July 28, 2009 12:16 PM

You can use google to search for other answers

 

More Threads

• How to know which item in ListBox is slected?
• Localization for custom User Controls not Translating with rest of application when installed
• Calendar/Scheduler
• Seeking code showing SQL 2008 Heirarchy ID data bound to a tree control
• Windows XP control
• Control Similar to Taskbar
• modify the contents of a text box on a windows app from a class
• MdiWindowListItem oes not reflect changed form text
• using resources for bitmaps on buttons
• listview gridline problem..