Results 1 to 4 of 4

Thread: Handling windows [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Exclamation Handling windows [RESOLVED]

    VB Code:
    1. Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
    2.     Private Declare Function GetMainWindow Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
    3.  
    4.     Public Sub SelectWindow(ByVal Process_hWnd As IntPtr)
    5.         'Bring target window to front
    6.         BringWindowToTop(GetMainWindow(Process_hWnd))
    7.     End Sub

    why isn't this working?

    called by:

    VB Code:
    1. hWndIntPtr = SOMEPROCESS.Handle
    2. [COLOR=Red]'EDITED:SelectWindow(New IntPtr(hWndIntPtr.ToInt64))[/COLOR]
    3. 'To this:
    4.  
    5. SelectWindow(hWndIntPtr)
    6.  
    7. '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.

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    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.

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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
  •  



Click Here to Expand Forum to Full Width