Handling windows [RESOLVED]
VB Code:
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
Private Declare Function GetMainWindow Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
Public Sub SelectWindow(ByVal Process_hWnd As IntPtr)
'Bring target window to front
BringWindowToTop(GetMainWindow(Process_hWnd))
End Sub
why isn't this working?
called by:
VB Code:
hWndIntPtr = SOMEPROCESS.Handle
[COLOR=Red]'EDITED:SelectWindow(New IntPtr(hWndIntPtr.ToInt64))[/COLOR]
'To this:
SelectWindow(hWndIntPtr)
'DUH! :)
:confused:
EDIT:
ok, a little more info...
Error number: 453 "Unable to find entry point named GetMainWindow in DLL user32"... :(
Re: Handling windows [UNRESOLVED]
Where did you get that code from? I can't find any indication that a GetMainWindow function exists, as your error message suggests. You can get the handle of the main window of a process by creating a Process object and using its MainWindowHandle property. You can use the Shared members GetProcesses, GetProcessById or GetProcessesByName to get your Process object.
Re: Handling windows [UNRESOLVED]
Actually... from you! :p
Quote:
You're using the Long type and yet calling ToInt32 instead if ToInt64. Also, you're passing that API function the process handle instead of a window handle. Just make all your handles of type IntPtr and then you don't need to convert to anything. You would get the main window of a process by calling GetMainWindow, then you can get the window handle.
(from http://www.vbforums.com/showthread.p...=getmainwindow )
I thought it would've worked but um, if you suggest me functions that aren't existant... :confused:
EDIT: RESOLVED! MainWindowHandle property was it... :p
Re: Handling windows [RESOLVED]
lol Bad bad bad, JM... :)