Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 641351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:03:12+00:00 2026-05-13T21:03:12+00:00

I want to use this function EnumWindows(EnumWindowsProc, NULL);. The EnumWindowsProc is a Callback function:

  • 0

I want to use this function “EnumWindows(EnumWindowsProc, NULL);”.
The EnumWindowsProc is a Callback function:

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);

For this callback I want to use a member function of a class.

e.g:

Class MyClass
{
    BOOL CALLBACK My_EnumWindowsProc(HWND hwnd, LPARAM lParam);
    void          test();
};

So i want to bind the called Callback with my function !!!

I try this:

void MyClass::test()
{
    EnumWindowsProc ptrFunc = mem_fun(&MyClass::My_EnumWindowsProc);
    EnumWindows(ptrFunc, NULL);
}

It’s doesn’t work, “mem_fun” can take only one argument !
Is it possible to do that ? else do you know another solution ?
(maybe a solution will be possible with Boost::bind)

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:03:12+00:00Added an answer on May 13, 2026 at 9:03 pm

    You need to create an Adapter, such as:

    #include <windows.h>
    #include <iostream>
    #include <string>
    using namespace std;
    
    class MyCallback
    {
    public:
        MyCallback() : count_(0) {};
        static BOOL CALLBACK CallbackAdapter(HWND, LPARAM);
        BOOL Callback(HWND);
        unsigned count_;
    };
    
    BOOL MyCallback::Callback(HWND wnd)
    {
        char title[1025] = {};
        GetWindowText(wnd, title, sizeof(title)-1);
        cout << wnd << "= '" << title << "'" << endl;
        ++count_;
        return TRUE;
    }
    
    BOOL MyCallback::CallbackAdapter(HWND wnd, LPARAM lp)
    {
        MyCallback* that = reinterpret_cast<MyCallback*>(lp);
        return that->Callback(wnd);
    }
    
    int main()
    {
        MyCallback cb;
        EnumWindows(&MyCallback::CallbackAdapter, reinterpret_cast<LPARAM>(&cb));
        cout << "Windows Found: " << cb.count_;
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AS3 class with some getVideo function. I want to use this
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I want to use a javascript countdown function similar to this http://jsfiddle.net/Apnu2/6/ when a
I want to use jquery delegate to call a function, and this works fine:
I want to use this function to get contours and within these contours, I
I want to use this function from mongoid: person.update_attributes(first_name: Jean, last_name: Zorg) But I
I want to use this function but preserving the uppercase or lowercase so for
I have a function that returns IEnumerable<IEnumerable<string>> . I want to use this function,
i want to use js this function: i have a string[] s={11111,2222,33333,...} how to
In javascript, when would you want to use this: (function(){ //Bunch of code... })();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.