Hi,
I am programming in VB.NET
I want to move an IE window to the top left hand corner of the screen.
I have the following code, which works fine on my Vista PC.
--------------------------------------------------------------------
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function MoveWindow Lib "user32.dll" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Sub positionWindow()
Dim smartWindowHandle As Long
smartWindowHandle = getWindowHandle(windowName) 'where the windowname is previously specified
MoveWindow(smartWindowHandle, 0, 0, 647, 550, 1)
End Sub
The window handle is attained using the following:
Private Function WindowHandle(ByVal sTitle As String) As Long
WindowHandle = FindWindow(vbNullString, sTitle)
End Function
and ...
Public Function getWindowHandle(ByVal windowName As String) As Long
Return (WindowHandle(windowName))
End Function
---------------------------------------------------------------------
The problem is that on my Vista machine, it works fine. But on my XP machine, the window that is being moved, freezes and doesnt repaint itself. And when I run another window over it, it dissapears.
Can anybody offer any advice on how to move the window, without the window falling apart?
Thanks
I am programming in VB.NET
I want to move an IE window to the top left hand corner of the screen.
I have the following code, which works fine on my Vista PC.
--------------------------------------------------------------------
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function MoveWindow Lib "user32.dll" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Sub positionWindow()
Dim smartWindowHandle As Long
smartWindowHandle = getWindowHandle(windowName) 'where the windowname is previously specified
MoveWindow(smartWindowHandle, 0, 0, 647, 550, 1)
End Sub
The window handle is attained using the following:
Private Function WindowHandle(ByVal sTitle As String) As Long
WindowHandle = FindWindow(vbNullString, sTitle)
End Function
and ...
Public Function getWindowHandle(ByVal windowName As String) As Long
Return (WindowHandle(windowName))
End Function
---------------------------------------------------------------------
The problem is that on my Vista machine, it works fine. But on my XP machine, the window that is being moved, freezes and doesnt repaint itself. And when I run another window over it, it dissapears.
Can anybody offer any advice on how to move the window, without the window falling apart?
Thanks
Last edited: