Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Center Form on Rotation
Message
 
 
To
19/01/2017 10:30:25
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01646851
Message ID:
01646857
Views:
47
>>Hi,
>>Running an app (VFP 9) on a tablet.
>>Initially a form is centered. But when a user rotates the tablet (e.g. from portrait to landscape), how to you make the form to be centered again?
>>TIA
>
>Left my tablet at home, so no direct way to test this, but I think that setting DisplayOrientation will mimic the rotation induced by the user.
>
>
>#DEFINE IS_TABLET		.F.
>
>_Screen.WindowState = 1
>
>LOCAL Test AS AutoCenteredTopForm
>
>m.Test = CREATEOBJECT("AutoCenteredTopForm")
>m.Test.Show()
>
>#IF IS_TABLET
>
>READ EVENTS
>
>#ELSE
>
>LOCAL Orientation AS Integer
>LOCAL CurrentOrientation AS Integer
>
>m.CurrentOrientation = _Screen.DisplayOrientation
>
>FOR m.Orientation = 0 TO 3
>
>	_Screen.DisplayOrientation = m.Orientation
>	WAIT WINDOW "About to rotate..." TIMEOUT 3
>
>ENDFOR
>
>_Screen.DisplayOrientation = m.CurrentOrientation
>_Screen.WindowState = 0
>
>#ENDIF
>
>m.Test.Release()
>m.Test = .NULL.
>
>DEFINE CLASS AutoCenteredTopForm AS Form
>
>	AutoCenter = .T.
>	ShowWindow = 2			&& as Top Form
>	Desktop = .T.			&& on Desktop
>	Caption = "Auto-Centered Top-Form"
>	AlwaysOnTop = .T.
>	Width = SYSMETRIC(1) / 2
>	Height = SYSMETRIC(2) / 2
>	
>	FUNCTION Init
>	
>		BINDEVENT(_Screen, "DisplayOrientation", This, "ReCenter")
>	
>	ENDFUNC
>	
>	FUNCTION Destroy
>	
>		UNBINDEVENTS(_Screen, "DisplayOrientation", This, "ReCenter")
>		CLEAR EVENTS
>	
>	ENDFUNC
>	
>	PROCEDURE ReCenter
>		This.AutoCenter = .F.
>		This.AutoCenter = .T.
>	ENDPROC
>
>ENDDEFINE
>
First, thank you for the code.
Do I understand correctly that this code has to be at the Top of the application and will apply to every form?
I thought I would need to add the "centering" code in every form.
Could you, please, clarify?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform