Board index » cppbuilder » ok

ok


2003-07-14 07:02:05 AM
cppbuilder110
void __fastcall TForm1::New(int w, int h)
{
Graphics::TBitmap *pBitmapTemp = new Graphics::TBitmap();
TCanvas *pMapCanvas;
pBitmapTemp->Height = h*32;
pBitmapTemp->Width = w*32;
Image->Enabled = true;
Image->Height = h*32;
/*also tried using Image->Picture->Bitmap->Height ... but it is resized
just at the dimension of default size*/
Image->Width = w*32; pCanvas = pBitmapTemp->Canvas;
pCanvas->Pen->Color = clRed;
pCanvas->Pen->Color = clBlack;
BitBlt(Images->Canvas->Handle, 0, 0, w*32, h*32, pCanvas->Handle, 0, 0,
SRCCOPY);
}
 
 

Re:ok

Watching better at the second time i click on New button the TImage just
resizes, but is the image inside isn't redrawed! it show only the part
contained in the last sized of the TImage object.
How can i reupdate this particular case of painting?
 

Re:ok

b wrote:
Quote
Watching better at the second time i click on New button the TImage
just resizes, but is the image inside isn't redrawed! it show only
the part contained in the last sized of the TImage object.
This was stated in the post that I linked to, but in case you missed it: The
solution is to resize the Image's Bitmap as well as resizing the Image...
Image->Width = w*32;
Image->Height = h*32;
Image->Picture->Bitmap->Width = Image->Width;
Image->Picture->Bitmap->Height = Image->Height;
Regards,
--
Damon (TeamB)
BCBCAQ - bcbcaq.bytamin-c.com
 

{smallsort}

Re:ok

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
Graphics::TBitmap *pBitmapTemp = new Graphics::TBitmap();
Just a side comment - you have memory and resource leaks with that code.
You are deynamically allocating a TBitmap but you are never freeing it when
you are done with that. You are leaking the TBitmap memory as well as the
underlying bitmap resources contained inside of it.
Gambit
 

Re:ok

How i just told you, i tried to use that, but if i set the default values of
size of TImage in the Form, the calling picture->bitmap->... resize the
TImage just at the default values, and it doesn't permit to enlarge again.
 

Re:ok

Ok so how i must do to free the memory?
 

Re:ok

"b" <borland.public.cppbuilder.vcl.components.using>wrote in message
Quote
Ok so how i must do to free the memory?
The same way you would free any other dynamically-allocated memory via
'new' - use 'delete':
void __fastcall TForm1::New(int w, int h)
{
Graphics::TBitmap *pBitmapTemp = new Graphics::TBitmap;
//...
delete pBitmapTemp;
}
Gambit
 

Re:ok

ok
 

Re:ok

The following codes works fine:
procedure TMainForm.ws_deleteClick(Sender: TObject);
var
str:string;
begin
try
if application.MessageBox('confirm to delete?','Alert',MB_YESNO)=ID_YES
then
begin
str:=
tf_employee(activemdichild).dx1.DataSource.DataSet.Fields[1].AsString;
with dm.emp_sql do
begin
close;
sql.Clear;
sql.Add('delete from employees');
sql.Add('where job_id=:p');
parameters.ParamByName('p').Value :=str;
execsql;
end;
But still THANK YOU VERY MUCH.
"Bill Todd" < XXXX@XXXXX.COM >写入消息新闻:444d8483$ XXXX@XXXXX.COM ...
Quote
DarkAngel wrote:

>
>Hi, experts:
>
>I use the following codes to delete a records from dbgrid:
>
>adoquery1.Close;
>adoquery1.SQL.Clear;
>adoquery1.SQL.Add('delete from employees where job_id=:p');
>adoquery1.Parameters.ParamByName('p').Value
>:=dbgrid1.DataSource.DataSet.Fields[1].AsString;

I suspect you want the value from the first field in the dataset which
would be dbgrid1.DataSource.DataSet.Fields[0].AsString.

>adoquery1.ExecSQL;
>adoquery1.Open;

You should not call both the ExecSQL and the Open methods. Never call
Open for any SQL statement except SELECT. Use ExecSQL for all SQL
statements that do not return a result set.

>
>and I got an error saying 'List index out of bounds'.

Probably because you used Fields[1] instead of Fields[0].


--
Bill Todd (TeamB)
 

Re:ok

Yokummmmmmmmm