473,467 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can Borderless forms have a context menu in the start bar?

Hi
I'm currently developping a skinnable form by using a borderless form
(Form.FormBorderStyle=None). Is it the right way to go in the first place?
if it is. Assuming that when there is no border to the form there is no
context menu when you right-click on your form in the start bar too (the one
with Restore, Move, Size, Close et al.)... How can I make this context menu
work again? Is there a way to tell the form to make it work even if the form
is borderless?

thanks

ThunderMusic
Nov 20 '06 #1
5 2522
I found the answer on this page http://www.dotnetrix.co.uk/menus.html
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi
I'm currently developping a skinnable form by using a borderless form
(Form.FormBorderStyle=None). Is it the right way to go in the first place?
if it is. Assuming that when there is no border to the form there is no
context menu when you right-click on your form in the start bar too (the
one with Restore, Move, Size, Close et al.)... How can I make this
context menu work again? Is there a way to tell the form to make it work
even if the form is borderless?

thanks

ThunderMusic

Nov 21 '06 #2
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:ed**************@TK2MSFTNGP02.phx.gbl...
>I found the answer on this page http://www.dotnetrix.co.uk/menus.html
That would be http://www.dotnetrix.co.uk/misc.html

I have been working on better examples, but have put them aside for the
moment as I work on other stuff, but if you want to make the form resizable,
then I would suggest that you leave the FormBorderstyle as is and set the
Caption to "" and ControlBox to False. This will leave you with a 3d border
around the form which needs to be trimmed off when building the region, but
it will enable the Size option in the Window Menu.

If you then define a Border Region you can send WM_NCLBUTTONDOWN messages,
in response to mousedown within the region, with one of the following
NCHITTEST flags as the wParam in order to get window sizing when dragging by
an edge.

HTLEFT
HTRIGHT
HTTOP
HTTOPLEFT
HTTOPRIGHT
HTBOTTOM
HTBOTTOMLEFT
HTBOTTOMRIGHT

Also make sure you disable Visual Styles on the window as this will increase
painting performance and you won't be using them on a skinned window. The
following is the method that I use to disable Visual Styles on the form,
whilst still allowing them on the controls:

<DllImport("uxtheme.dll")_
Public Shared Function SetWindowTheme(ByVal hwnd As IntPtr, _
ByVal pszSubAppName As String, ByVal pszSubIdList As String) As IntPtr
End Function

Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
SetWindowTheme(Me.Handle, String.Empty, "")
End If
End Sub
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Nov 21 '06 #3
thanks a lot... I'll look into it... ;)
Right now, I'm managing resizing by hand by looking where the cursor is and
displaying the good cursor at the right time and sizing when I have to size
by modifying Left, Top, Width and Height... I have a bug tought when I'm
sizing from Left or Top, The window start to move around when it's width and
height = 0. That was the only way I found I could do it with borderless
windows... for now, I will try to use the "more standard way" you explain
here and fill the blanks with what is explained on the site... ;) For the
3D Border I must get rid of it because I use the TransparencyKey of the .Net
Form, so even if my background it completely transparent, the border still
show because I don't have to use region by now... But the example on the
site already get rid of the border even if the window is sizable.

if you have better examples for this exact same purpose, would you be so
kind as to post them here or on my e-mail please? (just get rid of the
NoSpAm at the beginning, the @NoSpAm.com at the end and decode...) ;) and
please indicate in the subjet you are from the newsgroups because your
message will probably end up in my junk folder, so I must be able to
recognize you... ;)

thanks again...

ThunderMusic

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]wrote in
message news:e7**************@TK2MSFTNGP04.phx.gbl...
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:ed**************@TK2MSFTNGP02.phx.gbl...
>>I found the answer on this page http://www.dotnetrix.co.uk/menus.html

That would be http://www.dotnetrix.co.uk/misc.html

I have been working on better examples, but have put them aside for the
moment as I work on other stuff, but if you want to make the form
resizable, then I would suggest that you leave the FormBorderstyle as is
and set the Caption to "" and ControlBox to False. This will leave you
with a 3d border around the form which needs to be trimmed off when
building the region, but it will enable the Size option in the Window
Menu.

