?
Solved

change the size and position of an application

Posted on 2000-01-10
3
Medium Priority
?
149 Views
Last Modified: 2010-05-18
E.g
Private Sub Command1_Click()
   shell("c:\winnt\application.exe,3)
   ' Here do I want to change the size and postition of the applications window
Is this possible to do that ?
Note: The application is not a VB projekt

0
Comment
Question by:Fredde
3 Comments
 
LVL 1

Expert Comment

by:MitchBroadhead
ID: 2338233
what is the application?  Can you use:
Set App = new Application
after adding relevant object library?
0
 
LVL 1

Accepted Solution

by:
vbWayne earned 160 total points
ID: 2338240

'here is everyth9ing you need...you just have to
'apply it to your situtation
'specify the screen size/position of a window
'this example sets notepad to the bottom left corner

Private Type POINTAPI
    X As Long
    Y As Long
End Type

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

Private Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As RECT
End Type

Private Declare Function SetWindowPlacement _
Lib "user32" (ByVal hwnd As Long, _
lpwndpl As WINDOWPLACEMENT) As Long

Private Declare Function GetWindowPlacement _
Lib "user32" (ByVal hwnd As Long, lpwndpl As _
WINDOWPLACEMENT) As Long

Private Declare Function FindWindow Lib _
"user32" Alias "FindWindowA" (ByVal lpClassName _
As String, ByVal lpWindowName As String) As Long

Private Declare Function SetRect Lib "user32" _
(lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long) As Long

'==========================================
'this is in the for
'calls notepad and opens a file as t sets it's place and position.

Private Sub Command1_Click()
   Dim WndPlace As WINDOWPLACEMENT
   Dim h As Long
    Dim RetVal
    RetVal = Shell("C:\WINDOWS\notepad.exe C:\A VB Tips\alpha only.txt", 1)
    'Shell "Notepad", vbHide
    h = FindWindow("Notepad", vbNullString)
    If h <> 0 Then
        WndPlace.Length = Len(WndPlace)
        Call GetWindowPlacement(h, WndPlace)
        Call SetRect(WndPlace.rcNormalPosition, 0, 3700, WndPlace.rcNormalPosition.Right, 4000)
        Call SetWindowPlacement(h, WndPlace)
    End If
End Sub
0
 

Author Comment

by:Fredde
ID: 2344636
Is only working with notepad ? I get h =0 when I tried another program
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

598 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