|
-
Dec 26th, 2005, 10:41 PM
#1
Thread Starter
Fanatic Member
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! :)

EDIT:
ok, a little more info...
Error number: 453 "Unable to find entry point named GetMainWindow in DLL user32"...
Last edited by Ruku; Jan 1st, 2006 at 08:25 PM.
-
Dec 26th, 2005, 11:23 PM
#2
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.
-
Jan 1st, 2006, 08:21 PM
#3
Thread Starter
Fanatic Member
Re: Handling windows [UNRESOLVED]
Actually... from you! 
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... 
EDIT: RESOLVED! MainWindowHandle property was it...
Last edited by Ruku; Jan 1st, 2006 at 08:25 PM.
-
Jan 1st, 2006, 08:37 PM
#4
Re: Handling windows [RESOLVED]
lol Bad bad bad, JM...
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
|