INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Forms

How can I prevent undocking a docked form by vgulielmus
Posted: 13 Feb 14 (Edited 30 Jan 15)

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 

Vilhelm-Ion Praisach

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close