Solved

Error-Proof SavePictureDialog.Execute

Posted on 2003-10-27
6
552 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 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