■ 트레이 상단에 폼 위치 설정하기

----------------------------------------------------------------------------------------------------

using System.Drawing;

using System.Runtime.InteropServices;

using System.Windows.Forms;

 

/// <summary>

/// 사각형

/// </summary>

[StructLayout(LayoutKind.Sequential)]

public struct RECT

{

    /// <summary>

    /// 왼쪽

    /// </summary>

    public int Left;

 

    /// <summary>

    /// 위쪽

    /// </summary>

    public int Top;

 

    /// <summary>

    /// 오른쪽

    /// </summary>

    public int Right;

 

    /// <summary>

    /// 아래쪽

    /// </summary>

    public int Bottom;

}

 

/// <summary>

/// 시스템 파라미터 정보 구하기

/// </summary>

/// <param name="action">작업</param>

/// <param name="parameter">파라미터</param>

/// <param name="rect">사각형</param>

/// <param name="winINI">WIN.INI 업데이트 플래그</param>

/// <returns></returns>

[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]

public static extern int SystemParametersInfo(int action, int parameter, out RECT rect, int winINI);

 

/// <summary>

/// SPI_GETWORKAREA

/// </summary>

private const int SPI_GETWORKAREA = 0x0030;

 

#region 위치 설정하기 - SetLocation(form)

 

/// <summary>

/// 위치 설정하기

/// </summary>

/// <param name="form">Form 객체</param>

public void SetLocation(Form form)

{

    RECT rect = new RECT();

    

    SystemParametersInfo(SPI_GETWORKAREA, 0, out rect, 0);

    

    Size size = form.Size;

    

    Point location = new Point(rect.Right - form.Width, rect.Bottom  - size.Height);

    

    form.Location = location;

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요