첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170
using System;
using System.Drawing;
using System.Runtime.InteropServices;

#region 윈도우 배치 구하기 - GetWindowPlacement(windowHandle, windowPlacement)

/// <summary>
/// 윈도우 배치 구하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="windowPlacement">윈도우 배치</param>
/// <returns>처리 결과</returns>
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowPlacement(IntPtr windowHandle, out WINDOWPLACEMENT windowPlacement);

#endregion

#region 윈도우 명령 표시 - ShowWindowCommand

/// <summary>
/// 윈도우 명령 표시
/// </summary>
public enum ShowWindowCommand : int
{
    /// <summary>
    /// SW_HIDE
    /// </summary>
    SW_HIDE = 0,

    /// <summary>
    /// SW_SHOWNORMAL
    /// </summary>
    SW_SHOWNORMAL = 1,

    /// <summary>
    /// SW_SHOWMINIMIZED
    /// </summary>
    SW_SHOWMINIMIZED = 2,

    /// <summary>
    /// SW_MAXIMIZE
    /// </summary>
    SW_MAXIMIZE = 3,

    /// <summary>
    /// SW_SHOWMAXIMIZED
    /// </summary>
    SW_SHOWMAXIMIZED = 3,

    /// <summary>
    /// SW_SHOWNOACTIVATE
    /// </summary>
    SW_SHOWNOACTIVATE = 4,

    /// <summary>
    /// SW_SHOW
    /// </summary>
    SW_SHOW = 5,

    /// <summary>
    /// SW_MINIMIZE
    /// </summary>
    SW_MINIMIZE = 6,

    /// <summary>
    /// SW_SHOWMINNOACTIVE
    /// </summary>
    SW_SHOWMINNOACTIVE = 7,

    /// <summary>
    /// SW_SHOWNA
    /// </summary>
    SW_SHOWNA = 8,

    /// <summary>
    /// SW_RESTORE
    /// </summary>
    SW_RESTORE = 9
}

#endregion
#region 포인트 - POINT

/// <summary>
/// 포인트
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Field
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region Field

    /// <summary>
    /// X
    /// </summary>
    public int X;

    /// <summary>
    /// Y
    /// </summary>
    public int Y;

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Field
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - POINT(x, y)

    /// <summary>
    /// 생성자
    /// </summary>
    /// <param name="x">X 좌표</param>
    /// <param name="y">Y 좌표</param>
    public POINT(int x, int y)
    {
        X = x;
        Y = y;
    }

    #endregion

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

    #region Point 타입 암시적 변환하기 - Point(point)

    /// <summary>
    /// Point 타입 암시적 변환하기
    /// </summary>
    /// <param name="point">포인트</param>
    public static implicit operator Point(POINT point)
    {
        return new Point(point.X, point.Y);
    }

    #endregion
    #region POINT 타입 암시적 변환하기 - POINT(point)

    /// <summary>
    /// POINT 타입 암시적 변환하기
    /// </summary>
    /// <param name="point">포인트</param>
    public static implicit operator POINT(Point point)
    {
        return new POINT(point.X, point.Y);
    }

    #endregion
}

#endregion
#region 사각형 - RECT

/// <summary>
/// 사각형
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Field
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region Field

    /// <summary>
    /// 왼쪽
    /// </summary>
    public int Left;

    /// <summary>
    /// 위쪽
    /// </summary>
    public int Top;

    /// <summary>
    /// 오른쪽
    /// </summary>
    public int Right;

    /// <summary>
    /// 아래쪽
    /// </summary>
    public int Bottom;

    #endregion
}

#endregion
#region 윈도우 배치 - WINDOWPLACEMENT

/// <summary>
/// 윈도우 배치
/// </summary>
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPLACEMENT
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Field
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region Field

    /// <summary>
    /// 길이
    /// </summary>
    public int Length;

    /// <summary>
    /// 길이
    /// </summary>
    public int Flag;

    /// <summary>
    /// 윈도우 명령 표시 여부
    /// </summary>
    public ShowWindowCommand ShowWindowCommand;

    /// <summary>
    /// 최소 위치
    /// </summary>
    public POINT MinimumPosition;

    /// <summary>
    /// 최대 위치
    /// </summary>
    public POINT MaximumPosition;

    /// <summary>
    /// 일반 사각형
    /// </summary>
    public RECT NormalRectangle;

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Property
    ////////////////////////////////////////////////////////////////////////////////////////// Static
    //////////////////////////////////////////////////////////////////////////////// Public

    #region 디폴트 - Default

    /// <summary>
    /// 디폴트
    /// </summary>
    public static WINDOWPLACEMENT Default
    {
        get
        {
            WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT();

            windowPlacement.Length = Marshal.SizeOf(windowPlacement);

            return windowPlacement;
        }
    }

    #endregion
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요