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++ Widgets - General questions or Mixed problems » Is it possible to get Ctrl name during runtime (or similar)?
Is it possible to get Ctrl name during runtime (or similar)? [message #13103] Tue, 11 December 2007 10:45 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Env: winxp, u++ 2007.1

Hi,

Suppose the following:
I have a modal dialog with 2 EditStrings (with names edField1 and edField2) and one EditInt (with name edField3) and I want to do different things if the focus is on EditStrings or in the EditInt.

I can diferentiate the EditInt from EditString with the following code:

EditInt *pEditInt=NULL;
EditString *pEditStr=NULL;

pEditStr=dynamic_cast<EditString *>(GetFocusCtrl());
if(pEditStr) //It is one of the edit strings
{
...
}

pEditInt=dynamic_cast<EditInt*>(GetFocusCtrl());
if(pEditInt) //It is the EditInt
{
...
}

How can I know if the focus is in the edField1 or in edField2?

Many thanks

Alex
Re: Is it possible to get Ctrl name during runtime (or similar)? [message #13104 is a reply to message #13103] Tue, 11 December 2007 11:14 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Is there any good reason why you can't just compare addresses?
Ctrl * focus = GetFocusCtrl();
if (focus == &edField1) {
// First EditString
}
else if (focus == &edField2) {
// Second EditString
}
else if (focus == &edField3) {
// EditInt
}
Or:
if (edfield1.HasFocus()) { // etc.

which is exactly the same.
Re: Is it possible to get Ctrl name during runtime (or similar)? [message #13105 is a reply to message #13104] Tue, 11 December 2007 11:39 Go to previous message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Embarassed

Thank you.

Alex
Previous Topic: PromptOK - little error in textselection
Next Topic: failure to use SOCKET and an exception question
Goto Forum:
  


Current Time: Sun May 05 09:40:39 CEST 2024

Total time taken to generate the page: 0.02516 seconds