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!

it's me and my TImage again

Status
Not open for further replies.

MechanicalBoy

Technical User
Aug 11, 2002
11
PL
Hi All !
I have a problem with my image (img). I create it when i click on (butt1) :

TImage *img;
.
.
.

void __fastcall TForm1::butt1Click(TObject *Sender)
{
if((img = new TImage(this))!=NULL)
{
img->SetBounds(0,0,300,10);
img->Canvas->Brush->Color = clGreen;
img->Canvas->FillRect(Rect(0,0,img->Width,img->Height));
img->InsertControl(img);
img->Visible = true;
}
}

when this function terminates everything is OK. I can see green rectangle on the form [resolution (300x10)]

But when i change it's dimensions (by clicking on butt2):

void __fastcall TForm1::butt2Click(TObject *Sender)
{
img->Width += 100;
img->Height += 100;
img->Canvas->Brush->Color = clGreen;
img->Canvas->FillRect(Rect(0,0,img->Width,img->Height));
img->Refresh();
}

I obtain a green rectangle with resolution (300x10) again.
Why it's dimensions are not changed.

Furthermore i know that img is much larger becouse when i replace

img->Width += 100;
img->Height += 100;

by

img->Width += 1000;
img->Height += 1000;

i see automaticly created form scrollbars and it distinctly points that the image is indeed resized.

I think that problem concerns img->Canvas->FillRect() method.

Thanks in advance for any help !

RafalP
 
I am not sure if using the image canvas is a good idea.

You might like to try using:

img->Picture->LoadFromFile("blue.bmp"); // You will need create a bmp file.

img->AutoSize=true;

also, img->InsertControl(img) MUST BE Form1->InsertControl(img);

Would TShape work better for your program?

Take a look at SetBounds in the C++ builder help files. It say ... Height and Width may not be set...

Hope this helps. Rod
 
Thanks for your help arcbkc.
I decided to use TShape in my program. Actually my application is similar to Simulink that works with Matlab.
It is a kind of interface for steering certain machine
Sorry for img->InsertControl(img); :)
Originally i used this->InsertControl(img); & i tryed to modify code to make it more formal and i discredited myself :)))))

Best regards
RafalP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top