"John" <Jo**@nospam.infovis.co.uk> wrote in
news:41**********************@news-text.dial.pipex.com:
Hi
I have a small pop non-dialog form that I need to appear towards the
right side of the screen. Is there a way to achieve this?
Regards
You might try putting this code in a standard module:
***************
Option Explicit
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As Rectangle) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Const HWND_TOP As Long = 0
Private Const SM_CYVTHUMB As Long = 9
Private Const SWP_NOZORDER As Long = &H4
Private Type Dimensions
Width As Long
Height As Long
End Type
Private Type Rectangle
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Sub PlaceFormRight(ByRef Form As Form)
Dim AccessRectangle As Rectangle
Dim AccessWindow As Long
Dim FormDimensions As Dimensions
Dim FormRectangle As Rectangle
Dim FormWindow As Long
Dim NewLeft As Long
AccessWindow = hWndAccessApp
GetWindowRect AccessWindow, AccessRectangle
FormWindow = Form.hwnd
GetWindowRect FormWindow, FormRectangle
With FormRectangle
FormDimensions.Height = .Bottom - .Top
FormDimensions.Width = .Right - .Left
End With
NewLeft = AccessRectangle.Right - FormDimensions.Width -
GetSystemMetrics(SM_CYVTHUMB)
If NewLeft > AccessRectangle.Left Then _
SetWindowPos FormWindow, _
HWND_TOP, _
AccessRectangle.Right - FormDimensions.Width - _
GetSystemMetrics(SM_CYVTHUMB), _
0, _
FormDimensions.Width, _
FormDimensions.Height, _
SWP_NOZORDER
End Sub
*******
and calling ths sub in the form's module as
***********************
Private Sub Form_Activate()
PlaceFormRight Me
End Sub
*******
.... and you might experiment a bit with the system metrics call to get
exactly the result you want.
--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.