Solved

Error-Proof SavePictureDialog.Execute

Posted on 2003-10-27
6
554 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
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!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 90
oracle global variables 4 79
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 75
Delphi problems to abort a printjob 9 34
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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