본문 바로가기
프로그래밍/C#.net

바탕화면을 부모로 가지기

by 건우아빠유리남편 2009. 3. 24.
반응형
public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        private static extern IntPtr FindWindow(string  lpClassName,string  lpWindowName);

        [DllImport("user32.dll")]
        private static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);

        [DllImport("User32.dll")]
        private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        private const int GW_CHILD = 5;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IntPtr Progmanhwnd = IntPtr.Zero;
            IntPtr hwd1, hwd2, hwd3;
            Progmanhwnd = (IntPtr)FindWindow("Progman", "Program Manager");
            hwd1 = GetWindow(Progmanhwnd, GW_CHILD);
            hwd2 = GetWindow(hwd1, GW_CHILD);
            hwd3 = GetWindow(hwd2, GW_CHILD);

            SetParent(this.Handle, hwd2);

        }

    }
반응형

댓글