Hi, this is silly but no right click menu (maximise, restore, close, etc) comes up, when i right click on the icon of the borderless form in the taskbar.
i have set showInTaskbar to true for the borderless form
and border to none.
Also how can we change the right click menu of the taskbar for our programs, say add another item (always on top) under the close option.
thanks in advance.

Borderless Form -- Right Click Menu of Taskbar
Yadira
just a thing may be u can add to ur sites mdi section. is to arrange the windows like the properties windows of visual studio.like u can dock/undock them, float them. and may be arrange them around other ways.
just a suggestion for a nice site
thanks again.
LalitSRana
Do you know a way of keeping the taskbar system menu for a borderless window I really need to have a borderless window, but when I set its borderstyle to none, then no system menu is displayed when I right click the window tab in the taskbar :-(
thank you very much
Thibaud
satyakrishna
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const WS_CAPTION As Int32 = &HC00000
cp.Style = cp.Style And Not WS_CAPTION
Return cp
End Get
End Property
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
const int WS_CAPTION = 0xC00000;
cp.Style = cp.Style &~ WS_CAPTION;
return cp;
}
}
This results not only in you keeping the WindowMenu, but also in your TaskBarWindow showing the Window Text.
Modification of the WindowMenu requires Interop and you will find an example on my site:
http://www.dotnetrix.co.uk/menus.html
PaulYuk_MS
And I didn't know about the CS_DROPSHADOW, it's quite a nice effect :-)
Your customized border form looks great. I suppose you modified the form Region, and checked WM_NCHITTEST in the WndProc That's what I did in my own custom form.
I also tried to draw a size grip in the lower right corner and make it react well, but did not manage to do so. Do you know how to do so
Did you change WindowState to make the window minimize/maximized/restored when user clicks your own buttons, or did you just change the window bounds
Thanks for this information!
Thibaud
sammye
I just saw your shaped form example (http://www.dotnetrix.pwp.blueyonder.co.uk/misc.html), in particular your sizing label. I had done exactly the same at first for sizing my borderless form, but it was not completly convenient, because the label could be covered by a status bar.
Instead I override WndProc, and did a hack on the WM_NCHITTEST message, both to indicate what part of the form should be 'movable', and what part should be handled as a sizing border:
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
// Convert to client co-ordinates of parent
Point p = FindForm().PointToClient(new Point((int)m.LParam));
int x = p.X;
int y = p.Y;
Rectangle rect = Bounds;
if (x < 5)
{
if (y < 5)
m.Result = new IntPtr(HTTOPLEFT);
else if (y >= this.Height - 5)
m.Result = new IntPtr(HTBOTTOMLEFT);
else
m.Result = new IntPtr(HTLEFT);
}
else if (x >= this.Width - 5)
{
if (y < 5)
m.Result = new IntPtr(HTTOPRIGHT);
else if (y >= this.Height - 5)
m.Result = new IntPtr(HTBOTTOMRIGHT);
else
m.Result = new IntPtr(HTRIGHT);
}
else if (y < 5)
m.Result = new IntPtr(HTTOP);
else if (y >= this.Height - 5)
m.Result = new IntPtr(HTBOTTOM);
else
m.Result = new IntPtr(HTCAPTION); // form can be moved
break;
default: base.WndProc(ref m); break;
}
}
This was working great, except that when I now add the WS_SYSMENU style to the window, it is no more resizable! The HTxxx values are ignored (except HTCAPTION which still makes the form movable by dragging it) :-(
Did you know about this way of making the form sizable (and movable), and do you know a way of making it sizable when WS_SYSMENU is set I noticed it can be sizable again if I set the WS_THICKFRAME style, but then Windows draw the form border, overlapping my own customized border!
May be that's why you implemented your own sizing handling, and so I should do the same, and find a way of forcing the grip to be on top of other controls
Ronald Lips
Hi Thibaud,
The existing example is a quick and dirty way to implement the solution, but the newer example that I was working on uses WM_NCHITTEST to implement the form resizing and MenuBar interaction.
I set the WS_THICKFRAME style so that the form is resizable, and clipped the NonClient Area out by asigning a Region inside the ClientArea. I don't think this works so well in Vista though and so a better solution may be to handle the WM_NCCALCSIZE message and decrease the border to zero width/height.
Hopefully, I'll get time to take another look at this soon, and upload an updated example which works in Vista as well as the other flavours of Windows.
garthish
Sifi
Just add the following code to a form (removing any styles which are irrelevant).
I'm sure you can convert to C# without problem should you need it.
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
'If this form is inherited, the IDE needs this style 'set so that it's coordinate system is correct. Const WS_CHILDWINDOW As Int32 = &H40000000 'The following two styles are used to clip child 'and sibling windows in Paint events. Const WS_CLIPCHILDREN As Int32 = &H2000000 Const WS_CLIPSIBLINGS As Int32 = &H4000000 'Add a Minimize button (or Minimize option in Window Menu). Const WS_MINIMIZEBOX As Int32 = &H20000 'Add a Maximum/Restore Button (or Options in Window Menu). Const WS_MAXIMIZEBOX As Int32 = &H10000 'Window can be resized. Const WS_THICKFRAME As Int32 = &H40000 'Add A Window Menu Const WS_SYSMENU As Int32 = &H80000'Detect Double Clicks
Const CS_DBLCLKS As Integer = &H8 'Add a DropShadow (WinXP or greater). Const CS_DROPSHADOW As Integer = &H20000Dim cp As CreateParams = MyBase.CreateParams
cp.Style = WS_CLIPCHILDREN Or WS_CLIPSIBLINGS _
Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX _
Or WS_SYSMENU Or WS_THICKFRAME
If Me.DesignMode Then
cp.Style = cp.Style
Or WS_CHILDWINDOW End If
Dim ClassFlags As Integer = CS_DBLCLKS Dim OSVER As Integer = Environment.OSVersion.Version.Major * 10OSVER += Environment.OSVersion.Version.Minor
If OSVER >= 51 Then ClassFlags = ClassFlags Or CS_DROPSHADOWcp.ClassStyle = ClassFlags
Return cpEnd Get
End PropertyI was working on a new example which shows how to resize and drag borderless forms around as well as simulate a MenuBar with the help of ContextMenus, but I got distracted and never finished it.
There's a screenshot (just to tease) on my site, but no example code just yet.
http://www.dotnetrix.co.uk/images/nonclientgraphicspath.png