Results 1 to 7 of 7

Thread: hHwnd with Labels

  1. #1
    letxa2000
    Guest

    hHwnd with Labels

    I need to access the hWnd of a label control. In VB3 this was as easy as saying myVar=lblMyLabel.hWnd. This no longer works in VB6, although it does seem possible to get the hWnd of other controls.

    Can someone tell me how I can obtain the hWnd of a label control in VB6?

    I love these "advances" in MS products where less is "better" and consistency between versions is best left to their competitors.

    Craig Steiner

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    VB 6 (I believe 4 and 5, could be wrong about 4, it's been so long.) does not use a window class for the Label control (previously would have been the Static class.) instead the the contents of the Label are Drawn onto the parent, so there is no way to get a handle to a standard Label control. If you need this functionality I suggest using a 3rd party control or creating your own.

  3. #3
    letxa2000
    Guest
    Not the answer I wanted to hear, although it doesn't surprise me. Leave it to Microsoft to NOT use their own control classes.

    Damn.

    I wanted to be able to update the contents of VB6 labels from a VC++ DLL called from the VB6 program. I guess I can't do that, at least not with Microsoft products. Out of curiosity, is there any useful reason that they chose to stop using their own CStatic control?

    And do you have any recommendations of a good 3rd party control? All I want is what used to be the label control. I guess I could write my own; never thought I'd find myself writing a label control but why not. We are left to fill in the holes that Microsoft leaves us...

    Craig Steiner

  4. #4
    letxa2000
    Guest
    But wait...

    If they just draw the text on the screen, what's up with all the properties when you are in design mode? They actually go through the hassle of converting all those CStatic properties to a DRAW sequence?

    More importantly, they go through the hassle of processing EVENTS at run-time that happen "to" the text that has been drawn?

    The more I think about it, the less sense it makes...

  5. #5
    Tygur
    Guest
    You can use a picturebox instead of a label if you'd rather not take the time to look for or make a label control. Just use Print to put text on it. And you might want to set the AutoRedraw property of the picturebox to true.

  6. #6
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    The reason that they stopped using dedicated windows for their label controls (and shape and line controls) is that each window created uses up a certain amount of resources and they found that this made the loading and unloading of forms very slow...

    That said, if you pass the label's Caption property ByRef to your DLL, the latter should be able to modify it.

    HTH,
    D.

  7. #7
    Tygur
    Guest
    Originally posted by MerrionComputin
    That said, if you pass the label's Caption property ByRef to your DLL, the latter should be able to modify it.
    Have you ever tried it? That doesn't work.

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