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

TestProject.zip
0.02MB

▶ AnimateWindowType.cs

using System;

namespace TestProject
{
    /// <summary>
    /// 윈도우 애니메이션 종류
    /// </summary>
    [Flags]
    public enum AnimateWindowType : int
    {
        HorizontalPositive = 0x00001,
        HorizontalNegative = 0x00002,
        VerticallyPositive = 0x00004,
        VerticallyNegative = 0x00008,
        Center             = 0x00010,
        Hide               = 0x10000,
        Activate           = 0x20000,
        Slide              = 0x40000,
        Blend              = 0x80000
    }
}

 

728x90

 

▶ WINAPI.cs

using System;
using System.Runtime.InteropServices;

namespace TestProject
{
    /// <summary>
    /// WIN API
    /// </summary>
    public class WINAPI
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Import
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 윈도우 애니메이션 하기 - AnimateWindow(windowHandle, animationTime, animateWindowType)

        /// <summary>
        /// 윈도우 애니메이션 하기
        /// </summary>
        /// <param name="windowHandle">윈도우 핸들</param>
        /// <param name="animationTime">애니메이션 시간</param>
        /// <param name="animateWindowType">윈도우 애니메이션 종류</param>
        /// <returns>처리 결과</returns>
        [DllImport("user32")]
        public static extern int AnimateWindow(IntPtr windowHandle, int animationTime, int animateWindowType);

        #endregion
    }
}

 

300x250

 

▶ 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
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region Open 버튼 클릭시 처리하기 - openButton_Click(sender, e)

        /// <summary>
        /// Open 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void openButton_Click(object sender, EventArgs e)
        {
            TestForm testForm = new TestForm(500, AnimateWindowType.Blend);

            testForm.Show();
        }

        #endregion
    }
}

 

▶ TestForm.cs

using System;
using System.Windows.Forms;

namespace TestProject
{
    /// <summary>
    /// 테스트 폼
    /// </summary>
    public partial class TestForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Field
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Field

        /// <summary>
        /// 애니메이션 시간 (밀리초)
        /// </summary>
        private int animationTime;

        /// <summary>
        /// 윈도우 애니메이션 종류
        /// </summary>
        private AnimateWindowType animateWindowType;

        #endregion

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

        #region 생성자 - TestForm()

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

        #endregion
        #region 생성자 - TestForm(animationTime, animateWindowType)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="animationTime">애니메이션 시간</param>
        /// <param name="animateWindowType">윈도우 애니메이션 종류</param>
        public TestForm(int animationTime, AnimateWindowType animateWindowType)
        {
            this.animationTime     = animationTime;
            this.animateWindowType = animateWindowType;

            InitializeComponent();

            Load                   += Form_Load;
            this.closeButton.Click += closeButton_Click;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

        /// <summary>
        /// 폼 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Form_Load(object sender, EventArgs e)
        {
            WINAPI.AnimateWindow(Handle, animationTime, (int)animateWindowType);
        }

        #endregion
        #region Close 버튼 클릭시 처리하기 - _btnClose_Click(sender, e)

        /// <summary>
        /// Close 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void closeButton_Click(object sender, EventArgs e)
        {
            Close();
        }

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

댓글을 달아 주세요