Re: OpenPictureDialog Problems



<cybatech@xxxxxxxxxxxxx> wrote in message
news:ag39e15gau8ugi4ivoa7rsuj551a2cs0mt@xxxxxxxxxx
>
> This is the code I am trying. It works fine with Tshape!

That's odd, does the TShape your version of Delphi have an Image
property?

What Delphi version are you using?

Is the AV occurring at the line
> manyshape1.Image := Bitmap;?

I wonder if the problem is that ManyShape1 may not be assigned.

And how and where is it declared?

ManyShape1 sounds as though it is the default (and non-meaningful)
name for a tManyShape component that you have dropped on your form.

I would declare a tManyShape variable named something like
fCurrentShape as a private form variable.

And than add the line fCurrentShape := NewShape; at the end of each of
the OnClick handlers for the buttons that create the various shapes.

In the procedure MouseDownOnShape event handler,
add the line
fCurrentShape := Sender as tManyShape;
as follows:
begin
if Sender is TManyShape then
begin
fCurrentShape := Sender as tManyShape;
FCurrentShape.Invalidate;
if ssRight in Shift then
(Sender as TManyShape).Tag := RIGHT_BUTTON_DOWN
// etc


Yhis will mean that fCurrentShape is assigned to the value of the last
shape created or clicked on. But fCurrentShape will be nil before you
add your first shape to the form.

So, in your BitBtn1Click method (non-meaninful name 8-) ) change the
line

manyshape1.Image := Bitmap; to something like

if Assigned (fCurrentShape) then
fCurrentShape.Image := Bitmap;

After looking at the source for tManyShape, I cannot see that setting
the image will have any effect since as far as I can tell, the private
image variable is never used in the Paint method.

I have my own rather similar class, derived from TShape but it does
not have an Image property and cannot load shapes as tBitmaps. (but it
can save and load shapes)



--
Henry Bartlett
Delphi Links Page:
( http://www.hotkey.net.au/~hambar/habit/delflink.htm )





.


Quantcast