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

TestProject.zip
0.01MB

▶ MainForm.cs

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

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

        #region 윈도우 디스플레이 어피너티 설정하기 - SetWindowDisplayAffinity(windowHandle, affinity)

        /// <summary>
        /// 윈도우 디스플레이 어피너티 설정하기
        /// </summary>
        /// <param name="windowHandle">윈도우 핸들</param>
        /// <param name="affinity">어피너티</param>
        /// <returns>처리 결과</returns>
        [DllImport("user32")]
        private static extern uint SetWindowDisplayAffinity(IntPtr windowHandle, uint affinity);

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// WDA_NONE
        /// </summary>
        private const uint WDA_NONE = 0;

        /// <summary>
        /// WDA_MONITOR
        /// </summary>
        private const uint WDA_MONITOR = 1;

        #endregion

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

        #region 생성자 - MainForm()

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

            this.preventButton.Click += preventButton_Click;
        }

        #endregion

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

        #region 캡처 방지 설정하기 버튼 클릭시 처리하기 - preventButton_Click(sender, e)

        /// <summary>
        /// 캡처 방지 설정하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void preventButton_Click(object sender, EventArgs e)
        {
            if(this.preventButton.Text == "캡처 방지 설정하기")
            {
                SetWindowDisplayAffinity(this.Handle, WDA_MONITOR);

                this.preventButton.Text = "캡처 방지 해제하기";
            }
            else
            {
                SetWindowDisplayAffinity(this.Handle, WDA_NONE);

                this.preventButton.Text = "캡처 방지 설정하기";
            }
        }

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

댓글을 달아 주세요