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

TestProject.zip
다운로드

▶ ProgressBarState.cs

namespace TestProject
{
    ///진행바 상태
    public static class ProgressBarState
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region Field

        /// <summary>
        /// NORMAL
        /// </summary>
        public static readonly int NORMAL = 1;

        /// <summary>
        /// ERROR
        /// </summary>
        public static readonly int ERROR = 2;

        /// <summary>
        /// WARNING
        /// </summary>
        public static readonly int WARNING = 3;

        #endregion
    }
}

 

▶ ProgressBarExtension.cs

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

namespace TestProject
{
    /// <summary>
    /// 진행바 확장
    /// </summary>
    public static class ProgressBarExtension
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Import
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 메시지 보내기 - SendMessage(windowHandle, message, wordParameter, longParameter)

        /// <summary>
        /// 메시지 보내기
        /// </summary>
        /// <param name="windowHandle">윈도우 핸들</param>
        /// <param name="message">윈도우 메시지</param>
        /// <param name="wordParameter">WORD 매개 변수</param>
        /// <param name="longParameter">LONG 매개 변수</param>
        /// <returns>처리 결과</returns>
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
        private static extern IntPtr SendMessage(IntPtr windowHandle, uint message, IntPtr wordParameter, IntPtr longParameter);

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 진행바 상태 설정하기 - SetProgressBarState(progressBar, state)

        /// <summary>
        /// 진행바 상태 설정하기
        /// </summary>
        /// <param name="progressBar">진행바</param>
        /// <param name="state">상태</param>
        public static void SetProgressBarState(this ProgressBar progressBar, int state)
        {
            SendMessage(progressBar.Handle, 1040, (IntPtr)state, IntPtr.Zero);
        }

        #endregion
    }
}

 

▶ MainForm.cs

using System;
using System.Windows.Forms;

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

        #region 생성자 - MainForm()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 로드시 처리하기 - OnLoad(e)

        /// <summary>
        /// 로드시 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.normalStateProgressBar.SetProgressBarState(ProgressBarState.NORMAL);

            this.errorStateProgressBar.SetProgressBarState(ProgressBarState.ERROR);

            this.warningStateProgressBar.SetProgressBarState(ProgressBarState.WARNING);
        }

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

댓글을 달아 주세요