Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I don't know why the program doesn't work as it should.
I have two edit elements on the form: edit1 and edit2.
I want to mark the always active component in yellow.
Edit1 is active after the program has started. I click edit2 and I want edit1 in the onExit action to check the value in edit1.
I show a messagebox with two Yes / No buttons and the message "The value seems wrong. Do you want to correct it?"
If the user clicks on Yes (i.e. wants to correct the value), I stay on edit1 and edit2 (despite clicking) stays in the standard color.
If the user clicks on No (i.e. NOT wanting to correct the value) then he should go to edit2 and edit2 should turn yellow and edit1 to the standard color.
Unfortunately, after clicking edit2 and selecting the NO button, edit2 does not change the color, although it is active because when I start to click something on the keyboard, I write in edit2.
My code looks like this.
C++
void __fastcall TForml::EditlExit (TObject *Sender)
{
	Editi->Color=OryginalColor; 
	String info = "Value in Edit1 seems to be wrong. Are You want to change it?";
	int iQuestion = MessageBox (Handle, info.c_str(), L"Warning", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON1); 
	if (i Question == ID YES) {
		Edit1->SetFocus():
	}	
	else if (i question == ID_NO) {
		Edit1->Color = OryginalColor;
	}
}

void __fastcall TForml::Edit1Enter (Tobject *Sender)
{
	OryginalColor = Edit1->Color;
	Edit1->Color = clYellow;
}

void __fastcall TForml::Edit2Enter (Tobject *Sender)
{
	OryginalColor = Edit2->Color;
	Edit2->Color = clYellow;
}

void __fastcall TForml::Edit1Exit (Tobject *Sender)
{
	Edit2->Color = OryginalColor;
}


What I have tried:

I tried to detect which component was clicked with the MouseDown action but it also did not work.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900