|
-
Mar 31st, 2007, 08:13 AM
#1
Thread Starter
Lively Member
[RESOLVED] Position my Form on the bottom right on load?
What I want to do is have it so when, frmToast is loaded, the form is positioned to the users Bottom Right part of the screen.
Basically where the MSN Toast (being the "person has signed in” thing) is…
Your Help would be very much appreciated...
-
Mar 31st, 2007, 08:34 AM
#2
Re: Position my Form on the bottom right on load?
Check this
-
Mar 31st, 2007, 08:48 AM
#3
Thread Starter
Lively Member
Re: Position my Form on the bottom right on load?
This is a very good example. However Im looking for just a small bit of code that i can chuck into Form_Load()
Can anyone help me?
plz
-
Mar 31st, 2007, 09:07 AM
#4
Re: Position my Form on the bottom right on load?
Try...
vb Code:
Private Sub Form_Load()
'bottom right
Me.Top = (Screen.Height) - (Me.Height)
Me.Left = (Screen.Width) - (Me.Width)
End Sub
Private Sub Form_Load()
'bottom left
Me.Left = Screen.Width - Me.ScaleWidth
Me.Top = Screen.Height - Me.ScaleHeight
End Sub
Hope it helps. Once again I have no VB installed here. Might encounter errors.
-
Mar 31st, 2007, 09:48 AM
#5
Thread Starter
Lively Member
Re: Position my Form on the bottom right on load?
Thank you Very VERY VERY Much! hehe
However, what do i do about the taskbar? it goes under that? now what do i do?
-
Mar 31st, 2007, 10:54 AM
#6
Addicted Member
Re: Position my Form on the bottom right on load?
building on zynder's code, you can combine the Me.Top and Me.Left by
using Me.Move
object.Move left, top, width, height
The Move method syntax has these parts:
Part Description
object Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object.
left Required. Single-precision value indicating the horizontal coordinate (x-axis) for the left edge of object.
top Optional. Single-precision value indicating the vertical coordinate (y-axis) for the top edge of object.
width Optional. Single-precision value indicating the new width of object.
height Optional. Single-precision value indicating the new height of object.
Do not use if shrinkwrap is broken or missing!
I'm learning how to fish, too!
-
Mar 31st, 2007, 10:55 AM
#7
Thread Starter
Lively Member
Re: Position my Form on the bottom right on load?
I found what i needed to find. Thank you all for you help.
-
Mar 31st, 2007, 10:59 AM
#8
Addicted Member
Re: [RESOLVED] Position my Form on the bottom right on load?
EDIT: Late posting - great that you got it done!
here is some code to CENTER the form in the screen, accounting for the taskbar, maybe you can modify it to work for bottom/right.
from http://www.expressnewsindia.com/c4/ex1/C1028.html / www.freevbcode.com
vb Code:
Option Explicit
Private Declare Function GetSystemMetrics _
Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetWindowLong Lib _
"user32" Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Const SM_CXFULLSCREEN = 16
Private Const SM_CYFULLSCREEN = 17
Public Function FormCenter(frmObj As Form) As Boolean
'Centers form on screen, accounting for taskbars such as
'the windows taskbar, MS Office taskbar, etc.
'Pass the form you want to center as the frmObj
'parameter. Returns true if successful, false if not.
'Adapted from an example in VBPJ Tech Tips, 10th Edition
'scale mode of form must be
'vbTwips, otherwise won't work
'if you think that form's scale mode might be something else, incorporate
'the perpixelx and perpixels y functions for metrics other than twips:
'http://www.freevbcode.com/ShowCode.Asp?ID=102
Dim lLeft As Long
Dim lTop As Long
On Error Resume Next
If frmObj.ScaleMode <> vbTwips Then Exit Function
lLeft = (Screen.TwipsPerPixelX * _
GetSystemMetrics(SM_CXFULLSCREEN)) / 2
lLeft = lLeft - (frmObj.Width / 2)
lTop = (Screen.TwipsPerPixelY * _
GetSystemMetrics(SM_CYFULLSCREEN)) / 2
lTop = lTop - (frmObj.Height / 2)
frmObj.Move lLeft, lTop
FormCenter = Err.Number = 0 And Err.LastDllError = 0
End Function
Last edited by kewakl; Mar 31st, 2007 at 11:00 AM.
Reason: Late
Do not use if shrinkwrap is broken or missing!
I'm learning how to fish, too!
-
Apr 2nd, 2007, 06:44 AM
#9
Re: [RESOLVED] Position my Form on the bottom right on load?
Keep it simple:
Code:
Option Explicit
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" ( _
ByVal uAction As Long, _
ByVal uParam As Long, _
lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Const SPI_GETWORKAREA As Long = 48
Private Type RECT
lLeft As Long
lTop As Long
lRight As Long
lBottom As Long
End Type
Private Sub Form_Load()
Dim deskRECT As RECT
Call SystemParametersInfo(SPI_GETWORKAREA, 0&, deskRECT, 0&)
Me.Top = deskRECT.lBottom * Screen.TwipsPerPixelY - Me.Height
Me.Left = deskRECT.lRight * Screen.TwipsPerPixelX - Me.Width
End Sub
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
|