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
Class method called by keyboard hook callback has an empty "this" pointer [message #37334] Sun, 23 September 2012 11:31 Go to previous message
Mircode is currently offline  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:

KeyBuddy2* MainWindow;


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
 
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 Apr 29 13:03:58 CEST 2024

Total time taken to generate the page: 0.03546 seconds