If you then define a Border Region you can send WM_NCLBUTTONDOWN messages,
in response to mousedown within the region, with one of the following
NCHITTEST flags as the wParam in order to get window sizing when dragging
by an edge.

HTLEFT
HTRIGHT
HTTOP
HTTOPLEFT
HTTOPRIGHT
HTBOTTOM
HTBOTTOMLEFT
HTBOTTOMRIGHT

Also make sure you disable Visual Styles on the window as this will
increase painting performance and you won't be using them on a skinned
window. The following is the method that I use to disable Visual Styles on
the form, whilst still allowing them on the controls:

<DllImport("uxtheme.dll")_
Public Shared Function SetWindowTheme(ByVal hwnd As IntPtr, _
ByVal pszSubAppName As String, ByVal pszSubIdList As String) As IntPtr
End Function

Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then
SetWindowTheme(Me.Handle, String.Empty, "")
End If
End Sub
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html

Nov 21 '06 #4
The existing example on my site uses the same method that you are using to
resize the form. The newer example that I have been working on, uses the
windows resizing methods, similar to the move a borderless form example on
my site. This method will not work with the current example as the Size
menuitem of the Window menu needs to be enabled. If your form does not have
a border it is not sizable and so the menuitem will be grayed out.

If you are using the forms TransparencyKey to shape the form, then the new
method is probably not suitable as it requires that you define a region so
that you can Edge Detect and decide which of the 8 directions you need to be
sizing in.

The examples that I'm working on are not complete and are VB only at the
moment (I don't write the C# version until I am happy with the VB version).
I won't be giving out or posting the examples until they are complete, but
feel free to ask if you run into problems.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Nov 22 '06 #5
I have started a new thread with a problem I run into, maybe you already
seen this kind of behavior?

thanks for the help...

ThunderMusic

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]wrote in
message news:OY**************@TK2MSFTNGP03.phx.gbl...
The existing example on my site uses the same method that you are using to
resize the form. The newer example that I have been working on, uses the
windows resizing methods, similar to the move a borderless form example on
my site. This method will not work with the current example as the Size
menuitem of the Window menu needs to be enabled. If your form does not
have a border it is not sizable and so the menuitem will be grayed out.

If you are using the forms TransparencyKey to shape the form, then the new
method is probably not suitable as it requires that you define a region so
that you can Edge Detect and decide which of the 8 directions you need to
be sizing in.

The examples that I'm working on are not complete and are VB only at the
moment (I don't write the C# version until I am happy with the VB
version). I won't be giving out or posting the examples until they are
complete, but feel free to ask if you run into problems.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html

Nov 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alireza Haghshenass | last post by:
Dear All, I am facing a problem which I could not solve. I am writing an application which uses a notify icon and a context menu bound to it to show modal dialog forms. When these forms is shown...
2
by: fperfect13 | last post by:
Hi, I have the folowing exception Exception : System.NullReferenceException: Object reference not set to an instance of an object. 00000019 3:30:48 PM at...
5
by: trint | last post by:
I've tried everything... function showRemote() { self.name = ""; // names current window as "main" var windowprops = "border=0,titlebar=0,toolbar=0,location=0,directories=0,status=0, " +...
7
by: gabe | last post by:
I've been looking unsuccessfully for resources on building apps that show up on the desktop's context menu. Any ideas?
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
0
by: nave11 | last post by:
How to add Context menu to a class derived from System.Windows.Forms.Label ? This label will be dragged on a designer surface on runtime. For example, to add a context menu with "Copy" and "Paste"...
8
by: James Arnold | last post by:
I currently have a borderless form, which I am subclassing to allow dragging & dropping: Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case 132 'Click & Drag Form...
0
by: Patel | last post by:
Hi All, I am doing one INTERESTING work with Context Menu Strip. I am trying to insert a custom control / .Net control in Context menu as a context menu strip. I tried inserting MonthCalender in...
5
by: sierra7 | last post by:
Hi I have been writing Access applications for some years now and have moved away from from the 'Switchboard' type of opening form to using a menubar accross the top of the screen and borderless...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.