Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Class method called by keyboard hook callback has an empty "this" pointer
Re: Class method called by keyboard hook callback has an empty "this" pointer [message #37337 is a reply to message #37336] |
Sun, 23 September 2012 20:27   |
|
You're welcome. In U++ it is fairly common to use a static variable in global function instead of global variables to prevent all kinds of troubles that global variables cause.
In your case, you can do something like
KeyBuddy2* MainWindow() {
static KeyBuddy2* ptr;
return ptr;
}
...
KeyBuddy2::KeyBuddy2()
{
MainWindow()=this;
CtrlLayout(*this, "Window title");
SetHook();
}
...
MainWindow()->ProcessKbdEvent(...)
There is even a macro for this: GLOBAL_VAR(type, name), for those that are too lazy to write (Such as me )
Honza
|
|
|
Goto Forum:
Current Time: Tue Apr 29 04:30:25 CEST 2025
Total time taken to generate the page: 0.00949 seconds
|