SaveDialog filters

Hi,

it's me, again:) This time with TSave(Picture)Dialog questions

For instance i want a graphic file conversion. I have a picture loaded into a TImage,
and there is a TSavePictureDialog

[b]q#1:[/b]
I don't get why does the All(*.jpg;*....) line appear in a SavePictureDialog filters.
It's kinda stupid, isn't it? How can i save a file in more than one filetype??
Anyway, it's no problem...i can recreate the filters...
So I get the filters from GraphicFilter(TGraphic),
but i don't want the All(*.jpg;*.bmp...) line appear there.
Yeah and other times at OpenPicturedialog i want to change the "All(...)" to "Supported graphic files".
How can i do this other than using string handling routines (like Pos, Copy),
Because that's _not_ a nice solution.

[b]q#2:[/b]
if i want to cut out the Icons line is there a better solution than:
a) using string handling routines (again!) or
b) unregistering the TIcons before Graphicfilter and then re-registering it

[b]q#3:[/b]
and here's the saving:

[blue]if SaveDialog1.Execute then
Image1.Picture.SaveTofile(SaveDialog1.FileName);[/blue]

But here SaveDialog1.FileName has no extension
How will i know what filetype was chosen?
The only thing i know is that FilterIndex changes.
I go crazy if i have to use string handling routines again!!


that's all for this time;-)
Can anyone help me, please?

Thanks in advance,
malacka

Comments

  • : Hi,
    :
    : it's me, again:) This time with TSave(Picture)Dialog questions
    :
    : For instance i want a graphic file conversion. I have a picture loaded into a TImage,
    : and there is a TSavePictureDialog
    :
    : [b]q#1:[/b]
    : I don't get why does the All(*.jpg;*....) line appear in a SavePictureDialog filters.
    : It's kinda stupid, isn't it? How can i save a file in more than one filetype??
    : Anyway, it's no problem...i can recreate the filters...
    : So I get the filters from GraphicFilter(TGraphic),
    : but i don't want the All(*.jpg;*.bmp...) line appear there.
    : Yeah and other times at OpenPicturedialog i want to change the "All(...)" to "Supported graphic files".
    : How can i do this other than using string handling routines (like Pos, Copy),
    : Because that's _not_ a nice solution.
    :
    : [b]q#2:[/b]
    : if i want to cut out the Icons line is there a better solution than:
    : a) using string handling routines (again!) or
    : b) unregistering the TIcons before Graphicfilter and then re-registering it
    :
    : [b]q#3:[/b]
    : and here's the saving:
    :
    : [blue]if SaveDialog1.Execute then
    : Image1.Picture.SaveTofile(SaveDialog1.FileName);[/blue]
    :
    : But here SaveDialog1.FileName has no extension
    : How will i know what filetype was chosen?
    : The only thing i know is that FilterIndex changes.
    : I go crazy if i have to use string handling routines again!!
    :
    :
    : that's all for this time;-)
    : Can anyone help me, please?
    :
    : Thanks in advance,
    : malacka
    :
    :
    1: Here is a simple code to change the word "All" into "Supported Types", or any other string for that matter.
    [code]
    SavePictureDialog1.Filter := StringReplace(SavePictureDialog1.Filter,
    'All', 'Supported Types', []);
    [/code]

    2: I haven't found a better solution, except perhaps the solution presented below for question 3. This can be used two ways:
    a: get the string for the icons filter, and then use StringReplace() to remove it (replace it by an empty string)
    b: add together all the filters you want, possibly based on an array of integer.

    3: Here is a link to a simple function, which allows you to copy a substring based on the index of that string:
    http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=4&MsgID=188161
    You can use that and the StringReplace() function to get the filter string (ie. *.bmp for a bitmap) and change the asterix (*) into the filename and path. The index parameter needs to be calculated based on the FilterIndex, but that shouldn't be too difficult. I foresee one slight problem, if the user tries to save the image as a "Supported Types" (ie. FilterIndex 0).
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion