VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Makes command button control transparent with the form background picture.

by Ali Atiq (5 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 16th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Makes command button control transparent with the form background picture.

API Declarations



Option Explicit

Public Function MakeButtonsTransparent(frm As Form)
Dim ctl As Control
Static StartupFlag%
On Error GoTo MakeCommandTransparen_ErrHandler
If StartupFlag% > 0 Then Exit Function
frm.Controls.Add "VB.PictureBox", "tmpPic", frm
With frm!tmpPic
.AutoRedraw = True
For Each ctl In frm.Controls
If TypeOf ctl Is CommandButton Then
.BorderStyle = 0
.Visible = True ' this one also
.Cls
.Move ctl.Left, ctl.Top, ctl.Width, ctl.Height
.CurrentX = (.ScaleWidth / 2) - (frm.TextWidth(ctl.Caption) / 2)
.CurrentY = (.ScaleHeight / 2) - (frm.TextHeight(ctl.Caption) / 2)
.PaintPicture frm.Image, 0, 0, , , .Left, .Top
frm!tmpPic.Print ctl.Caption
ctl.Picture = .Image
ctl.Caption = ""
End If
Next ctl
.Visible = False
End With
StartupFlag% = StartupFlag% + 1

Exit Function
MakeCommandTransparen_ErrHandler:
frm!tmpPic.Visible = False
StartupFlag% = StartupFlag% + 1
MsgBox Err.Description
End Function


Rate Makes command button control transparent with the form background picture.




Option Explicit

'Load picture to the form _
 Load command control _
 Set property [Style=1-Graphic] _

Private Sub Form_Load()
  MakeButtonsTransparent Me
End Sub


Download this snippet    Add to My Saved Code

Makes command button control transparent with the form background picture. Comments

No comments have been posted about Makes command button control transparent with the form background picture.. Why not be the first to post a comment about Makes command button control transparent with the form background picture..

Post your comment

Subject:
Message:
0/1000 characters