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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select objects within a selection rectangle

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
I need to be able to select objects within a selection rectangle. I have the rectangle, which is drawn on the canvas, but when i click and drag the rectangle, I need the things inside of it to be selected. Does anybody know how to do this?!?

Thanks a whole lot,
Cyprus
 
What about looping through the controls collection of the form and see which controls fit within your rect.
 
Hey there we go. wow, I never even thought about that. hum... What about multiselect? see, I need to select a few different images that are on the form. I've never tried to do multiselect. How?

Thanks! (and thanks for the tip, I'll do that) Cyprus
 
something like this:

void __fastcall TForm1::Button1Click(TObject *Sender) {
TControl *c;
for( int i=0; i<this->ControlCount; i++ ) {
c = this->Controls;
Application->MessageBoxA( c->Name.c_str(), &quot;debug&quot;, 0 );
// check the values of c->Top, c->Left, c->Width, c->Height
// to find out whether your controls are inside the rect.
}
}
 
Uhhh select ...

Run-time selecting of the controls could be a problem. Maybe the click, mouseover events of the form are of any use. You could use the tag property of an image to hold the select-status.
But how would you let the user know which images are selected ?
 
I already got the selection thing working. it'll select things within the box. I was just wondering about multiselect. I want to multiselect some images. Possible? If not, i can work around it.

Thanks Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top