Results 1 to 6 of 6

Thread: FindWindow API. Anyone know how to use it ?

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562

    FindWindow API. Anyone know how to use it ?

    Hi,
    There is an API called 'FindWindow'. I want to know how to use it.
    It returns the HWND of the window, but I don't know what parameters to pass for Class Name and Window Name
    Help!
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276

    Credits to Hack

    Borrowed From Hack...

    [vbcpde]
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Private Const WM_CLOSE = &H10
    Private Const WM_QUIT = &H12

    Dim CloseIt As Long
    CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
    [/Highlight]

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    The first parameter of the FindWindow API doesn't have to be vbNullString. It can be the class name of the window you are searching.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    Whats the class name. In VC++ is it the name of the class I give for 'CFrameWnd' when I use MFC
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    No, those are only MFC classes.

    For example, different windows have different types class names.

    BUTTON - button window
    #32770 - Dialog windows
    LISTBOX - list box

    You can give windows your own class names when you create them using CreateWindow API. VB windows have class names like ThunderRT6TextBox etc.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    You can also use Spy++ (comes with MSVC++) to find the class names for different windows.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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