Home > Back-end >  With one button to make a keyboard input respectively to them but have more than one Memo
With one button to make a keyboard input respectively to them but have more than one Memo

Time:09-16

For example, I click Memo1 cursor in Memo1 click button A Memo1 text + A
But Memo2.3.4.5?

CodePudding user response:

CB code:
 TMemo * activeMemo=NULL; 
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//a few Memo sharing this event handler, Edit also can share
Void __fastcall TForm1: : Memo1Enter (TObject * Sender)
{
ActiveMemo=dynamic_cast & lt; TMemo * & gt; (the Sender);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
If (activeMemo)
ActiveMemo - & gt; Lines - & gt; Add (" A ");
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

ActiveMemo=dynamic_cast & lt; TMemo * & gt; (the Sender);
If the Sender is a TEdit *, activeMemo is NULL,

CodePudding user response:

This post a truth with you
https://bbs.csdn.net/topics/392370743

CodePudding user response:

Strange strange, I can't post why show?
Already the third time,

CodePudding user response:

Method one: determine the current focus controls;
Method 2: MemoX gains focus when the event to change the input corresponding Memo,
Methods N, how to can have a lot of way,

CodePudding user response:

refer to 7th floor tanqth response:
method one: determine the current focus controls;
Method 2: MemoX gains focus when the event to change the input corresponding Memo,
Methods N, how to can have a lot of way to


Click on the button controls the focal point is button, not a Memo,

CodePudding user response:

Mean according to A, no matter A few input A memo?

CodePudding user response:

Set a variable, the corresponding number, save the Memo when click it a Memo, variable to hold the serial number of the Memo, so a corresponding number according to the set of a Memo, to specify the nemo assignment,
  • Related