Get a handle to form coordinates

2010-09-10  来源:本站原创  分类:DotNet  人气:170 

Namespace

using System.Runtime .InteropServices;

Statement sector

Point p;
        /// <summary>
        ///  Gets the coordinates of the mouse
        /// </summary>
        /// <param name="p"> Gets the coordinates of the structure  </param>
        /// <returns> Returns the mouse coordinates obtained success  </returns>
        [DllImport("user32.dll")]
        private static extern bool GetCursorPos(out Point p);

        /// <summary>
        ///  According to coordinates to obtain the handle of the form
        /// </summary>
        /// <param name="p"> Coordinate structure  </param>
        /// <returns> Returns the handle of the form  </returns>
        [DllImport("user32.dll")]
        private static extern IntPtr WindowFromPoint(Point p);

Main code

private void timer1_Tick(object sender, EventArgs e)
        {
            if (GetCursorPos(out p))
            {
                // Gets the window of the mouse  handle
                IntPtr hwndCurWindow = WindowFromPoint(p);
                // Converted to hex display
               this.label1.Text  = string.Format(" Handle  :{0}", hwndCurWindow.ToString("X"));
            }
        }
相关文章
  • Get a handle to form coordinates 2010-09-10

    Namespace using System.Runtime .InteropServices; Statement sector Point p; /// <summary> /// Gets the coordinates of the mouse /// </summary> /// <param name="p"> Gets the coordinates of the structure </param> /// <ret

  • struts2 dynamic form 2010-08-11

    MyAction.java public class MyAction extends AbstractAction { private List personList; // Generated form public String execute() { personList = buildPersonList(); return this.SUCCESS; } // Handle the form submission public String update(){ Iterator it

  • Part IV: Passing form data (MVC case tutorial (based on the ASP.NET MVC beta)) 2010-11-05

    Abstract This article will complete our "MVC announcement system" announcement function, as demonstrated in the ASP.NET MVC, how to pass form data processing. Preface Through the previous articles, we have been able to use the ASP.NET MVC relati

  • Submit the form to avoid duplication 2011-01-04

    Submit the form to avoid duplication when the user submits the form the reason may be because of speed, or malicious web pages to refresh, resulting in duplication of the same record into the database, this is a more difficult problem. We can from th

  • ImageZoom image magnification effect (expansion of article) 2010-04-16

    On a ImageZoom effect has been done on the image to enlarge detailed analysis, this time based on the ImageZoom expansion, to achieve more results. Major expansion of the original image and display box, display model, there are several modes: "Follow

  • delphi common property of the event description 2010-07-20

    DELPHI common property description: align setting component alignment (with the parent container) mode borderstyle border shape set components caption setting component title ctl3d set whether the 3D model component border if borderstyle bsnone then

  • Share python automatic clearance 2010-10-11

    #saolei.py # coding: cp936 import win32gui import win32process import win32con import win32api from ctypes import * ''' Under the first principle of that, the principle is very simple , Managed to get "minefield " Data, and then by simulating mo

  • Encapsulates the Jakarta file upload function in a class 2010-03-21

    Encapsulates the Jakarta file upload function in a class Postscript: I remember having a supported version of the encoding settings, but no had to go home .. and then take a look at things are not done their own version management, very confused ....

  • DispatchAction with MappingDispatchAction the difference between 2010-03-22

    Their difference is: 1.MappingDispatchAction is DispatchAction sub-categories: 2. Configuration file: MappingDispatchAction the same path can have multiple profiles (the same Action instance have more than one configuration), but it must be noted tha

  • Reprinted PHP Application Framework Design: 2 - Managing Users 2010-02-24

    Transfer from: http://www.lbsharp.com/wordpress/index.php/2005/10/13/php-application-framework-design-2-managing-users/ This is part 2 of a multi-part series on the design of a complete application framework written in PHP. In part 1, we covered the

  • 2009-12-21 Chuan Chi podcast - Struts1 (Reprinted) 2010-04-10

    Struts1 Today is the day after tomorrow is the last day. I say see how many feel Struts1 irritated. As always use the configuration file, not how to write code, a powerful form validation function is complete. In fact, we have been focused on code re

  • CGI of the C language articles 2010-06-03

    Why the CGI programming? In HTML, when customers fill out the form and press the send (submit) button, the form content is sent to the server side, in general, then it needs a server-side script to the contents of the form some deal, or save them up,

  • Struts2 Type Convertion 2010-06-25

    Why type of conversion? HTTP protocol is any content transmitted String type, so if we need a server on a non-String types of objects, such as: int or a Date, then we need to receive the HTTP request data, the first to String type of data transformat

  • Implemented using java Swing Tips bubble effect 2010-09-04

    Stunning results, see Annex screenshot package monitor.ico; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.Rectangle; import javax.swing.BorderFa

  • Analyze web pages and the parent window, child window interaction 2010-10-11

    1, the parent window to pass information to the child window Look at the code example: <script language=javascript> function outPut () ... { / / Get the parent window's text message assigned to the text var text = document.abc.text.value; / / Open c

  • Submit a question to prevent the duplication of Php Summary 2010-10-28

    When the user submits the form the reason may be because of speed, or malicious web pages to refresh, resulting in duplication of the same record into the database, this is a more difficult problem. We can from the client and server side start with,

  • Web page data capture three ways (Reprinted) 2010-10-29

    Personal website owners believe that all people have the data capture the experience of it, the current method of data capture is simply another site in two ways: First, the use of third-party tools, most notably the engine collector, this does not d

  • Servlet doGet and doPost difference in 2010-10-30

    Servlet doGet and doPost difference in Serlvet interface defines a service is to service, while the HttpServlet class implements the method called and asked one of the following methods: doGet: handling GET request doPost: POST request when the issue

  • jsp interview questions 2010-11-15

    1, how to mix using Jsp and SSI # include? JSP can be used in the following ways contain pure HTML: <!--# Include file = "data.inc" -> However, if data.inc contains JSP CODE, we can use: <% @ Include file = "data.inc"%> 2,

  • Wikipedia cards and servlet comparison with traditional CGI 2010-12-25

    business card servlet Wikipedia Servlet is a server-side Java application, platform and protocol independent features that can generate dynamic Web pages. It acts as client request (Web browser or other HTTP client) and server response (HTTP server,