pro_vb thread: How to create a button which is like the one in Add/Remove Program in Windows 2000 ?
check out this "sort-of subclassing" example:
place a command button and text box on form, paste this code and hit run.
Option Explicit
Private Declare Function SetCapture Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If (X < 0) Or (Y < 0) Or (X > Command1.Width) _
Or (Y > Command1.Height) Then
' the MOUSELEAVE pseudo-event
ReleaseCapture
' in this example revert the caption to normal
Command1.Font.Bold = False
ElseIf GetCapture() <> Command1.hwnd Then
' the MOUSEENTER pseudo-event
SetCapture Command1.hwnd
' in this example, make the caption bold
Command1.Font.Bold = True
End If
End Sub
Private Sub Text1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If (X < 0) Or (Y < 0) Or (X > Text1.Width) _
Or (Y > Text1.Height) Then
' the MOUSELEAVE pseudo-event
ReleaseCapture
' in this example revert the caption to normal
Text1.SelLength = 0
ElseIf GetCapture() <> Text1.hwnd Then
' the MOUSEENTER pseudo-event
SetCapture Text1.hwnd
' in this example, make the caption bold
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End If
End Sub
change the code in the mousemove events to change the appearance property instead of
the font and, i think, you've got it.
have fun,
john
>--- Raymond Lo <ytlo@n...> wrote:
> Dear Sir,
> In Add/Remove Program in Windows 2000, there are three buttons.
> They are the 'Change or Remove Programs', 'Add New Programs' and
> 'Add/Remove Windows Components'.
> I want to make a user-control button which is like the above
> buttons. I cannot make the effect described as follows : When I move the
> mouse pointer over my user-control button, the button will be in
> 'pressed-down' state. When I move the mouse pointer away from the control,
> the button will be in 'flat' state.
>
> I would like to ask: How could I raise this event ?
> ===================================================
>
> It is not 'GotFocus', 'LostFocus', 'EnterFocus' and 'LeaveFocus'.
> This is because these events will only be raised after you 'clicked' some
> other buttons or textboxes.
>
> I would be appreciated if you could help me to get the answer.
> Many thanks in advance.
>
> Best regards.
>
> Raymond.
>
----------------------------
John Pirkey
MCSD
John@S...
http://www.stlvbug.org