>>procedure TCamForm.PicButtonClick(Sender: TObject);
>>begin
>>  if (picselect = pic1.Tag) and (FIMG1.Visible = true) then exit;
>>  Picclick(Pic1.Tag);
>>end;
>>// using each btn tag in subproc picclick(tag)
>>// there is probably a way using that nice idea, but somehow I feel I have
>>done that beat already.

>... assuming 'pic1' is a SpeedButton...
>procedure TCamForm.PicButtonClick(Sender: TObject);
>var theButtonUserClicked : TSpeedButton;
>begin
>  theButtonUserClicked := TSpeedButton( Sender );
>  if (picselect = theButtonUserClicked.Tag) and (FIMG1.Visible = true) then
exit;
>  Picclick(theButtonUserClicked.Tag);
>end;

>.. but I don't understand what purpose 'picselect' would serve -- it
*sounds*
>like it represents the button that has just been clicked, which is
redundant
>because we already know it's 'Sender', so the 'picselect =
>theButtonUserClicked.Tag' condition should be removed.
>What does FIMG1 represent? Is there a relationship between it and pic1?
Does pic2 have a FIMG2?
>Show us lots of code and I'm sure we could come up with a better solution,
but I'm going to stop guessing now.

My best guestimate of his meaning is:
FIMG1 is the image that is showing the 'current' picture indicated by a
number held
in the global picselect.  There is code in the PicClick() procedure that
accepts a number
and sets PicSelect to that number whilst 'loading' FIMG1 with the relevent
data. It is
undesirable to have the same data reloaded when someone clicks a second time
on
the speedbutton.

My solution: Store the current image number in the Tag property of the FIMG1
component

procedure TCamForm.PicButtonClick(Sender: TObject);
begin
    if Sender is TSpeedButton then with Sender as TSpeedbutton do  if
Tag<>FIMG1.Tag then PicClick(Tag);
end;

PicClick() will need to set the FIMG1.Tag to match the parameter passed
in...

Personally I would rewrite PicClick as "procedure PicClick(IMAGE :TIMage;
Index :Integer);" and do the code in there.

then the OnClick becomes just
begin
   PicClick(FIMG1,TSpeedButton(Sender).Tag);
end;

with PicClick being something like
begin
    if IMAGE.Tag<>Index then begin
        IMAGE.Tag := Index;
        IMAGE.LoadFromFile('Image'+IntToStr(Index)+'.bmp'); // Only as an
example of doing something with the index
    end;
end;

No nasty globals - and centralised code for the PicClick that will let you
redirect to different Image components.

Just my .05c worth... All based on painful assumptions for lack of
sufficient code to make a diagnosis.

--
Aaron@home


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to