コード例 #1
0
ファイル: WindowHandleInfo.cs プロジェクト: WendyH/HMSEditor
        public List <IntPtr> GetAllChildHandles()
        {
            List <IntPtr> childHandles = new List <IntPtr>();

            GCHandle gcChildhandlesList      = GCHandle.Alloc(childHandles);
            IntPtr   pointerChildHandlesList = GCHandle.ToIntPtr(gcChildhandlesList);

            try {
                NativeMethods.EnumWindowProc childProc = new NativeMethods.EnumWindowProc(EnumWindow);
                NativeMethods.EnumChildWindows(this._MainHandle, childProc, pointerChildHandlesList);
            } finally {
                gcChildhandlesList.Free();
            }

            return(childHandles);
        }
コード例 #2
0
ファイル: WindowHandleInfo.cs プロジェクト: WendyH/HMSEditor
        public List<IntPtr> GetAllChildHandles()
        {
            List<IntPtr> childHandles = new List<IntPtr>();

            GCHandle gcChildhandlesList    = GCHandle.Alloc(childHandles);
            IntPtr pointerChildHandlesList = GCHandle.ToIntPtr(gcChildhandlesList);

            try {
                NativeMethods.EnumWindowProc childProc = new NativeMethods.EnumWindowProc(EnumWindow);
                NativeMethods.EnumChildWindows(this._MainHandle, childProc, pointerChildHandlesList);
            } finally {
                gcChildhandlesList.Free();
            }

            return childHandles;
        }
コード例 #3
0
        static List <IntPtr> GetAllChildHandles(IntPtr main)
        {
            var childHandles       = new List <IntPtr>();
            var gcChildhandlesList = GCHandle.Alloc(childHandles);

            try
            {
                var pointerChildHandlesList            = GCHandle.ToIntPtr(gcChildhandlesList);
                NativeMethods.EnumWindowProc childProc = new NativeMethods.EnumWindowProc(EnumWindow);
                NativeMethods.EnumChildWindows(main, childProc, pointerChildHandlesList);
            }
            finally
            {
                gcChildhandlesList.Free();
            }
            return(childHandles);
        }
コード例 #4
0
ファイル: frmSuperPutty.cs プロジェクト: keramist/superputty
 private static bool IsForegroundWindow(Form parent)
 {
     IntPtr fgWindow = NativeMethods.GetForegroundWindow();
     if (parent.Handle == fgWindow) return true; // main form is FG
     //foreach (Form f in Application.OpenForms) { if (f.Handle == fgWindow) return true; }
     List<IntPtr> result = new List<IntPtr>();
     GCHandle listHandle = GCHandle.Alloc(result);
     try
     {
         NativeMethods.EnumWindowProc childProc = new NativeMethods.EnumWindowProc(EnumWindow);
         NativeMethods.EnumChildWindows(parent.Handle, childProc, GCHandle.ToIntPtr(listHandle));
     }
     finally
     {
         if (listHandle.IsAllocated)
             listHandle.Free();
     }
     return result.Count > 0;
 }
コード例 #5
0
 public static extern bool EnumChildWindows(IntPtr window, NativeMethods.EnumWindowProc callback, IntPtr i);