|
发表于 2011-2-9 03:02:09
|
显示全部楼层
我也写了一个。呵呵。
Form1.frm- Public Function GetDcPic() As Long
- Dim destHdc&, Ret&
- Dim Pxy As PointApi
- destHdc = GetDC(0)
- GetCursorPos Pxy
- GetDcPic = BitBlt(PicDest.hdc, 0, 0, PicDest.Width, PicDest.Height, destHdc, Pxy.x, Pxy.y, vbSrcCopy)
- PicDest.Refresh
- End Function
- Public Function GetDcColor() As Double
- Dim destHdc&, Ret&
- Dim Pxy As PointApi
- destHdc = GetDC(0)
- GetCursorPos Pxy
- GetDcColor = GetPixel(destHdc, Pxy.x, Pxy.y)
- Ret& = ReleaseDC(0, destHdc)
- End Function
- Private Sub Timer1_Timer()
- PicColor.BackColor = GetDcColor
- Blue.Text = (PicColor.BackColor And &HFF0000) / &H10000
- Green.Text = (PicColor.BackColor And &HFF00&) / &H100&
- Red.Text = PicColor.BackColor And &HFF&
- GetDcPic
- End Sub
复制代码 Module1.Bas- Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointApi) As Long
- Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
- Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
- Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
- Public 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
- Public Type PointApi
- x As Long
- y As Long
- End Type
复制代码 |
评分
-
参与人数 1 | +20 |
水晶币 +20 |
+20 |
收起
理由
|
马大哈
| + 20 |
+ 20 |
+ 20 |
这个不错,框架已经有了:) |
查看全部评分
|