Board index » cppbuilder » 2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)


2004-02-18 07:42:21 AM
cppbuilder65
hi dear builders,
I got a problem to share a PopupMenu between 2 forms with their own
RichEdit (on each form 1 RichEdit)
I've tryed to share the PopupMenu with the below code...unsucessfully...
All I need, is to share the functionality of the PopupMenu so this:
WorkingRichEdit->Text = "test...";
should work for the currently active FormX->RichEditX->Text...
thanks for any help on this..
Oren
/*******************************************************/
// in..Form1
TForm1 *Form1;
TRichEdit* WorkingRichEdit; // global variable to hold the currently
RichEdit..
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner){}
void __fastcall TForm1::cmdSetTextClick(TObject *Sender) // this is the
PopupMenu->OnClick()
{
WorkingRichEdit->Text = "test...";
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Show();
}
void __fastcall TForm1::FormShow(TObject *Sender)
{
WorkingRichEdit = RichEdit_1;
}
/********************************************************/
// in Form2
TForm2 *Form2;
__fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) {}
void __fastcall TForm2::FormShow(TObject *Sender)
{
WorkingRichEdit = RichEdit_2;
}
 
 

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

"Oren (Halvani.de)" < XXXX@XXXXX.COM >wrote in message
Quote
I've tryed to share the PopupMenu with the below code...
unsucessfully... All I need, is to share the functionality of
the PopupMenu so this:

WorkingRichEdit->Text = "test...";

should work for the currently active FormX->RichEditX->Text...
Your description is too vague. You need to provide more details. What does
your actual code look like? Are you using the popup menu's PopupComponent
property at all? That is a pointer to the component that is currently
invoking the popup menu.
Gambit
 

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

Quote
Your description is too vague. You need to provide more details. What
does
your actual code look like? Are you using the popup menu's PopupComponent
property at all? That is a pointer to the component that is currently
invoking the popup menu.

Gambit
hi Remy...
well all I need is this...
when the PopupMenu gets clicked from Form2->RichEdit_2 it should paste the
text to Form2->RichEdit_2 NOT into Form1->RichEdit_1 (like it does now in my
code)
and of course when the PopupMenu gets clicked from Form1->RichEdit_1 it
should paste
it correctly into Form1->RichEdit_1 and NOT into: Form2->RichEdit_2
how can I handle it..? I tryed also with:
//in Header...
extern TRichEdit* WorkingRichEdit; // global variable accesable in all
Forms...
but it also doesn't work :-( can you help me...?
Oren
 

{smallsort}

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

"Oren (Halvani.de)" < XXXX@XXXXX.COM >wrote in message
Quote
well all I need is this...
I understand what you need. You did not explain what you *already have* in
place so far though.
Quote
when the PopupMenu gets clicked from Form2->RichEdit_2 it should paste the
text to Form2->RichEdit_2 NOT into Form1->RichEdit_1 (like it does now in
my
code)
Again, look at at the popup menu's PopupComponent property. It tells you
exactly which component is currently displaying the popup menu.
Quote
extern TRichEdit* WorkingRichEdit;
You do not need to go that approach.
Gambit
 

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

Quote
Again, look at at the popup menu's PopupComponent property. It tells you
exactly which component is currently displaying the popup menu.

>extern TRichEdit* WorkingRichEdit;

You do not need to go that approach.


Gambit
Remy, I set the PopupComponent property in both Forms/RichEdits for the
one PopupMenu that pastes the text...It still does paste the text into
RichEdit_1
NOT into RichEdit_2 :-(
Oren
can you explain me...what is wrong...?
 

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

oren wrote:
Quote
...I set the PopupComponent property in both Forms/RichEdits
???
In the Object inspector you should set the PopupMenu property
for both TRichEdits to i.e. PopupMenu1
Quote
for the
one PopupMenu that pastes the text...It still does paste the text into
RichEdit_1
NOT into RichEdit_2 :-(
PopupMenus are not know for pasting text. You have to do that
yourself.
You should first determine on which TRichEdit PopupMenu1 is used.
So you should have a look at PopupMenu1->PopupComponent when
one of the TMenuItems of that PopupMenu is clicked.
PopupMenu1->PopupComponent will be i.e. RichEdit1 or RichEdit2.
Hans.
 

Re:2 Form's with 2 RichEdit's and ONLY 1 PopupMenu (sharing problems...)

"oren" < XXXX@XXXXX.COM >wrote in message
Quote
I set the PopupComponent property
You *do not* set it yourself. It is set automatically for you when the menu
is displayed. Just use it when needed. For example:
void __fastcall TForm1::MenuItem1Click(TObject *Sender)
{
TRichEdit *re =
dynamic_cast<TRichEdit*>(PopupMenu1->PopupComponent);
if( re )
re->Text = "...";
}
Gambit