Solved

Error-Proof SavePictureDialog.Execute

Posted on 2003-10-27
6
547 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
Comment Utility
?

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
Comment Utility
>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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Author Comment

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

Expert Comment

by:kretzschmar
Comment Utility
run out of ideas :-(
0
 
LVL 3

Author Comment

by:fibdev
Comment Utility
Thanks for trying kretzschmar,

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now