예제 #1
0
        /// <summary>MDIの子ウィンドウのうち、最前面のウィンドウハンドルを取得する</summary>
        private static IntPtr GetTopChildHandle(IntPtr windowHandle)
        {
            while (true)
            {
                IntPtr mdiHandle = WindowController2.FindWindowEx(windowHandle, IntPtr.Zero, "MDIClient", null);
                if (mdiHandle == IntPtr.Zero)
                {
                    continue;
                }

                var activeChildHandle = WindowController2.GetWindow(mdiHandle, GW_CHILD);
                if (activeChildHandle == IntPtr.Zero)
                {
                    throw new AutoCadException("MDIの子ウィンドウが見つかりませんでした。");
                }

                return(activeChildHandle);
            }
        }
예제 #2
0
        public static IntPtr GetTopDrawingHandle()
        {
            while (true)
            {
                var    autocadWindowHandle = WindowController2.GetAutoCadHandle();
                IntPtr mdiHandle           = WindowController2.FindWindowEx(autocadWindowHandle, IntPtr.Zero, "MDIClient", null);
                //AutoCadのハンドルをうまくとれない時がある。その時mdiHandleがZeroになる。
                if (mdiHandle == IntPtr.Zero)
                {
                    continue;
                }

                var activeChildHandle = WindowController2.GetWindow(mdiHandle, GW_CHILD);
                if (activeChildHandle == IntPtr.Zero)
                {
                    throw new AutoCadException("MDIの子ウィンドウが見つかりませんでした。");
                }

                return(activeChildHandle);
            }
        }
예제 #3
0
        public static List <IntPtr> GetDrawingHandles()
        {
            while (true)
            {
                var autocadWindowHandle = WindowController2.GetAutoCadHandle();

                IntPtr mdi = FindWindowEx(autocadWindowHandle, IntPtr.Zero, "MDIClient", null);
                if (mdi == IntPtr.Zero)
                {
                    continue;
                }

                List <IntPtr> childList = new List <IntPtr>();
                IntPtr        child     = WindowController2.GetWindow(mdi, GW_CHILD);
                while (child != IntPtr.Zero)
                {
                    childList.Add(child);

                    child = WindowController2.GetWindow(child, GW_HWNDNEXT);
                }

                return(childList);
            }
        }