Γεια σου Γιώργο,
σε ένα module έχω τον παρακάτω κώδικα
και στο resize της φόρμας καλώ το MyForm_Resize:AddHandler Resize, AddressOf MyForm_Resize
Το έχω δοκιμάσει σε HTC Touch Pro και παίζει.
Καλύ τύχη.
#Region "Handle Screen Orientation"
' Add a class member variable to
' store that the orientation has changed.
Dim OrientationChanged As Boolean = False
Public Sub MyForm_Resize(ByVal sender As Object, ByVal e As EventArgs)
If (SystemSettings.ScreenOrientation <> ScreenOrientation.Angle0) Then
OrientationChanged = True
End If
End Sub
Public Function CheckOrientation() As Boolean
' orientationChanged is set to true in resize if it is
' detected that the orientation of the device has changed.
If OrientationChanged Then
' Attempt to change the display back to portrait mode.
Try
SystemSettings.ScreenOrientation = ScreenOrientation.Angle0
' Now that the orientation is back to portrait mode
' Do not attempt to change it again.
OrientationChanged = False
Catch ex As Exception
MsgBox("Failed to change the display mode." & vbCrLf & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End If
Return True
End Function
' Use the CheckOrientation() method before rendering occurs.
' All rendering for each frame occurs here.
Public Sub Render()
' If the device is not oriented properly,
' some display drivers may not work.
If Not CheckOrientation() Then
Return
End If
' Rendering code omitted here.
End Sub
#End Region