상세 컨텐츠

본문 제목

항상 떠 있는 폼

C#

by 탑~! 2012. 2. 28. 10:13

본문

using System.Runtime.InteropServices;
static public class FormHelper
{
       [DllImport("user32.dll")]
       static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
           int Y, int cx, int cy, uint uFlags);

       static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
       static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
       static readonly IntPtr HWND_TOP = new IntPtr(0);

       const UInt32 SWP_NOSIZE = 0x0001;
       const UInt32 SWP_NOMOVE = 0x0002;
       const UInt32 SWP_NOZORDER = 0x0004;
       const UInt32 SWP_NOREDRAW = 0x0008;
       const UInt32 SWP_NOACTIVATE = 0x0010;
       const UInt32 SWP_FRAMECHANGED = 0x0020;  /* The frame changed: send WM_NCCALCSIZE */
       const UInt32 SWP_SHOWWINDOW = 0x0040;
       const UInt32 SWP_HIDEWINDOW = 0x0080;
       const UInt32 SWP_NOCOPYBITS = 0x0100;
       const UInt32 SWP_NOOWNERZORDER = 0x0200;  /* Don't do owner Z ordering */
       const UInt32 SWP_NOSENDCHANGING = 0x0400;  /* Don't send WM_WINDOWPOSCHANGING */

       const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
}

//항상 위 설정
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);

//항상 위 해제
SetWindowPos(this.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);

'C#' 카테고리의 다른 글

Sample Entity Framework Provider For Oracle  (0) 2012.02.29
Windows Service 만들기  (0) 2012.02.28
test  (0) 2012.02.28
신뢰사이트 등록하기  (0) 2012.02.27
System Information  (0) 2012.02.15

관련글 더보기