Re: OpenPictureDialog Problems
- From: "Henry Bartlett" <hambar@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jul 2005 09:40:17 +1000
<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 )
.
- Follow-Ups:
- Re: OpenPictureDialog Problems
- From: alanglloyd@xxxxxxx
- Re: OpenPictureDialog Problems
- From: Henry Bartlett
- Re: OpenPictureDialog Problems
- References:
- OpenPictureDialog Problems
- From: cybatech
- Re: OpenPictureDialog Problems
- From: Maarten Wiltink
- Re: OpenPictureDialog Problems
- From: cybatech
- Re: OpenPictureDialog Problems
- From: Henry Bartlett
- Re: OpenPictureDialog Problems
- From: Rob Kennedy
- Re: OpenPictureDialog Problems
- From: Henry Bartlett
- Re: OpenPictureDialog Problems
- From: cybatech
- Re: OpenPictureDialog Problems
- From: Henry Bartlett
- Re: OpenPictureDialog Problems
- From: cybatech
- OpenPictureDialog Problems
- Prev by Date: Re: Beginner Question! API DOC?
- Next by Date: Re: OpenPictureDialog Problems
- Previous by thread: Re: OpenPictureDialog Problems
- Next by thread: Re: OpenPictureDialog Problems
- Index(es):