Link to home
Start Free TrialLog in
Avatar of fibdev
fibdev

asked on

Error-Proof SavePictureDialog.Execute

Hello Experts,

I'm looking to write an fullproof OnExecute for a savepicturedialog box.  here is a model of what I'm looking for.  Solutions don't have to fallow the format exactly if someone has a better way,  That's part of the reason I'm here.  I want this to support all available image formats.

If SavePictureDialog.Execute then
begin
  // code to extract last three char of spd.filename.
  // a workable filterindex here is suitable.
  // if possible I'de like to evaluate the charstring and use
  // GetGraphicsExtention(EvaluatedType);
end;

It's late and I'm really tired so excuse me if I left something out or did something wrong in my example.  What I'm shooting for is to avoid using a long series of if statements to save diferent filetypes.  If there is a way to use a case statement and call a seperate function that's ok too.  I think case statements are cleaner (If only they supported stringtypes.)  Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>If there is a way to use a case statement and call a seperate
>function that's ok too.  

you could use a static tstringlist like

case myStaticStringList.IndexOf(MyExt) of
  1 : ...
Avatar of fibdev
fibdev

ASKER

Looking good so far.

A note about this statement...

  // if possible I'de like to evaluate the charstring and use
  // GetGraphicsExtention(EvaluatedType);

I know it's probably something I'm doing incorrectly, but I've had bugs by using filter and filterindex.  I like the idea of the string list to make absolutely sure the filetype is correct.

procedure DoSave();
 var iExt : String;
begin
  case myStaticStringList.IndexOf(MyExt) of
    1 : iExt := GetGraphicExtension(TBitmap);
    2 : iExt := GetGraphicExtension(TGifImage);
    3 : ...
  end;
end;

I like this, but there has to be a way to achive this with less code.  If we can come up with a solid save procedure for all image formats then I will give points to all serious contributers and maybe, we can come up with something really good that ppl can use.  Thanks   :)

Gabe
Avatar of fibdev

ASKER

TIssue.StillUnresolved('Please Post More Fallow-up Comments');
run out of ideas :-(
Avatar of fibdev

ASKER

Thanks for trying kretzschmar,

I'm just cleaning up old questions.....