BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

vector of a custom class and mouse events

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder
View previous topic :: View next topic  
Author Message
tsamisa@gmail.com
Guest





PostPosted: Tue Mar 20, 2007 4:36 pm    Post subject: vector of a custom class and mouse events Reply with quote



I created a class that contains a TImage component and with an event
handler for mouse up . I declared a vector in my main program (form)
of my classe's type. When i create the images everything works fine.
If i press a mouse button (the event handler in my class is for
mouseup) i get in to the desired function but the properties of the
class are not correct.
The class:
class pdtls
{

private: // User declarations
bool pdcreated;

public: // User declarations
int pid,originalleft,originaltop,myindex;
TImage *pdimg;
AnsiString imgdata;
__fastcall pdtls();
__fastcall ~pdtls();
void __fastcall init(TScrollBox* owner,TColor clr,int l,int t,
AnsiString data,int orgnllft,int
orgnltp,
int imgtype);
void __fastcall init(TForm* owner,TColor clr,int l,int t,
AnsiString data,int orgnllft,int
orgnltp,int imgtype);
void __fastcall testfn(TObject *Sender,TShiftState Shift, int
X, int Y);
void __fastcall checkfordelete(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall deletethis();
void __fastcall setlefttop(int lft,int tp);
void __fastcall setmyindex(int indx);

};

in the init functions i have the following lines:
pdimg=new TImage(owner); //The owner is a scrollbox of the main form
pdimg->Parent=owner;
pdimg->ShowHint=true;
this->pdimg->OnMouseUp=checkfordelete;

in the function checkfordelete i just have this line:
Form1->waypointindex=myindex;
where waypointindex is an integer in my main form

the declaration in my main form is
vector <pdtls> pds;
vector <pdtls>::iterator p=pds.begin();

int crrvctr=pds.size();
pds.push_back(pdtls());
pds[crrvctr].init(Form1->ScrollBox1,clRed,X-5,Y-5,Edit4->Text,X,Y,0);
pds[crrvctr].setmyindex(crrvctr);

when i move my mouse over te images the hint display (ahint box that
displays some data) is correct on all the images.

when i click the last created image myindex, originaltop, pid etc are
correct. When i click on the first created image or any other except
the last i get random values for the same values.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.