Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form to be placed in the lower right

Status
Not open for further replies.

fcjm

Programmer
Jan 15, 2001
19
0
0
PH
Does anyone know how could I place my form in the lower right of the window without covering the taskbar? Even if user changes the display settings, the same thing will happen. Any ideas? Thanks.
 
Add a SysInfo control to your form, and then something like this should work:

Private Sub Form_Load()
Reposition Me
End Sub

Private Sub SysInfo1_DisplayChanged()
Reposition Me

End Sub

Private Sub Reposition(frmTarget As Form)
frmTarget.Top = SysInfo1.WorkAreaHeight + SysInfo1.WorkAreaTop - frmTarget.Height
frmTarget.Left = SysInfo1.WorkAreaWidth + SysInfo1.WorkAreaLeft - frmTarget.Width
End Sub
 
Thanks for the suggestions.

The suggestion of strongm is correct. But is there another way where I don't need to use control like using API?
 
The link that LazyMe provides contains API code.

Having said that, why is an API solution your preference?
 
Yeah, I'm also wondering about that. Why going through all the "trouble" with API calls when it's as easy as strongm suggests? Since it's all about positioning a Form, you already have a container for the control....
Greetings,
Rick
 
The program I'm creating will be given install in other computers. It's easier to install a program if it's less control and it's size is lesser compare to an application with so many controls. Thanks for your answers, I found a code which solve my problem. Here it is:

Option Explicit

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, ByRef lpvParam As RECT, _
ByVal fuWinIni As Long) As Long

Private Const SPI_GETWORKAREA = 48

Private Sub Form_Load()

Dim r As RECT

SystemParametersInfo SPI_GETWORKAREA, 0, r, 0

With Me
.Move r.Right * Screen.TwipsPerPixelX - .Width, _
r.Bottom * Screen.TwipsPerPixelY - .Height
End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top