Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Class method called by keyboard hook callback has an empty "this" pointer
Class method called by keyboard hook callback has an empty "this" pointer [message #37334] |
Sun, 23 September 2012 11:31  |
Mircode
Messages: 17 Registered: September 2012
|
Promising Member |
|
|
Hello!
I managed to create a working low level keyboard hook on windows. Now I want to update a label in my GUI everytime something happens.
In order to access my main window class from the hook callback, I created a global variable, which points to this class:
Inside the constructor I define it
KeyBuddy2::KeyBuddy2()
{
MainWindow=this;
CtrlLayout(*this, "Window title");
SetHook();
}
Inside the LowLevelKeyboardProc function, I call
MainWindow->ProcessKbdEvent(...)
but inside the ProcessKbdEvent method, "this" does not point to MainWindow. Instead, it is a nullpointer.
I am happy that I found this problem to be the cause of my program crashing all the time... I wanted to access class members from inside this method.
As a workaround, I can write MainWindow->member instead of just member. But still, this should not be necessary. Does anyone know the cause of this behavior?
Greetings,
Mirko
|
|
|
Goto Forum:
Current Time: Tue Apr 29 01:34:00 CEST 2025
Total time taken to generate the page: 0.00617 seconds
|