Solved

Error-Proof SavePictureDialog.Execute

Posted on 2003-10-27
6
557 Views
Last Modified: 2008-01-16
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.
0
Comment
Question by:fibdev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 9632136
?

SavePictureDialog.Filter := GraphicFilter(TGraphic);
If SavePictureDialog.Execute then
begin
  // code to extract last three char of spd.filename.
  ext := ExtractFileExt(savepocturedialog.filename);
  // a workable filterindex here is suitable.
  ?? see above firstline
  // if possible I'de like to evaluate the charstring and use
  // GetGraphicsExtention(EvaluatedType);
  Ext2 := GraphicExtension(YourGraphicClass);  //for ex TBitmap

end;

not sure for what you after

meikl ;-)

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9632145
>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 : ...
0
 
LVL 3

Author Comment

by:fibdev
ID: 9638409
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:fibdev
ID: 9810575
TIssue.StillUnresolved('Please Post More Fallow-up Comments');
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9810656
run out of ideas :-(
0
 
LVL 3

Author Comment

by:fibdev
ID: 10090598
Thanks for trying kretzschmar,

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why can't I create any project with my delphi EXE file? 6 57
Create a path if not exists 7 124
Wincontrol not (correctly) drawn 15 57
Browsing a TTreeView in Delphi 5 46
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question