Add system menu to form with FormBorderStyle = None

M

Mark Ingram

Hi, ive got a form with FormBorderStyle set to None (i am using custom
regions to determine the shape of the form). But i would like to be able
to display the standard system menu when the user right clicks the
application in the taskbar. How can i do this?
 
N

Nicholas Paldino [.NET/C# MVP]

Mark,

I haven't tried this, but you could call the GetSystemMenu API through
the P/Invoke layer. This will return the handle to the system menu for the
window to you.

Once you have that, you can pass the handle to the TrackPopupMenu or
TrackPopupMenuEx API function, again through the P/Invoke layer.

Hope this helps.
 
M

Mick Doherty

Mark Ingram said:
Hi, ive got a form with FormBorderStyle set to None (i am using custom
regions to determine the shape of the form). But i would like to be able
to display the standard system menu when the user right clicks the
application in the taskbar. How can i do this?

The shaped form example on my site includes a Sytem Menu, you should be able
to extract what you need from it.
http://www.dotnetrix.co.uk/misc.html --> An example of a moveable/resizable
shaped form.
 
M

Mark Ingram

Mick said:
The shaped form example on my site includes a Sytem Menu, you should be able
to extract what you need from it.
http://www.dotnetrix.co.uk/misc.html --> An example of a moveable/resizable
shaped form.


On your page you say:

"With a little InterOp you can draw a standard TitleBar onto which you
can place custom buttons, and this solution is much simpler than that of
OwnerDrawing the NonClient Area to achieve the same effect. "

How can i draw the minimise, maximise, close etc, buttons? Where are
they stored?
 
M

Mick Doherty

Depends on how you want to draw them.
Non Visual Styled Caption Buttons can be drawn via the ControlPaint class.
Visual Styled buttons need to drawn with Interop using OpenThemeData(),
DrawThemeBackground(), CloseThemeData(). The definitions are stored in the
header files 'uxtheme.h' and 'Tmschema.h' or you may find them on
www.pinvoke.net

There may be ways to draw Visual Styled buttons without Interop in VS2005,
but I can't confirm this as I don't have it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top