ctrBtnMacOs




Private Declare Function RoundRect Lib "gdi32" _
(ByVal hdc As Long, ByVal X1 As Long, _
ByVal Y1 As Long, ByVal X2 As Long, _
ByVal Y2 As Long, ByVal X3 As Long, _
ByVal Y3 As Long) As Long
Private Declare Function DrawText Lib "user32" _
Alias "DrawTextA" (ByVal hdc As Long, _
ByVal lpStr As String, ByVal nCount As Long, _
lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function Rectangle Lib "gdi32" _
(ByVal hdc As Long, ByVal X1 As Long, _
ByVal Y1 As Long, ByVal X2 As Long, _
ByVal Y2 As Long) As Long
Const DT_NOCLIP = &H100
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim rct As RECT
Private Sub Form_Load()
image1.Top = 50
image1.Left = 75
End Sub

Private Sub Form_Paint()
Cls
Cls
Me.DrawWidth = 1 'Smallest
RoundRect Me.hdc, 125, 75, 60, 45, 20, 20
'Draw first rounded rectangle

Me.DrawWidth = 3
RoundRect Me.hdc, 128, 78, 57, 42, 20, 20
'Draw second around it

Me.FontBold = True
Me.FontSize = 10
Me.Font = "System" 'Best font For button
With rct
.Top = 50
.Left = 75
End With
DrawText Me.hdc, "Quit", 4, rct, DT_NOCLIP
'Draw word "Quit" in middle of button

End Sub

Private Sub image1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Cls
With rct
.Top = 50
.Left = 75
End With
Me.ForeColor = vbBlack
Me.DrawWidth = 20 'Thick
Rectangle Me.hdc, 120, 70, 68, 50
'Draw square thats black

Me.ForeColor = vbWhite
DrawText Me.hdc, "Quit", 4, rct, DT_NOCLIP
'Write "Quit" so we can read it agenst(sp?) the black

End Sub

Private Sub image1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
'same as Form_Paint

Cls
Me.DrawWidth = 1
Me.ForeColor = vbBlack
RoundRect Me.hdc, 125, 75, 60, 45, 20, 20
Me.DrawWidth = 3
RoundRect Me.hdc, 128, 78, 57, 42, 20, 20
Me.FontBold = True
Me.FontSize = 10
Me.Font = "System"
With rct
.Top = 50
.Left = 75
End With
DrawText Me.hdc, "Quit", 4, rct, DT_NOCLIP
End Sub

Assumes:
Add a label named image1 and set the Caption to 10
spaces and the BackStyle to 1 - Opaque(Sp?)
The forms ScaleMode To 3 - Pixels











( ctrbtnmacos.html )- by Paolo Puglisi - Modifica del 17/12/2023