コード例 #1
0
ファイル: WindowFinder.cs プロジェクト: Nucs/nlib
        /// <summary>
        /// Handles the MouseUp event of the picTarget control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void picTarget_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            IntPtr hWnd;
            IntPtr hTemp;

            // End targeting
            isTargeting = false;

            // Unhighlight window
            if (targetWindow != IntPtr.Zero)
            {
                NativeWin32.HighlightWindow(targetWindow);
            }
            targetWindow = IntPtr.Zero;

            // Reset capture image and cursor
            picTarget.Cursor = Cursors.Default;
            picTarget.Image  = bitmapFind;

            // Get screen coords from client coords and window handle
            hWnd = NativeWin32.WindowFromPoint(picTarget.Handle, e.X, e.Y);

            // Get owner
            while ((hTemp = NativeWin32.GetParent(hWnd)) != IntPtr.Zero)
            {
                hWnd = hTemp;
            }

            SetWindowHandle(hWnd);

            // Release capture
            NativeWin32.SetCapture(IntPtr.Zero);
        }
コード例 #2
0
ファイル: WindowFinder.cs プロジェクト: Nucs/nlib
        /// <summary>
        /// Handles the MouseDown event of the picTarget control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        private void picTarget_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Set capture image and cursor
            picTarget.Image  = bitmapFinda;
            picTarget.Cursor = cursorTarget;

            // Set capture
            NativeWin32.SetCapture(picTarget.Handle);

            // Begin targeting
            isTargeting  = true;
            targetWindow = IntPtr.Zero;

            // Show info   TODO: Put into function for mousemove & mousedown
            SetWindowHandle(picTarget.Handle);
        }