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 7743701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:36:09+00:00 2026-06-01T09:36:09+00:00

So i’m working on a simple win32 wrapper for my own convenience, and i’ve

  • 0

So i’m working on a simple win32 wrapper for my own convenience, and i’ve run into a slightly complicated problem.

this has alot of other members, but i’m omitting a bit and leaving just the offending members.

class Windows::AbstractWindow
{
public:
     void InstallHandler(UINT msgName, void (Windows::AbstractWindow::*)(HWND, UINT, WPARAM, LPARAM));

private:
     std::map<UINT, void (Windows::AbstractWindow::*)(HWND, UINT, WPARAM, LPARAM)> HandlerIndex;

};

(for the record, Windows in this case is a namespace of various classes and objects i’ve made)

just a bit nasty but lemme explain my process and reasoning. i have a made a class called AbstractWindow which contains most of all of the functionality of a window in a very object oriented way.

I’m now working on a method of taking private member functions, and storing them in a map via pointers to them, which are identified by the Windows message that they are supposed to handle. This way, when a message is received by the windows procedure, it digs through this map to see if you’ve installed a handler for it. If it has it calls that function and exits. It it hasn’t it calls DefWindowProc and exits. easy enough.

However, this object is never supposed to be instantiated and is simply supposed to be inherited from and extended. problem is, that map’s function pointer declaraction is of type AbstractWindow which will not allow me to store member function pointers of a type inherited from AbstractWindow. For example,

class BasicWindow : public Windows::AbstractWindow
{
public:
    BasicWindow() 
    {
         InstallHandler(WM_CREATE, &create);
    }

private:
    void Create(HWND, UINT, WPARAM, LPARAM) {}
}

… yields an error:

error C2664: 'Windows::AbstractWindow::InstallHandler' : cannot convert parameter 2 from 'void (__thiscall BasicWindow::* )(HWND,MSG,WPARAM,LPARAM)' to 'void (__thiscall Windows::AbstractWindow::* )(HWND,UINT,WPARAM,LPARAM)'

because the pointer types are not the same, despite being inherited from the base class. So does anyone wish to suggest a solution while still maintaining this method? And if not, i’m also open to suggestions that you think would make message handling more convenient than this way.

  • 1 1 Answer
  • 0 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-06-01T09:36:10+00:00Added an answer on June 1, 2026 at 9:36 am

    You should read up on the Curiously Recurring Template Pattern (http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern).

    Basically, you turn your base class into a template with a template parameter that specifies the sub-class.

    Perhaps it’ll be easier to understand if you see it:

    namespace Windows
    {
         template <typename T>
         class AbstractWindow
         {
         public:
              void InstallHandler(UINT msgName, void (T::*)(HWND, UINT, WPARAM, LPARAM));
    
         private:
              std::map<UINT, void (T::*)(HWND, UINT, WPARAM, LPARAM)> HandlerIndex;
    
         };
    }
    
    class BasicWindow : public Windows::AbstractWindow< BasicWindow >
    {
    public:
        BasicWindow() 
        {
             InstallHandler(WM_CREATE, &BasicWindow::Create);
        }
    
    private:
        void Create(HWND, UINT, WPARAM, LPARAM) {}
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.