Results 1 to 4 of 4

Thread: Problem with FinWindow

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    22

    Unhappy

    Hi,

    I want to get a window handle with the FindWindow api, but the function always returns 0.
    This is my code :

    Private Sub Command1_Click()

    Dim WindowHwnd as Long
    WindowHwnd = FindWindow("#32770 (Dialog)", CLng(0)) ' it's the ie download window class name
    If WindowHwnd = 0 Then
    Label1.Caption = "Il n'y a pas de D/L en cours"
    Else
    Label1.Caption = "Il y a un D/L en cours"
    End If

    End Sub


    Thanks

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    FindWindow will not search through child windows, use FindWindowEx.
    The code below will find the "File Download" Window and close it.

    Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Const WM_CLOSE = &H10

    Private Sub Command1_Click()
    Dim bWnd, i
    bWnd = FindWindowEx(ByVal 0&, ByVal 0&, vbNullString, "File Download")
    If bWnd = 0 Then
    Label1.Caption = "NO"
    Else
    Label1.Caption = "YES"
    i = SendMessage(bWnd, WM_CLOSE, 0, 0&)
    End If
    End Sub

    Bon Chance.
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    22

    Cool

    Good work!

  4. #4
    Guest
    I assume you used Spy++ to get the ClassName. The class name for a dialog is not #32770 (Dialog), rather it's just #32770.

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