|
-
January 22nd, 2000, 02:55 PM
#1
Screen positioning question...
i have this code. what it does is displays the splash screen, then slides, from the left, the first form over the splash screen, then the splash screen disappears. well, iv "hard coded" the top and left property positions of both the splash screen(frmSplash) and the first form(frmMain) so that, on my screen, the both show up in the middle. the problem is, i cant set the startup position property to center on either of the forms because that messes up the code, they have to be set on 0-manual. what im wanting to do is some how find the the dimensions of the current screen and then do some math so that the forms will show up in the middle of that screen. here is the code for the "form effects"
Option Explicit
Private frmMainLeft As Single
' Splash screen effects
'
' Displays image to size of form regardless of
' screen resolution
' Start wiping in 3 seconds.
Timer1.Interval = 3000
End Sub
Private Sub Timer1_Timer()
Static done_before As Boolean
Dim new_left As Single
' See if this is the first time.
If Not done_before Then
' It's the first time. Start wiping the
' main form over the splash screen.
done_before = True
Timer1.Interval = 25
frmMainLeft = frmMain.Left
frmMain.Left = -frmMain.Width
frmMain.Visible = True
End If
new_left = frmMain.Left + 240
If new_left > frmMainLeft Then
new_left = frmMainLeft
Unload Me
End If
frmMain.Left = new_left
End Sub
if any one could help me, id greatly appreciate it! thanks
Aaron
-
January 24th, 2000, 11:52 AM
#2
Re: Screen positioning question...
To determine the current screen resolution you can use the Screen object. Since the height and width are given in twips, I usually convert them to pixels. The following code is what I use for determining the current display resolution.
'----------------------------------------------
Public Function DisplayResolution() As Byte
'--------------------------------------------------------------
' Determines the current display resolution and returns
' the resolution-identifying constant.
'
' Returns: Display_640x480 (default if resolution is not recognized)
' Display_800x600
' Display_1024x768
' Display_1152x864
' Display_1280x1024
'--------------------------------------------------------------
Select Case Screen.Width / Screen.TwipsPerPixelX
Case 640!
DisplayResolution = Display_640x480
Case 800!
DisplayResolution = Display_800x600
Case 1024!
DisplayResolution = Display_1024x768
Case 1152!
DisplayResolution = Display_1152x864
Case 1280!
DisplayResolution = Display_1280x1024
Case Else
' If unrecognized, assume 640x480.
' Design should accommodate this resolution.
DisplayResolution = Display_640x480
End Select
End Function
'-------------------------------------------------
I like to use enumerated constants as a return value for this function, which you can define as you see fit.
Good Luck,
Greg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|