Mike Treat
asked on
Is there any way to open a Window to a specific position and size from a shortcut, or from another utility app. This would be handy.
I need this ability for settng up to open applications and documents to a specific location on the screen. I have looked and cannot find this any where.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The following example opens Notepad and then moves it to the bottom right of the screen with a width of 500 and a height of 250:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
(ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, _
ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, _
ByVal wFlags As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As Process = Process.Start("notepad.exe ")
p.WaitForInputIdle()
Dim w As Integer = 500
Dim h As Integer = 250
SetWindowPos(p.MainWindowH andle.ToIn t32, 0, Screen.PrimaryScreen.Worki ngArea.Wid th - w, Screen.PrimaryScreen.Worki ngArea.Hei ght - h, w, h, 0)
End Sub
End Class
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
(ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, _
ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, _
ByVal wFlags As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As Process = Process.Start("notepad.exe
p.WaitForInputIdle()
Dim w As Integer = 500
Dim h As Integer = 250
SetWindowPos(p.MainWindowH
End Sub
End Class
ASKER
Can this be done with VB.NEt
I found this program called AutoSizer that works pretty good