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...
Printable View
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...
Check this ;)
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:D
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.
Thank you Very VERY VERY Much! hehe
However, what do i do about the taskbar? it goes under that? now what do i do?
building on zynder's code, you can combine the Me.Top and Me.Left by
using Me.Move
Quote:
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.
I found what i needed to find. Thank you all for you help.
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
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