C # Window Handle problem (EXT) __c#

Source: Internet
Author: User

1. How to get a handle to a window.
For example, to get a handle to a window PictureBox control (which other controls can also),

INTPTR handle = Picturebox.handle;

2, note: Window creation and window creation is a handle is completely different ...
When a window is created, the window does not create a handle, only Application.Run (form) or form. Show () is followed by a handle, that is, the window only displays or starts the message loop only after the handle. If you create a form after form. Form. = new Form (), call form in main thread. Handle, if the handle has not been created, referencing the property will force the creation of the handle, which will have a fatal effect on the logic within the system.
3, how to determine the handle of a window to create complete.
Use the Ishandlecreated property: This property indicates whether the control has a handle associated with him, or true if a handle has been assigned to the control, otherwise false.
4, some properties:
(1), CreateControl: Forces the creation of controls, including handles and any child controls
(2), CreateHandle: Creates a handle for the control,
In general, you should not call the CreateHandle method directly. The preferred method is to invoke the CreateControl method, which forces a handle to be created for the control and its child controls when the control is created. Description to Inheritors When overriding CreateHandle in a derived class, make sure that the CreateHandle method of the base class is invoked to ensure that the handle is created.
(3), Destroyhandle: Destroys the handle associated with the control
(4), Fromchildhandle: Retrieving the control containing the specified handle
(5), FromHandle: Returns the control that is currently associated with the specified handle
(6), Handle: Gets the window handle to which the control is bound, and the value of the Handle property is the Windows HWND. If the handle has not been created, referencing the property will force the handle to be created.
(7), ishandlecreated: Indicates whether the control has a handle associated with him, true if a handle has been assigned to the control, or false otherwise.
(8), Recreatehandle: Forcing the handle to be re-created for the control
(9), Recreatinghandle: Indicates whether the handle is currently being hit
5. Note:
The handle is a random amount, and two times the operation will normally get a different result two times.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.