|
-
Jul 7th, 2000, 07:57 AM
#1
Thread Starter
Hyperactive Member
Did the subject get ya to look?
I have seen some references but just cant find any right now. When positioning my form I want it to be on the lowest possible location, but if any taskbar/appbars are there, my form would of course need to be on higher up on the screen.
Here is the code I have right now
Code:
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Sub CenterForm(formName As Form)
' Position a form on the screen
'formName.Top = (Screen.Height - formName.Height)
MsgBox Screen.Height & vbCrLf & GetSystemMetrics(SM_CYSCREEN) * Screen.TwipsPerPixelY
formName.Top = ((GetSystemMetrics(SM_CYSCREEN) * Screen.TwipsPerPixelY) - formName.Height)
formName.Left = 0
'formName.Width = Screen.Width
formName.Width = (GetSystemMetrics(SM_CXSCREEN) * Screen.TwipsPerPixelX)
End Sub
But it doesnt account for the taskbar, it puts the form on lowest location possible and since the taskbar is there it goes over my form, ugg, which isnt too cool.
Thanks
-
Jul 7th, 2000, 08:26 AM
#2
Lively Member
If you're willing to add the SysInfo control to your project, you can do it the easy way: 
This example tests the size of the active form after a change in screen resolution and adjusts the size of the form if it exceeds the visible screen area. To run this example, put a SysInfo control on a form. Paste this code into the DisplayChanged event of the SysInfo control. Run the example, then change the screen resolution.
Code:
Private Sub SysInfo1_DisplayChanged()
If Screen.ActiveForm.Width > SysInfo1.WorkAreaWidth Then
Screen.ActiveForm.Left = SysInfo1.WorkAreaLeft
Screen.ActiveForm.Width = SysInfo1.WorkAreaWidth
End If
If Screen.ActiveForm.Height > SysInfo1.WorkAreaHeight Then
Screen.ActiveForm.Top = SysInfo1.WorkAreaTop
Screen.ActiveForm.Height = SysInfo1.WorkAreaHeight
End If
End Sub
If you still want api, erm, I'll have to find what api calls SysInfo is using to get it's WorkArea properties.
-
Jul 7th, 2000, 08:36 AM
#3
Thread Starter
Hyperactive Member
I think I may have to use SHAppBarMessage, and then query for position, but the form I have is not really an appbar, I just want it to have the lowest spot availabe on the screen but higher then any tool/task bar.
-
Jul 7th, 2000, 09:23 AM
#4
Thread Starter
Hyperactive Member
How do I get the available screen space which takes into effect the task/app bars?
Anyone?
-
Jul 7th, 2000, 09:29 AM
#5
Lively Member
What is wrong with including the SysInfo control - sure it's a bit big to do just that job, but if it does the job then I'd go with it, rather than worrying about low-level api stuff that we're not sure about?
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
|