I've been studying this solution, yet can not duplicate.
http://www.thescripts.com/forum/thread351439.html
I have a form with a single button. When the button is clicked, I want Internet Explorer to launch on a specific monitor with a specific window size.
I assume the only way to do this is with the Windows API -- which I have never used.
Here is my code:
------------------------------------------------------------------------------------------- -
-
Imports System.Runtime.InteropServices
-
-
Public Class Form1
-
-
Dim tom As New Process
-
Dim tomstyle As New ProcessWindowStyle
-
Dim hndtom As IntPtr
-
-
Public Declare Auto Function SetWindowPos Lib "user32.dll" ( _
-
ByVal hWnd As IntPtr, _
-
ByVal hWndInsertAfter As IntPtr, _
-
ByVal X As Int32, _
-
ByVal Y As Int32, _
-
ByVal cx As Int32, _
-
ByVal cy As Int32, _
-
ByVal uFlags As UInt32 _
-
) As Boolean
-
-
Public Declare Auto Function MoveWindow Lib "user32.dll" ( _
-
ByVal hWnd As IntPtr, _
-
ByVal X As Int32, _
-
ByVal Y As Int32, _
-
ByVal nWidth As Int32, _
-
ByVal nHeight As Int32, _
-
ByVal bRepaint As Boolean _
-
) As Boolean
-
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
tomstyle = ProcessWindowStyle.Normal
-
-
tom = Process.Start("c:\program files\internet explorer\iexplore.exe")
-
-
hndtom = tom.MainWindowHandle
-
-
MsgBox(MoveWindow(hndtom, 10, 10, 300, 400, True))
-
-
End Sub
-
-
End Class
-
-
-
-------------------------------------------------------------------------------------------
The message box returns false each time, and the window is not resized.
What am I missing??
Tom
1 11567
Answer : Please add the
Imports System.Threading namespace and then add Thread.Sleep(2000) to wait for some time before resize...
It works fine....Thanks for ur help your code works for me also...
Below is Corrected Code
Imports System.Runtime.InteropServices 'Add below namespace for sleep function
Imports System.Threading
Public Class Form1
Dim tom As New Process
Dim tomstyle As New ProcessWindowStyle
Dim hndtom As IntPtr
Public Declare Auto Function SetWindowPos Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal hWndInsertAfter As IntPtr, _
ByVal X As Int32, _
ByVal Y As Int32, _
ByVal cx As Int32, _
ByVal cy As Int32, _
ByVal uFlags As UInt32 _
) As Boolean
Public Declare Auto Function MoveWindow Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal X As Int32, _
ByVal Y As Int32, _
ByVal nWidth As Int32, _
ByVal nHeight As Int32, _
ByVal bRepaint As Boolean _
) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tomstyle = ProcessWindowStyle.Normal
tom = Process.Start("c:\program files\internet explorer\iexplore.exe") 'Put some wait so that it returns the proper handle after the process is launched
Thread.Sleep(2000)
hndtom = tom.MainWindowHandle
MsgBox(MoveWindow(hndtom, 0, 50, 1024, 700, True))
End Sub
End Class
Poonam..:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: riki |
last post by:
Hi,
i have a big problem...i'm using one jscript for resizing of all of my pics
in popUp...in main html i'm having many little pics and clicking on them
they open in popUp and resize to larger...
|
by: TJ Talluto |
last post by:
<facts>
I have a "month calendar" that always displays exactly 42 days... and
alongside is a vertical box that displays the detail (form fields) of any
particular select event that appears on the...
|
by: serge calderara |
last post by:
Dear all,
I have an application which is suppose to start another executable process.
As soon as that process is running, I need to retrive its handle. The
problem of the particular process I am...
|
by: Ale |
last post by:
I try to start a program with process.start method.
It normally starts but no window is displayed, i only
see the application process running on the taskmanager.
I think the process is executed...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: cvetomir.todorov |
last post by:
We have an app which must be single instance. When we start the app we
check if it is already running (using the Process object in the
System.Diagnostics namespace) locating it by the name of the...
|
by: Mark Henry |
last post by:
I wrote a Desktop class for manipulating desktops and window stations.
The class is being used by a service for starting applications on the
interactive desktop (the service cannot run as Local...
|
by: dli07 |
last post by:
Hello,
I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from...
|
by: ropo |
last post by:
I have a .NET 2.0 app that at one point starts an old MFC App through
System.Diagnostics.Process.Start from a model form/
I then wait for it to finish by calling StartedProcess.WaitForExit();
...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |