在图片框写文字和图片

原来如此 2008-03-13 09:11:30
我在"Text1"控件里写入了文字"你好",在"Picture1"里导入了一张图片,怎样实现单击Command1控件使得"Text1"的"你好"和"Picture1"的图片合并在一起(文字在前,后面显示图片),并且显示在"Picture2"呢?
...全文
97 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cbm6666 2008-03-13
'添加 Picture1 Picture2 Text1

'Picture1请先装载一张图片

Option Explicit
Private Declare Function GdiTransparentBlt Lib "gdi32" (ByVal hdc1 As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal W1 As Long, ByVal H1 As Long, ByVal Hdc2 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal W2 As Long, ByVal H2 As Long, ByVal Color As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Dim transcolor&

Private Sub Form_Load()
With Picture1
.ScaleMode = 3
.AutoRedraw = True
.BorderStyle = 0
.AutoSize = True
.Move 0, 0
End With
With Picture2
.BorderStyle = 0
.AutoRedraw = True
.Move Screen.Width
End With
Set Picture2.Container = Picture1
Text1.Width = 3900: Text1.Height = 495
Text1.FontSize = 24: Text1.ForeColor = QBColor(11)
Text1.FontBold = True: Text1.FontItalic = True
Text1.Text = "CBM666的TextBox"
Text1.Move (Picture1.Width - Text1.Width) \ 2, 100
Set Text1.Container = Picture1
'*************** 窗体置中 ***************
Me.BorderStyle = 0: Me.Caption = "": Me.Width = Picture1.Width: Me.Height = Picture1.Height
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
transcolor = vbWhite
End Sub

Private Sub Form_Activate()
Call Getbackpic
End Sub

Sub Getbackpic()
Dim lDesktop As Long
Dim lDC As Long
Me.AutoRedraw = True
Text1.BorderStyle = 0
Picture2.Width = Text1.Width: Picture2.Height = Text1.Height
lDesktop = GetDesktopWindow() '取得桌面窗口
lDC = GetDC(lDesktop) '取得桌面窗口的设备场景
Me.Refresh
BitBlt Picture2.hDC, 0, 0, Text1.Width, Text1.Height, lDC, (Me.Left + Picture1.Left) \ 15 + Text1.Left, (Me.Top + Picture1.Top) \ 15 + Text1.Top, vbSrcCopy '将桌面图象绘制到窗体
Text1.Move Screen.Width
GdiTransparentBlt Picture1.hDC, (Picture1.Width \ 15 - Picture2.Width) \ 2, 10, Picture2.Width, Picture2.Height, Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, transcolor
Picture2.Move Screen.Width
End Sub

Private Sub Picture1_Click()
Unload Me
End Sub

'效果图:
http://p.blog.csdn.net/images/p_blog_csdn_net/cbm666/366646/o_QQText.jpg

回复
supergreenbean 2008-03-13
Private Sub Command1_Click()
Picture1.AutoRedraw = True
Picture1.Print Text1.Text

Picture2.PaintPicture Picture1.Image, 0, 0
End Sub
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7521

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-13 09:11
社区公告
暂无公告