How to convert a cwnd object to an hwnd window handle?

Source: Internet
Author: User
 
Cwnd * WND;
Hwnd;

How do they convert each other?

1. WND-> m_wnd;
2. cwnd * WND = cwnd: fromhandle (hwnd)

Do you mean force conversion? I'm afraid not? WND is the window pointer, and hwnd is the window handle! However, they can be obtained from each other as follows:
Hwnd = WND-> m_hwnd;
WND. atach (hwnd)
Create a cwnd object and use attach to associate hwnd with the cwnd object.

Static cwnd * Pascal fromhandle (hwnd); construct a cwnd * pointer through hwnd (but this pointer will be deleted when idle, so it cannot be saved for future use ).

// Cwnd object to hwnd:
Cwnd WND;
Hwnd;

Hwnd = WND. m_hwnd;
// Or
Hwnd = WND. getsafehwnd (); // recommended

// Hwnd to cwnd object:
Cwnd * pwnd;
Hwnd;

Pwnd = cwnd: fromhandle (hwnd );
// Or
Pwnd-> attach (hwnd );

Http://blog.chinaunix.net/u/28371/showart_234740.html

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.