I would like to create a winform like this:
I already accomplished the visual effect (like as seen in the picture), by following other question. But I can't disallow resizing the form, since to have the border, it must be "Sizeable". Someone suggested putting Minimum Size and Maximum Size values equal to the current Form Size. This solves part of the issue, but when the mouse hovers the border, it still shows the double-ended arrow, suggesting the form is resizeable. Is there any way of disable this cursor change? My goal is to mimic the original systray popups in Windows 7, like the network, sound, etc.
Thank you!
Add a message handler to your form and handle WM_NCHITTEST. When the original returns HTSIZE (etc.), return HTNONE or HTCAPTION.
Something like this question should get you started.
To explain:
When Windows wants to know which cursor to use for your window, it first sends you a WM_NCHITTEST
message (non-client hit test). This message is handled by the WndProc
method. Your window is supposed to return one of the HT*
codes to tell Windows which part of the window the mouse is over. For example, return HTCAPTION
for the caption area, HTCLIENT
for the client area, or HTSIZENESW
for the bottom left sizing corner. The default message handler (calling base.WndProc
) deals with this for standard windows.
We don't have a standard window.
What we're trying to do here is ask the original window what the mouse is over. If it returns any of the HTSIZE*
values, we want to replace that return value with HTNONE
(for no action) or HTCLIENT
(if you want the cursor to be treated as inside the window -- probably not this one) or HTCAPTION
(if you want to be able to drag the window by the edges -- might be useful).