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