Re: OpenPictureDialog Problems



<cybatech@xxxxxxxxxxxxx> wrote in message
news:6cu0e1hd0q1nkt2ldj0d62ej1dt7uo404h@xxxxxxxxxx

> Can some please tell me why this won't work?
>
> procedure TForm1.Button1Click(Sender: TObject);
> var OpenPicDlg : TOpenPictureDialog;
> Bitmap: TBitmap;
> NewShape : TManyShape;
> begin
> Bitmap := TBitmap.Create;
> OpenPicDlg := TOpenPictureDialog.Create(Self);
> if OpenPicDlg.Execute then
> begin
> bitmap.LoadFromFile(OpenPicDlg.FileName);
> Newshape.Image :=Bitmap;
> end;
> OpenPicDlg.Free;
> end;

One easy guess: no NewShape:=TManyShape.Create anywhere.

Did you step through this code and see exactly where the
error occurs? For that matter, what _is_ the error message,
and why aren't you telling us?

Does it work when you assign the loaded bitmap to a TImage
component on your form instead of to NewShape?

It's a good habit to _always_ start a try-finally after a
Create and Free in the finally clause.

Groetjes,
Maarten Wiltink


.


Quantcast