?
Solved

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.

Posted on 2005-03-05
3
Medium Priority
?
254 Views
Last Modified: 2010-04-17
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
Comment
Question by:avbmiket
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 750 total points
ID: 13467778
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
 

Author Comment

by:avbmiket
ID: 13468665
I have VS.NET

Can this be done with VB.NEt

I found this program called AutoSizer that works pretty good
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13469410
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Simple Linear Regression
Introduction to Processes

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question