VB中如何将光标位置更改为图片框位置
我认为标题很清楚,但我会尝试更深入地了解它。
所以我创建了一个用鼠标玩的游戏,就像游戏迷宫一样。你不能碰墙,否则你就输了。
当我启动关卡时,我希望光标出现在它的起始位置,这是一个红色图片框,但我不知道如何...
这是我使用的代码:
Windows.Forms.Cursor.Position = New Point(679 , 650)
正如您所看到的,这段代码存在很大的问题。
光标出现的位置实际上取决于屏幕的分辨率。
例如:对于我的显示器分辨率,位置(679, 650)位于我需要它出现的图片框的顶部。但如果你的显示器上有不同的分辨率,它会出现在不同的地方......
我实际上需要让它出现在图片框的顶部。
我希望我能比这更清楚:(
i think the title is pretty clear but i'll try to get more into it.
so i created a game where you use the mouse to play, it's like the game labirynth. you can't touch the walls or you lose.
when i start the level i want the cursor to appear in it's starting position, which is a red picturebox, but i dont know how to...
here is the code i used:
Windows.Forms.Cursor.Position = New Point(679, 650)
as you can see there is a massive problem about this code.
the location where the cursor appears is actuallt dependent of the resolution of the screen.
for example: with my monitor resolution, the location (679, 650) is right on top of the picturebox i need it to appear on. but if you have a different resolution on your monitor it will appear on a different place...
i need to actually make it appear on top of the picturebox.
i wish i could be clearer than this :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在获取图片位置值后设置鼠标位置。
you can set your mouse location after taking the value of your picture position.