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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:22:38+00:00 2026-06-12T01:22:38+00:00

I have a class like this class Keyboard { public: Keyboard(void); ~Keyboard(void); void SetHook(HINSTANCE

  • 0

I have a class like this

class Keyboard
{
public:
    Keyboard(void);
    ~Keyboard(void);
    void SetHook(HINSTANCE hInstance);
    LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
};


LRESULT CALLBACK Keyboard::keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    bool bControlKeyDown=0;
    bool caps = GetKeyState(VK_CAPITAL) < 0;

...

void Keyboard::SetHook(HINSTANCE hInstance)
{
    KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, Keyboard::keyboardHookProc, hInstance, NULL);
}

But the statement

KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, Keyboard::keyboardHookProc, hInstance, NULL);

Result in compile error

Error   7   error C3867: 'Keyboard::keyboardHookProc': function call missing argument list; use '&Keyboard::keyboardHookProc' to create a pointer to member

If I change to ‘&Keyboard::keyboardHookProc’ it also error, also when I cast to ‘(HOOKPROC) &Keyboard::keyboardHookProc’ it also error

Anyone please help

  • 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-12T01:22:40+00:00Added an answer on June 12, 2026 at 1:22 am

    This is common mistake for C-callbacks.

    Keyboard::keyboardHookProc must be static.

    [UPDATE]

    You must find some other way to get Keyboard object to this static method if you want to operate on Keyboard object in static Keyboard::keyboardHookProc. If you have one Keyboard you might use singleton pattern, If not then every static method must have its own Keyboard object.

    [UPDATE2]

    One of the way to link object with global function is by template object reference. But this work only for global objects:

    class Keyboard
    {
    public:
        Keyboard();
        ~Keyboard(void);
        LRESULT keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
    };
    
    LRESULT Keyboard::keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    }
    // global function interface 
    template <Keyboard& k>
    LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
       return k.keyboardHookProc(nCode, wParam, lParam);
    }
    
    
    Keyboard k; // global keyboard
    
    int main()
    {
       // this works
       SetWindowsHookEx(0, keyboardHookProc<k>, NULL, NULL);
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class like this: class MyClass{ public: MyClass(int Mode); private: std::map <
I have a class like this public class foo { private void getThread() {
I have a class like this: public class Contest { List<ContestTeam> Teams { get;
I have a class like this class GUI : public QWidget, public QThread When
I have a class like this, public class person { name Name {set; get;}
I have class like this below shown. which contains the shopping items where the
I have a class like this - class Messages { ... LinkedList<String> inputs; LinkedList<String>
I have a class like this: abstract class CrudResource extends Controller { type ResourceIdType
I have a class like this: class A { private: B* ptr; } But
So I have a class like this: class Encoder(object): movie = None def __init__(self,

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.