Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile (Such as me Wink )

Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [bug report] EditField::StdBar Undo menu not checked and EditField::RightDown is reentrant
Next Topic: ZMQ library in U++ (inproc, IPC, TCP and multicast)
Goto Forum:
  


Current Time: Mon Jun 10 21:31:30 CEST 2024

Total time taken to generate the page: 0.01296 seconds