Changing Location at runtime with peAnchors << Back



If you set the peAnchors property for a UI control, but you decide to change the size/location of said UI control at run time (see the following example), you need to reset pbAnchorCreated and call DoCreateAnchors. Failure to do so will result in said UI control "snapped back" to its original size/location when you start resizing your view/modal panel. Compile the following example without line 16 and 17, you will see the "snap back" that I was talking about.

This is a well known, and yet undocumented trick (As of DataFlex 20.0 Alpha 2). Every VDF developer will probably run into this problem at some point. If you ask for help on the DAW forum, the VDF veterans and/or DAW employees are going to give you the answer right away. And yet, it is still not documented. Do a search on the word "DoCreateAnchors" in the DAW support forum to see for yourself.

Use Windows
Use DfTreeVw

Object oPanel is a ModalPanel
	Set pbSizeToClientArea to True
	Set Size to 200 100
	Set Border_Style to Border_Thick
	Object oButton is a Button
		Set Location to 185 0
		Set peAnchors to anBottom
		Procedure OnClick
			Integer iLoc
			Send Adjust_Logicals
			Get Location to iLoc
			Set Location to (HI(iLoc)-10) (Low(iLoc))
			Set pbAnchorCreated To False
			Send DoCreateAnchors 0 0
		End_Procedure
	End_Object // oButton
End_Object // oPanel
Send Popup of oPanel
Free Web Hosting