Results 1 to 9 of 9

Thread: what API to get Label hWnd?

  1. #1

    Thread Starter
    Hyperactive Member FLasH3r's Avatar
    Join Date
    Feb 2001
    Location
    Bad command or filename
    Posts
    259

    what API to get Label hWnd?

    how can i find the hWnd of the label control?

  2. #2
    jim mcnamara
    Guest
    Unless you use VB 4.0 or earlier, labels are not windows - they don't have a hWnd. They are a static or graphical control, not window-based.

  3. #3

    Thread Starter
    Hyperactive Member FLasH3r's Avatar
    Join Date
    Feb 2001
    Location
    Bad command or filename
    Posts
    259

    how about checkbox and option box?

    how about checkbox and option box?

  4. #4
    jim mcnamara
    Guest
    ActiveX controls almost always have a hWnd, intrinsic VB controls probably do. Before you ask about every control in VB, use the Object Browser to find out for yourself.

    Look up a a control in the Browser, like Label, you'll see it has no .hWnd property. While this is not a guarantee the object has no hWnd, it's an indicator. Check Box & option button controls do have a hWnd property.

  5. #5
    Lively Member
    Join Date
    Aug 2001
    Posts
    109
    everything has a hWnd... but not always as a property.... u'll have to use FindWindow and FindWindowEx functions....

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    You can also use EnumChildWindows APi call

  7. #7
    jim mcnamara
    Guest
    Albafa - according to MSDN VB6.0 label controls are not windows, they have no hWnd. Spy++ agrees. If you know differently on an absolute basis, please demonstrate.

    And, you folks are right - almost all controls have a hWnd, even if it doesn't show in properties.

  8. #8
    Lively Member
    Join Date
    Aug 2001
    Posts
    109
    omg jim ur right ... i never noticed that shrugs

    Guess I was just too used to reading from AOL's "static" labels..

  9. #9
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: how about checkbox and option box?

    Originally posted by FLasH3r
    how about checkbox and option box?
    VB Code:
    1. Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    2. 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
    3. Private Sub Command1_Click()
    4. SetWindowText FindWindowEx(Me.hwnd, 0, "ThunderCheckBox", vbNullString), "Hello"
    5. End Sub

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