728x90
반응형
728x170
▶ 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
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 컨트롤 비트맵 구하기 (0) | 2017.01.17 |
---|---|
[C#/WINFORM] 커서 구하기 (0) | 2017.01.17 |
[C#/WINFORM] WebBrowser 클래스 : DocumentCompleted 이벤트를 사용해 웹 문서 로드 완료시 처리하기 (0) | 2017.01.15 |
[C#/WINFORM] WebBrowser 클래스 : DocumentCompleted 이벤트를 사용해 웹 문서 로드 완료시 처리하기 (0) | 2017.01.15 |
[C#/WINFORM] 화면 보호기(Screen Saver) 만들기 (0) | 2017.01.15 |
[C#/WINFORM] 커스텀 메시지 박스 사용하기 (0) | 2017.01.15 |
[C#/WINFORM] Control 클래스 : MouseDown/MouseMove/MouseUp 이벤트를 사용해 도형 그리기 (0) | 2017.01.10 |
[C#/WINFORM] 알림 창 만들기 (0) | 2017.01.10 |
[C#/WINFORM] 폼 강제로 칠하기 (0) | 2016.12.14 |
[C#/WINFORM] 전체 화면 그래픽스 객체 구하기 (0) | 2016.12.14 |
댓글을 달아 주세요