Callback Function in Windows

Source: Internet
Author: User


The callback function must be defined as a global function or a static class member function.

This parameter is not provided for callback because the member function of a common class calls the implicit passed this pointer.

For example:

Enumerate the APIs of windows in the current system.

Bool enumwindows (wndenumproc lpenumfunc, lparam)

The callback function is:
Bool callback enumwindowsproc (hwnd, lparam );

If you want to set the callback function as a member function of the class, you must declare the following in the class:
Static bool callback myenumwindowsproc (hwnd, lparam );

Implementation:
Bool ceasygamedlg: myenumwindowsproc (hwnd, lparam ){
 // Do...
 Return true;
}

In this case, the this value cannot be used in the myenumwindowsproc implementation.

========================================================== ============================

It can be noted that in enumwindows, an lparam is provided for us to pass our own
Parameter, so we can pass this pointer in:

Enumwindows (myenumwindowsproc, (lparam) This );

--------------

Bool ceasygamedlg: myenumwindowsproc (hwnd, lparam ){

 Ceasygamedlg * _ this = (ceasygamedlg *) lparam;

 _ This-> MessageBox (title );

 Return true;
 
}

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.