PDA

Click to See Complete Forum and Search --> : hwnd property of labels?


clonE
Jan 14th, 2000, 05:53 AM
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?

JeffSM
Jan 14th, 2000, 10:51 AM
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

rino_2
Jan 14th, 2000, 05:23 PM
Hi,

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

label1.ZOrder 0