|
-
Apr 1st, 2000, 07:32 AM
#2
Junior Member
Hi,
You can try to build your own CommandButton, so you'll be able to do what you want, without ocx.
There is an example that I often use.
You'll need a PictureBox (size it as you want, it's your button), put an image control in it (on the left side if you want) load your icon in this image control. Then put 4 lines on your form.
'general declarations
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
'In form_load
Line1.X1 = Picture1.Left - 10
Line1.X2 = Picture1.Left + Picture1.Width
Line1.Y1 = Picture1.Top - 10
Line1.Y2 = Line1.Y1
Line2.X1 = Picture1.Left
Line2.X2 = Picture1.Left + Picture1.Width
Line2.Y1 = Picture1.Top + Picture1.Height
Line2.Y2 = Line2.Y1
Line3.X1 = Picture1.Left - 10
Line3.X2 = Line3.X1
Line3.Y1 = Picture1.Top
Line3.Y2 = Picture1.Top + Picture1.Height
Line4.X1 = Picture1.Left + Picture1.Width
Line4.X2 = Line6.X1
Line4.Y1 = Picture1.Top
Line4.Y2 = Picture1.Top + Picture1.Height + 10
Line1.BorderColor = &HE0E0E0
Line2.BorderColor = &H808080
Line3.BorderColor = &HE0E0E0
Line4.BorderColor = &H808080
'The caption of your button
msg = "ClickHere"
Picture1.FontSize = 8
HalfWidth = Picture1.TextWidth(msg) / 2 - 90
HalfHeight = Picture1.TextHeight(msg) / 2
Picture1.CurrentX = Picture1.ScaleWidth / 2 - HalfWidth
Picture1.CurrentY = Picture1.ScaleHeight / 2 - HalfHeight
Picture1.Print msg
'Picture1 mouse_down
Line1.BorderColor = &H808080
Line2.BorderColor = &HE0E0E0
Line3.BorderColor = &H808080
Line4.BorderColor = &HE0E0E0
'Picture1 mouse_up
Line1.BorderColor = &HE0E0E0
Line2.BorderColor = &H808080
Line3.BorderColor = &HE0E0E0
Line4.BorderColor = &H808080
'Picture1 mouse_move (to hilite the caption in blue when
'mouse is over the button)
Dim MouseEnter As Boolean
Dim HalfWidth, HalfHeight, msg
MouseEnter = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseEnter Then
Picture1.ForeColor = &HFF0000
Picture1.Cls
msg = "ClickHere"
Picture1.FontSize = 8
HalfWidth = Picture1.TextWidth(msg) / 2 - 90
HalfHeight = Picture1.TextHeight(msg) / 2
Picture1.CurrentX = Picture1.ScaleWidth / 2 - HalfWidth
Picture1.CurrentY = Picture1.ScaleHeight / 2 - HalfHeight
Picture1.Print msg
SetCapture Picture1.hwnd
Else
Picture1.ForeColor = &H80000012
Picture1.Cls
msg = "ClickHere"
Picture1.FontSize = 8
HalfWidth = Picture1.TextWidth(msg) / 2 - 90
HalfHeight = Picture1.TextHeight(msg) / 2
Picture1.CurrentX = Picture1.ScaleWidth / 2 - HalfWidth
Picture1.CurrentY = Picture1.ScaleHeight / 2 - HalfHeight
Picture1.Print msg
Line1.BorderColor = &HE0E0E0
Line2.BorderColor = &H808080
Line3.BorderColor = &HE0E0E0
Line4.BorderColor = &H808080
ReleaseCapture
End If
You can of course change some settings depending on the size of your icon (here 16x16), fonts...
Claude.
[Edited by Claudi on 04-01-2000 at 07:35 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|