■ SetWindowPos API 함수를 선언하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
using System; using System.Runtime.InteropServices; #region 윈도우 위치 설정하기 - SetWindowPos(windowHandle, windowHandleInsertAfter, x, y, width, height, flag) /// <summary> /// 윈도우 위치 설정하기 /// </summary> /// <param name="windowHandle">윈도우 핸들</param> /// <param name="windowHandleInsertAfter">삽입 이후 윈도우 핸들</param> /// <param name="x">X 좌표</param> /// <param name="y">Y 좌표</param> /// <param name="width">너비</param> /// <param name="height">높이</param> /// <param name="flag">플래그</param> /// <returns>처리 결과</returns> [DllImport("user32")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetWindowPos(IntPtr windowHandle, IntPtr windowHandleInsertAfter, int x, int y, int width, int height, SetWindowPosFlag flag); #endregion #region 윈도우 위치 설정 플래그 - SetWindowPosFlag /// <summary> /// 윈도우 위치 설정 플래그 /// </summary> [Flags] public enum SetWindowPosFlag : uint { /// <summary> /// SWP_ASYNCWINDOWPOS /// </summary> SWP_ASYNCWINDOWPOS = 0x4000, /// <summary> /// SWP_DEFERERASE /// </summary> SWP_DEFERERASE = 0x2000, /// <summary> /// SWP_DRAWFRAME /// </summary> SWP_DRAWFRAME = 0x0020, /// <summary> /// SWP_FRAMECHANGED /// </summary> SWP_FRAMECHANGED = 0x0020, /// <summary> /// SWP_HIDEWINDOW /// </summary> SWP_HIDEWINDOW = 0x0080, /// <summary> /// SWP_NOACTIVATE /// </summary> SWP_NOACTIVATE = 0x0010, /// <summary> /// SWP_NOCOPYBITS /// </summary> SWP_NOCOPYBITS = 0x0100, /// <summary> /// SWP_NOMOVE /// </summary> SWP_NOMOVE = 0x0002, /// <summary> /// SWP_NOOWNERZORDER /// </summary> SWP_NOOWNERZORDER = 0x0200, /// <summary> /// SWP_NOREDRAW /// </summary> SWP_NOREDRAW = 0x0008, /// <summary> /// SWP_NOREPOSITION /// </summary> SWP_NOREPOSITION = 0x0200, /// <summary> /// SWP_NOSENDCHANGING /// </summary> SWP_NOSENDCHANGING = 0x0400, /// <summary> /// SWP_NOSIZE /// </summary> SWP_NOSIZE = 0x0001, /// <summary> /// SWP_NOZORDER /// </summary> SWP_NOZORDER = 0x0004, /// <summary> /// SWP_SHOWWINDOW /// </summary> SWP_SHOWWINDOW = 0x0040, } #endregion |