Faceți căutări pe acest blog

vineri, 30 ianuarie 2015

How can I prevent undocking a docked form

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.
To prevent undocking the form, it's enough to cut the title bar.

But the form can still be closed with CTRL+F4
To prevent closing the form, it's enough to intercept keydown.

(See http://www.tek-tips.com/faqs.cfm?fid=7701)

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 
 

Related posts
http://praisachion.blogspot.com/2017/08/easter-eggs-4.html
http://praisachion.blogspot.com/2017/08/easter-eggs-3.html
http://praisachion.blogspot.com/2017/08/easter-eggs-2.html
http://praisachion.blogspot.com/2017/08/easter-eggs-1.html

http://praisachion.blogspot.com/2016/02/interceptin-ctrlshiftenter.html
http://praisachion.blogspot.com/2015/06/detect-keyup-like-mouseup.html
http://praisachion.blogspot.com/2015/01/how-can-i-prevent-undocking-docked-form.html

Niciun comentariu:

Trimiteți un comentariu