Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Center Form on Rotation
Message
From
19/01/2017 10:30:25
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01646851
Message ID:
01646856
Views:
73
>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
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform