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 ![Go to previous message Go to previous message](theme/default/images/up.png) ![Go to next message Go to previous message](theme/default/images/down.png) |
|
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: Mon Jun 10 21:31:30 CEST 2024
Total time taken to generate the page: 0.01296 seconds
|