| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 893 人关注过本帖, 1 人收藏
标题:如何在屏幕上画圈
只看楼主 加入收藏
husiwen
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:227
专家分:1125
注 册:2010-5-23
结帖率:100%
收藏(1)
已结贴  问题点数:5 回复次数:3 
如何在屏幕上画圈
如何用vb在电脑屏幕中心画个小红圈。。是屏幕上不是窗体上。。
搜索更多相关主题的帖子: 屏幕 
2010-07-06 12:12
husiwen
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:227
专家分:1125
注 册:2010-5-23
收藏
得分:0 
想做个CS盲狙准星
2010-07-06 12:21
jiashie
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:237
专家分:999
注 册:2009-4-30
收藏
得分:5 
程序代码:
Option Explicit
Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Const PS_SOLID = 0

Private Sub Command1_Click()
Dim x As Long
Dim y As Long
Dim deskHwnd As Long
Dim hDeskDC As Long
Dim hPen As Long

x = Screen.Width / Screen.TwipsPerPixelX / 2
y = Screen.Height / Screen.TwipsPerPixelY / 2

deskHwnd = GetDesktopWindow()
hDeskDC = GetWindowDC(deskHwnd)
If hDeskDC = 0 Then Exit Sub

hPen = CreatePen(PS_SOLID, 2, vbRed)
If hPen = 0 Then Exit Sub

SelectObject hDeskDC, hPen

Ellipse hDeskDC, x - 10, y - 10, x + 10, y + 10

DeleteObject hPen
ReleaseDC deskHwnd, hDeskDC
End Sub

电脑中没有cs,无法测试。
另外:当桌面屏幕内容覆盖后,无法自动重画,只能暂时把它放到一个timer里,不停地画圆的方式来解决。
2010-07-06 13:34
wyld
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-7-6
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
2010-07-06 16:06
快速回复:如何在屏幕上画圈
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034849 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved