|
-
Aug 25th, 2010, 09:49 AM
#1
Thread Starter
Junior Member
using MoveWindow() just hides window comlpetely
Hi
Im trying to position a window with MoveWindow() API but it just keeps hiding the window and it has to be maximised to be able to see it.
The code im using is
Code:
Public Declare Function MoveWindow Lib "user32" _
(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
Dim p As System.Diagnostics.Process
For Each p In System.Diagnostics.Process.GetProcesses()
If p.MainWindowTitle = "MyProcess" Then
GetWindowRect(p.MainWindowHandle, r)
MsgBox("Left" & r.Left & vbNewLine & _
"Top" & r.Top & vbNewLine & _
"Bottom" & r.Bottom & vbNewLine & _
"Right" & r.Right)
Call MoveWindow(p.MainWindowHandle, 110, 59, 1270, 957,False)
Close()
End If
Next
i have tried with all different co-orindates and sixes and its always the same.
any help is appreciated
-
Aug 25th, 2010, 10:57 AM
#2
Re: using MoveWindow() just hides window comlpetely
try this instead:
vb Code:
Const SWP_NOSIZE As Integer = &H1
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As IntPtr, _
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
vb Code:
Dim xPosition As Integer = 50
Dim yPosition As Integer = 50
SetWindowPos(Me.Handle, -1, xPosition, yPosition, 0, 0, SWP_NOSIZE)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 25th, 2010, 10:59 AM
#3
Re: using MoveWindow() just hides window comlpetely
or if you want to use movewindow, this is the vb.net declaration:
vb Code:
Public Declare Function MoveWindow Lib "user32" _
(ByVal hwnd As intptr, _
ByVal x As integer, _
ByVal y As integer, _
ByVal nWidth As integer, _
ByVal nHeight As integer, _
ByVal bRepaint As integer) _
As integer
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 25th, 2010, 01:36 PM
#4
Thread Starter
Junior Member
Re: using MoveWindow() just hides window comlpetely
 Originally Posted by .paul.
try this instead:
vb Code:
Const SWP_NOSIZE As Integer = &H1
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As IntPtr, _
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
vb Code:
Dim xPosition As Integer = 50
Dim yPosition As Integer = 50
SetWindowPos(Me.Handle, -1, xPosition, yPosition, 0, 0, SWP_NOSIZE)
Thanks Paul,
That sorted it. Ideal
-
Aug 25th, 2010, 02:03 PM
#5
Re: using MoveWindow() just hides window comlpetely
Don't forget to mark your thread!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|