Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i recognize & obtain a access to certain

Status
Not open for further replies.

MechanicalBoy

Technical User
Aug 11, 2002
11
PL
Hi ALL.
Ok I'd better begin from the first :).
I create an array of panels using the following function:

void __fastcall TForm1::butt1Click(TObject *Sender)
{
for(int i=0 ; i < 5 ; i++)
{
array = new TPalel(this);
array->setBounds(40*i,40*i,50,30);
array->Tag = i;
array->Caption = AnsiString(&quot;New panel&quot;);
Form1->InsertControl(array);
array->Visible = true;
array->OnMouseMove = __EVENT;
}
}
// TPanel array[5]; is declared as a global

Each panel call the same (OnMouseMove) handler. __EVENT declaration I placed in Unit1.h as follows:

class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *butt1;
void __fastcall butt1Click(TObject *Sender);

private: // User declarations

void __fastcall __EVENT(TObject *Sender, TShiftState Shift,
int X, int Y);


public: // User declarations
__fastcall TForm1(TComponent* Owner);
};

In Unit1.cpp I was trying to write __EVENT definition. But i don't know how can i recognize which of panels call this handler if i have them 5. i know that each of them has uniqe Tag number and i would make use of this fact. Actually i don't even know how to obatain an access to methods and properties of object that calls handler __EVENT.

i tryid to get an address of the method (void Hide(); for example) like this:

void __fastcall TForm1::mevMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
void (*pointer)(void);
pointer = Sender->MethodAddress(&quot;Hide&quot;);

...
}
I realized tha Hide returns void type and is called without parametrs ...

but without success.

Can anybody help me ?

THANKS IN ADVANCE
MechanicalBoy
 
What is __EVENT first off? And is it absolutely necessary? I would like to see the definition for that if you could.


and second, you might be able to do something like:

TPanel *pnl = dynamic_cast<TRzLabel *>(Sender);
pnl->Hide();

instead of:

void (*pointer)(void);
pointer = Sender->MethodAddress(&quot;Hide&quot;);


Not every panel has an individual tag number, you have to assign the tag numers manually... which it looks like you did. so use the same code from above except do a
int x = pnl->Tag;

could you put up your definition of your array? From the looks of the code I dont think my suggestions will work with the way you assigned your panels to the array. We'll see... prior to your answering my questions I'll show you the way I did the exact same thing (or at least almost the exact same thing... i think) which is why im waiting for you so i dont put up a bunch of crap code that you dont need that wold hurt you worse than you already are.

Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top