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(Evalu atedType);
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.
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(Evalu
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looking good so far.
A note about this statement...
// if possible I'de like to evaluate the charstring and use
// GetGraphicsExtention(Evalu atedType);
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(TBitma p);
2 : iExt := GetGraphicExtension(TGifIm age);
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
A note about this statement...
// if possible I'de like to evaluate the charstring and use
// GetGraphicsExtention(Evalu
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
1 : iExt := GetGraphicExtension(TBitma
2 : iExt := GetGraphicExtension(TGifIm
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
ASKER
TIssue.StillUnresolved('Pl ease Post More Fallow-up Comments');
run out of ideas :-(
ASKER
Thanks for trying kretzschmar,
I'm just cleaning up old questions.....
I'm just cleaning up old questions.....
>function that's ok too.
you could use a static tstringlist like
case myStaticStringList.IndexOf
1 : ...