Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Change filename in TSaveDialog

Hi

How do I change the visible filename in a savedialog, the reason to do this is that if you have two filters and select a new one should the filename change its extension to the selected filter (like MS Office).
This also happends when the user click ok but not visible to the user.
0
koger
Asked:
koger
  • 4
  • 2
  • 2
  • +6
1 Solution
 
ZifNabCommented:
Hi,

Look at OnSelectionChange.

Occurs when the file types displayed in the dialog are changed.

property OnSelectionChange: TNotifyEvent;

Description

The OnTypeChange event occurs when the user selects a new filter from the Files of Type list box at the bottom of the dialog.

Regards, Zif
0
 
kogerAuthor Commented:
Ok I know this but, how to actually change the visible filename
0
 
FreakyCommented:
Don't understand what's your problem.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
kretzschmarCommented:
hi koger,

did you adjusted the filterproperty like
Textfiles|*.txt|Docfiles|*.doc
?

meikl
0
 
kogerAuthor Commented:
Year I know how to use the filter allright :-)

Try this start the TSaveDialog enter a filename change the filter then the filename will have a the selected extension in MS Office, then try the same think in Delphi the filename doesn't change.
0
 
JaymolCommented:
I would have thought this wasn't a problem.  If you just type a filename, it doesn't show the extension anyway.  If you type the extension yourself, then it's your own fault for being daft!  The only way to get the dialog to perform in this way is to create your own.  

John.
0
 
kretzschmarCommented:
? well, then i would do what zif already suggested, use the event OnTypeChange to append the new suffix, if filename is not empty
0
 
JaymolCommented:
That will work.
0
 
kogerAuthor Commented:
AFAIK the tsavedialog.filename gets updated fine. I just wanted to make it foolproof, but no can do or so it seeems.
0
 
sburckCommented:
Unfortunately, from the Help file:

"Programmatic changes to FileName have no effect while the dialog is active."

To do this while the dialog box is active (a live change, like in office), you'll have to modify the dialog source itself, or use a third party dialog box.
0
 
TheNeilCommented:
Or you could write your own using the components on the Win 3.1 component palette

The Neil
0
 
ptmcompCommented:
Could you use another OpenDialog (an ActiveX)? There was also the possibility of an window hook of the dialog...
0
 
cAkkCommented:
First:
you can get dialog's handle at savedialog.OnShow
using savedialog.handle.

then:

 hParent:=getparent(savedialog.handle);
  hEdit:= FindWindowEx(hParent, 0, 'Edit',nil);

now, hEdit is the Editbox's handle.

you can set it's text by using the handle.
0
 
kogerAuthor Commented:
And for all you others you can change the text with

SendMessage(hEdit,WM_SETTEXT,0,integer(PChar('text')));
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
  • 2
  • +6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now