'Mouse Cursor'에 해당되는 글 1건
- 2009.04.23 Control에 마우스 커서 이동하기
- Control에 마우스 커서 이동하기
- case C# 짜투리
- 2009. 4. 23. 11:15
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8
9 namespace MouseMove
10 {
11 public partial class frmTest : Form
12 {
13 public frmTest()
14 {
15 InitializeComponent();
16 }
17
18 private void SubMousePointMove(Control control)
19 {
20 try
21 {
22 int dintLocX = control.Location.X;
23 int dintLocY = control.Location.Y;
24
25 int dintX = (control.Width / 2) + dintLocX;
26 int dintY = (control.Height / 2) + dintLocY;
27
28 Point dMousePoint = new Point(dintX, dintY);
29
30 Cursor.Position = this.PointToScreen(dMousePoint);
31 }
32 catch (Exception ex)
33 {
34 }
35 }
36 }
37 }
자세한 설명은 생략한다!
간략설명 : 해당하는 Contorl의 좌표와 Size를 이용하여 Control의 중앙 위치를 계산하고 마우스 커서를 그 위치로 이동시킨다.
개발동기 : LG에서 만든 데스크탑을 사용하던 도중 창이 팝업되면 자동으로 마우스가 이동하는 걸 보고 만들게 됨.
핵심내용 :
Cursor.Position = this.PointToScreen(dMousePoint);
Recent comment