Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I prevent undocking a docked form

Forms

How can I prevent undocking a docked form

by  vgulielmus  Posted    (Edited  )
A docked toolbars can be "glued" with a few lines of codes (e.g. NODEFAULT in events like MouseDown, DblClick).
A docked form ignores all this, and the properties like movable, are either ignored either read-only.
But with a little trick, undocking can be prevented even for forms.
It's enough to cut the titlebar.

[code Foxpro]PUBLIC oFrm
oFrm=CREATEOBJECT("MyForm")
oFrm.show

DEFINE CLASS MyForm as Form
dockable=1
ADD OBJECT cmd as commandbutton
PROCEDURE init
This.Dock(2) && dock to the right side
* cut the title bar so the window cannot be moved or undocked
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, String bRedraw
Declare Long CreateRectRgn IN WIN32API Long X1, Long Y1, Long X2, Long Y2
SetWindowRgn(thisform.hwnd, CreateRectRgn(0,SYSMETRIC(4)+SYSMETRIC(9)/2,This.width+2*SYSMETRIC(3),This.height+2*SYSMETRIC(4)+SYSMETRIC(9)/2), "True")
BINDEVENT(This.HWnd,0x0100,This,"preventclosemethod") && intercept keydown to prevent closing the window with ctrl+f4
ENDPROC
PROCEDURE preventclosemethod
LPARAMETERS p1,p2,p3,p4
ENDPROC
ENDDEFINE[/code]

Vilhelm-Ion Praisach
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top