Home How to get the focused/selected object in delphi?
Reply: 0

How to get the focused/selected object in delphi?

user935 Published in May 25, 2018, 9:06 am

I have a PageControl object with several pages in separate tabs. Each tab contains a lot of objects such as TEdits and TComboBoxes. Lets say I'm in "Tab A" entering text in a TEdit and then the software change tab to "Tab B" and then back to "Tab A". Then the TEdit is no longer selected so I need to select it again to continue writing.

Now to my question: How can I save/get/store the selected object before change of tab so that I can return to the same object when back to the previous tab?


2018-02-15 Update:

Thanks @ExDev!

Screen.ActiveControl was what I where looking for! I solved it like this:

  FocusObject : TWinControl;
  // Save selected object  
  FocusObject:= Screen.ActiveControl;

  // Restore selected object  
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.243534 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO