0

I am using following code from this post,

#include "WinUser.h"


 void CALLBACK HandleWndEvent(HWINEVENTHOOK hWinEventHook, DWORD eventType, 
              HWND hWnd, LONG idObject, LONG idChild, 
              DWORD eventTypeThread, DWORD dwmsEventTime){
    ...
}

_hWinEventHook = ::SetWinEventHook(_eventMin,
            _eventMax,
            0,
            HandleWndEvent,
            0,
            0, WINEVENT_OUTOFCONTEXT);

however, I cann't compile this code.

The error I get is:

enter image description here

How do I fix this?

Yen Dang
  • 268
  • 2
  • 9
  • 2
    You need to make the callback `static`, i.e. it can't be a non-static class member. – Jonathan Potter Aug 03 '22 at 07:16
  • Hi @JonathanPotter, Thanks you, the code finally compiled. I was thinking used wrong header file. :( problem solved. – Yen Dang Aug 03 '22 at 07:20
  • *"I am using following code from this [post](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwineventhook)."* - No, you aren't. You have made significant changes to it, none of them are visible from the code provided. The issue can only be inferred from the error diagnostic, which you should be posting as text. If you want to make this question more useful, provide a [mcve] alongside the compiler output *as text*. – IInspectable Aug 03 '22 at 07:34

0 Answers0