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 » Community » Newbie corner » Focus problem
Re: Focus problem [message #57823 is a reply to message #57817] Sun, 19 December 2021 15:37 Go to previous messageGo to previous message
Silvan is currently offline  Silvan
Messages: 56
Registered: December 2014
Location: Trento (IT)
Member
Lance wrote on Sun, 19 December 2021 14:31
1): Derive MyPanel from ImageCtrl to supply customized Paint and Key is the right thing to do, at the moment at least, unfortunately.

3): Overriding MyPanel::Close to delete this is unnecessary and considered bad practice (in this case at least).

By overriding MyPanel::Close in your way, you basically enforce that MyPanel object have be be allocated from heap. U++ doesn't prohibit you from allocating Ctrl derivatives from heap, but it's much more often we have its object contained and be allocated from stack(faster and less memory usage). Or it can even be global, static etc.

In your case, if you really want your object be allocated from heap, you can use U++ provided smart pointer One to manage it for you. See example in the next reply.


If I comment out MainWindows::Close (not MyPanel) than when I exit the program there is an exception at address .....
That appens with:

	(new MainWindow)->OpenMain();
	Ctrl::EventLoop();


With:

	MainWindow m;
	m.Run();


I can comment out Close whitout error on exiting.

[Updated on: Sun, 19 December 2021 15:47]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to output variable values with time stamp in windows application
Next Topic: Clang linker error: no such file or directory
Goto Forum:
  


Current Time: Sun Aug 24 11:03:39 CEST 2025

Total time taken to generate the page: 0.05182 seconds