现给你专门做的,刚出炉,热乎着呢,别不结帖啊,把图片画到计算器上 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowDC 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 Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Sub Form_Load() Picture1.ScaleMode = 3 '设置图片的单位是像素 Picture1.Picture = LoadPicture(App.Path & "\1.jpg") '加载图片到PictureBox Shell "calc.exe", vbNormalNoFocus '打开计算器 End Sub Private Sub Command1_Click() Myhwnd = FindWindow(vbNullString, "计算器") '得到计算器的句柄 MyhDC = GetWindowDC(Myhwnd) '得到计算器的画图场景
Dim MyRect As RECT '声明一个矩形 GetClientRect Myhwnd, MyRect '得到计算器外框的矩形范围 nWidth = MyRect.Right - MyRect.Left '得到计算器的宽度 nHeight = MyRect.Bottom - MyRect.Top '得到计算器的高度
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowDC 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
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Picture1.ScaleMode = 3 '设置图片的单位是像素
Picture1.Picture = LoadPicture(App.Path & "\1.jpg") '加载图片到PictureBox
Shell "calc.exe", vbNormalNoFocus '打开计算器
End Sub
Private Sub Command1_Click() Myhwnd = FindWindow(vbNullString, "计算器") '得到计算器的句柄
MyhDC = GetWindowDC(Myhwnd) '得到计算器的画图场景
Dim MyRect As RECT '声明一个矩形
GetClientRect Myhwnd, MyRect '得到计算器外框的矩形范围
nWidth = MyRect.Right - MyRect.Left '得到计算器的宽度
nHeight = MyRect.Bottom - MyRect.Top '得到计算器的高度
Suc = BitBlt(MyhDC, 0, 0, nWidth, nHeight, Picture1.hDC, 0, 0, &HCC0020) '画图End Sub
API画图达不到那种效果!
能再写个吗?我可以再加点分!