• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

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.
0
Mike Treat
Asked:
Mike Treat
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Not from a shortcut unless the shortcut is passing command line parameters telling the app where to position itself or the shortcut is calling another program with parameters telling it where to position the app.

If you want to position another app after the fact from a utility app then use the SetWindowPos() API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setwindowpos.asp

What programming languages/tools do you have available to you?
0
 
Mike TreatArchitect CEOAuthor Commented:
I have VS.NET

Can this be done with VB.NEt

I found this program called AutoSizer that works pretty good
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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.MainWindowHandle.ToInt32, 0, Screen.PrimaryScreen.WorkingArea.Width - w, Screen.PrimaryScreen.WorkingArea.Height - h, w, h, 0)
    End Sub

End Class
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now