我写了一个简单的,但是涉及到了其他很多功能,不能全部给你。这里给出部分在picturebox上画图形的代码,应该有帮助。 Select Case PicType
Case 1
'''画任意线
lblHelp.Caption = " 画不规则线条"
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
Case 2
'''画直线
lblHelp.Caption = " 画直线"
'''清除重影
PIC.Line (EndX, EndY)-(BegX, BegY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
'PIC.ForeColor = &H80000012
'PIC.DrawMode = 7
'''重新画线
PIC.Line (BegX, BegY)-(x, y)
EndX = x
EndY = y
Case 3
'''画圆
lblHelp.Caption = " 画圆"
PIC.ForeColor = PIC.BackColor
Ellipse PIC.hdc, BegX, BegY, EndX, EndY
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic0.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
If PicColor <> 0 Then
PIC.ForeColor = PicColor
Else
PIC.ForeColor = &H80000012
End If
Ellipse PIC.hdc, BegX, BegY, x, y
Case 4
'''画矩形
lblHelp.Caption = " 画矩形"
PIC.Line (BegX, BegY)-(BegX, EndY), PIC.BackColor
PIC.Line (BegX, BegY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(BegX, EndY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
PIC.Line (BegX, BegY)-(BegX, y)
PIC.Line (BegX, BegY)-(x, BegY)
PIC.Line (x, y)-(x, BegY)
PIC.Line (x, y)-(BegX, y)
EndX = x
EndY = y
Case Else
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
End Select
Case 1
'''画任意线
lblHelp.Caption = " 画不规则线条"
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
Case 2
'''画直线
lblHelp.Caption = " 画直线"
'''清除重影
PIC.Line (EndX, EndY)-(BegX, BegY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
'PIC.ForeColor = &H80000012
'PIC.DrawMode = 7
'''重新画线
PIC.Line (BegX, BegY)-(x, y)
EndX = x
EndY = y
Case 3
'''画圆
lblHelp.Caption = " 画圆"
PIC.ForeColor = PIC.BackColor
Ellipse PIC.hdc, BegX, BegY, EndX, EndY
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic0.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
If PicColor <> 0 Then
PIC.ForeColor = PicColor
Else
PIC.ForeColor = &H80000012
End If
Ellipse PIC.hdc, BegX, BegY, x, y
Case 4
'''画矩形
lblHelp.Caption = " 画矩形"
PIC.Line (BegX, BegY)-(BegX, EndY), PIC.BackColor
PIC.Line (BegX, BegY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(BegX, EndY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
PIC.Line (BegX, BegY)-(BegX, y)
PIC.Line (BegX, BegY)-(x, BegY)
PIC.Line (x, y)-(x, BegY)
PIC.Line (x, y)-(BegX, y)
EndX = x
EndY = y
Case Else
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
End Select
解决方案 »
- 求教.VB程序如何获得电脑的唯一标识号啊
- 求邮件发送 HTML 网页的解决方法?
- 逛了一个人才网,没有招vb的!!
- 关于活动脚本,这个问题对我重要,给100分了
- ADO/ODBC的优劣
- 我在XP下用VB写程序,制作安装程序,在其它XP上安装正常,但是在windows2000下使用该安装程序时,总要求重启,可是重启后还要重启,没完
- 如何对一个picturebox里的图形进行区域选择,并将选择部分的图形提取出来
- 谁会用 Map Info MapX,有 $$ 哦!
- 请问怎么知道一个进程使用了多少内存?
- 我想获得用户选择的目录名,使用什么控件?
- 找不到Shell_NotifyIconA入口点,是怎么回事
- 我做的VB程序的安装总是出错,请帮忙!
Select Case PicType
Case 1
'''画任意线
lblHelp.Caption = " 画不规则线条"
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
Case 2
'''画直线
lblHelp.Caption = " 画直线"
'''清除重影
PIC.Line (EndX, EndY)-(BegX, BegY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
'PIC.ForeColor = &H80000012
'PIC.DrawMode = 7
'''重新画线
PIC.Line (BegX, BegY)-(x, y)
EndX = x
EndY = y
Case 3
'''画圆
lblHelp.Caption = " 画圆"
PIC.ForeColor = PIC.BackColor
Ellipse PIC.hdc, BegX, BegY, EndX, EndY
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic0.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
If PicColor <> 0 Then
PIC.ForeColor = PicColor
Else
PIC.ForeColor = &H80000012
End If
Ellipse PIC.hdc, BegX, BegY, x, y
Case 4
'''画矩形
lblHelp.Caption = " 画矩形"
PIC.Line (BegX, BegY)-(BegX, EndY), PIC.BackColor
PIC.Line (BegX, BegY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(EndX, BegY), PIC.BackColor
PIC.Line (EndX, EndY)-(BegX, EndY), PIC.BackColor
If TmpPicNum = 0 Then
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic3.bmp")
Else
Set PIC.Picture = LoadPicture(App.path + "\PicTemp\TmpPic" + CStr(TmpPicNum - 1) + ".bmp")
End If
PIC.Line (BegX, BegY)-(BegX, y)
PIC.Line (BegX, BegY)-(x, BegY)
PIC.Line (x, y)-(x, BegY)
PIC.Line (x, y)-(BegX, y)
EndX = x
EndY = y
Case Else
PIC.Line (BegX, BegY)-(x, y)
BegX = x
BegY = y
End Select这个程序不错,你试试
图像编辑程序,可以使用各种不同效果的画笔,并且包含一些图像特效,象柔化、锐化等等。 下载(11.7K)
http://www.applevb.com/sourcecode/cool%20picture%20editor.zip
一个非常Cool的图像编辑软件,支持在图像中画椭圆、矩形、锥体、圆柱、不规则曲线,支持输入文本,使用橡皮擦,图像区域填充。最绝的是它的画笔和画刷支持不同的形状(例如使用树叶形的画刷可以画出如同柳条的效果)。强烈推荐。 下载(216K)