编一个在屏幕上画图象的函数,懂的人进(能用就送150分)
来源:百度知道 编辑:UC知道 时间:2024/06/09 19:11:35
只是在屏幕上画,程序运行时,单击我的电脑仍会有反应.
真的能用,200分也没问题!!!
在屏幕上画图
'例子需控件:Command1、Picture1
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 RasterOpConstants) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
Dim toDC As Long, dl As Long
Dim nTop As Long, nLeft As Long, nW As Long, nH As Long
'要绘制的图片,这里我举例为窗口图标
'或 Picture1.Picture = LoadPicture(文件名),或从资源文件载入
Picture1.Picture = Me.Icon
Picture1.ScaleMode = vbPixels '将 Picture1 的坐标变为像素单位
Picture1.AutoSize = True
nTop = 20 '距屏幕顶端位置,单位:像素
nLeft = 10 '距屏幕左端位置,单位:像素
nW = Picture1.ScaleWidth '图像宽度
nH = Picture1.ScaleHeight '图像高度
toDC = GetWindowDC(0)
dl = BitBlt(toDC, nLeft, nTop,