첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainForm.cs

using System;
using System.Drawing;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 복구 사각형
        /// </summary>
        private Rectangle restoreRectangle;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            this.mouseLimitCheckBox.CheckedChanged += mouseLimitCheckBox_CheckedChanged;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 마우스 제한 체크 박스 체크 변경시 처리하기 - mouseLimitCheckBox_CheckedChanged(sender, e)

        /// <summary>
        /// 마우스 제한 체크 박스 체크 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void mouseLimitCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if(this.mouseLimitCheckBox.Checked)
            {
                this.restoreRectangle = Cursor.Clip;

                Cursor = new Cursor(Cursor.Current.Handle);

                Cursor.Position = new Point
                (
                    Location.X + this.mouseLimitLabel.Location.X,
                    Location.Y + this.mouseLimitLabel.Location.Y
                );

                Point startPoint = new Point
                (
                    Location.X + this.mouseLimitLabel.Location.X + 7,
                    Location.Y + this.mouseLimitLabel.Location.Y + 30
                );
                
                Cursor.Clip = new Rectangle(startPoint, this.mouseLimitLabel.Size);
            }
            else
            {
                Cursor.Clip = this.restoreRectangle;
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요