Продолжим тогда :) и на тему VB
'рецепт приготовления разукрашенного бутона :)
'Command1 1 штука
'Picture1 1 штука
'Если есть желание чтоб "текст" на кнопке подсвечивался как hiperlink,
'то раскомментируйте часть кода
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () 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 Const DT_CENTER = &H1
Private Const DT_WORDBREAK = &H10
Private Const DT_CALCRECT = &H400
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim CtrMov As Boolean
Dim CommandCaption As String
Private Sub Form_Load()
Picture1.Width = Command1.Width
Picture1.Height = Command1.Height
Picture1.ScaleMode = vbPixels
Command1.Caption = ""
CommandCaption = "ColorText"
ChangeTextColor vbBlue, CommandCaption
End Sub
Private Sub ChangeTextColor(ByVal Color As Long, ByVal Text As String)
Dim r As RECT
r.Right = Picture1.ScaleWidth
DrawText Picture1.hdc, Text, Len(Text), r, DT_WORDBREAK Or DT_CALCRECT
r.Top = (Picture1.ScaleHeight - r.Bottom) / 2
r.Bottom = r.Bottom + r.Top
r.Left = 0
r.Right = Picture1.ScaleWidth
Picture1.Cls
Picture1.ForeColor = Color
DrawText Picture1.hdc, Text, Len(Text), r, DT_WORDBREAK Or DT_CENTER
Command1.Picture = Picture1.Image
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
CtrMov = False
ChangeTextColor vbBlue, CommandCaption
Else
If CtrMov = False Then
SetCapture .hwnd
CtrMov = True
ChangeTextColor vbRed, CommandCaption
End If
End If
End With
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
CtrMov = False
End Sub