c# - How to keep border on a fixed form? -


i want windows forms form keep window border, while having no title bar , being non-resizable (fixed) (similarly window previews, when 1 hovers mouse on button on taskbar):

enter image description here

setting controlbox false , text "" removes title bar , keeps border want to, border visible if form sizeable. when set formborderstyle 1 of fixed* styles, border disappears:

enter image description here

how may achieve described behavior?

you can pinvoke setwindowslong , adjust window styles:

// run in linqpad private const int gwl_style = -16; private const int ws_sizebox = 0x040000; [dllimport("user32.dll", setlasterror = true)] private static extern int getwindowlong(intptr hwnd, int nindex); [dllimport("user32.dll")] private static extern int setwindowlong(intptr hwnd, int nindex, int dwnewlong); void main() {     var form = new form();     form.controlbox = false;     form.formborderstyle = formborderstyle.fixeddialog;     form.show();     setwindowlong(form.handle, gwl_style, getwindowlong(form.handle, gwl_style) | ws_sizebox); } 

after have prevent resizing manually though.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -