Any Control that was set to Enabled = False, will "delegate" their Mouse-Messages to the underlying Container.
Knowing that, the solution comes down to writing/defining your own ucLabel.ctl
(which despite having Disabled-State, will render its Text in the normal ForeColor).
The easiest way to do that (if you don't want to fiddle around with your own Text-Renderings) is,
to simply wrap an existing Label-Control within your new ucLabel.ctl.
Here's a small example - the following should go into a new ucLabel.ctl (which hosts a Label, named Label1):
Now place an instance of your new ucLabel on your Form - and check the behaviour with the following Code:Code:Option Explicit 'also set the UserControl to CanGetFocus = False in the Property-Grid Private Sub UserControl_Initialize() UserControl.Enabled = False Label1.BackColor = vbRed 'set whatever default-props you want on your Label End Sub Public Property Get Caption() As String 'expose any Prop you want (Caption is obvious) Caption = Label1.Caption End Property Public Property Let Caption(ByVal RHS As String) Label1.Caption = RHS End Property Private Sub UserControl_Resize() 'adjust the Label1-Size according to the hosting UserControl Label1.Move 0, 0, UserControl.Width, UserControl.Height End Sub
HTHCode:Option Explicit Private Declare Function ReleaseCapture& Lib "user32" () Private Declare Function SendMessageA& Lib "user32" (ByVal hWnd&, ByVal Msg&, ByVal wParam&, lParam As Any) Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SendMessageA hWnd, &H112, &HF012&, 0& End Sub
Olaf




Reply With Quote