Results 1 to 3 of 3

Thread: hwnd property of labels?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    USA
    Posts
    26

    Post

    I thought every thing had the hwnd property, even command buttons, labels, etc. Anyway, What I want to do is have the labels I specify to stay on top of everything else on my form. I tried using this code which is used to keep the form on top, so I thought i would try with a label:
    Call SetWindowPos(lblNum.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags)
    and i got an error saying that there is no .hwnd property for the label.
    Is there anything I can do to keep the labels on top of everything else?

  2. #2
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    Put your Label inside a PictureBox, then put this code in bas:

    Option Explicit

    Private Type POINTAPI
    x As Long
    y As Long
    End Type

    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

    Private Declare Function ReleaseCapture Lib "User32" () As Long
    Private Declare Function ClientToScreen Lib "User32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long

    Private Declare Function ScreenToClient Lib "User32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long

    Private Declare Function SetParent Lib "User32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

    Public Sub SetCliente2hWnd(ByRef frm As Form, ByRef ParentObj As Control, ByRef Control2Change As Control)

    Dim lRet As Long
    Dim PositionTxt As POINTAPI

    PositionTxt.x = frm.ScaleX(ParentObj.Left, Control2Change.Parent.ScaleMode, vbPixels)
    PositionTxt.y = frm.ScaleX(ParentObj.Top, Control2Change.Parent.ScaleMode, vbPixels)

    lRet = ClientToScreen(Control2Change.hWnd, PositionTxt)
    lRet = ScreenToClient(Control2Change.Parent.hWnd, PositionTxt)
    lRet = SetParent(Control2Change.hWnd, Control2Change.Parent.hWnd)

    End Sub

    'Use:
    '
    ' SetCliente2hWnd Me, Picture1, Picture1
    '
    ' If you're using a SSTab
    '
    ' SetCliente2hWnd Me, SSTab, Picture1
    '

    Well, this is what I use!

    Boa sorte! (good luck)
    Jefferson

  3. #3
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    Hi,

    Maybe I have got the wrong end of the stick but can't you just say:

    label1.ZOrder 0


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