Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Save dialog - update file extension in dialog on type change (https://www.delphipraxis.net/161589-save-dialog-update-file-extension-dialog-type-change.html)

WojTec 11. Jul 2011 12:32

Delphi-Version: 2010

Save dialog - update file extension in dialog on type change
 
How can I update file name in dialog on type change?

Delphi-Quellcode:
procedure OnTypeChange(...);
// Set DefaultExt here...
// Update file name:
SaveDialog.FileName := ChangeFileExt(SaveDialog.FileName, SaveDialog.DefaultExt);
But looks to not occur when type combobox is changed.

How can do it?

DeddyH 11. Jul 2011 14:40

AW: Save dialog - update file extension in dialog on type change
 
Do you mean the content of the edit on the dialog form? IIRC this will not get updated automatically when the filename changes. To see if your changes are taking place you will have to display a messagebox or something like that (for testing only, of course).

Sailor 11. Jul 2011 19:13

AW: Save dialog - update file extension in dialog on type change
 
The following code in the OnTypeChange event handler
will do it:

WITH SaveDialog
DO BEGIN
SendMessage(GetParent(Handle),cdm_SetControlText,E dt1,
Integer(PChar(ExtractFileName(file_id))));
SetWindowText(GetParent(Handle),PChar(Title))
END

WojTec 12. Jul 2011 08:04

Re: AW: Save dialog - update file extension in dialog on type change
 
Zitat:

Zitat von Sailor (Beitrag 1111201)
The following code in the OnTypeChange event handler
will do it:

WITH SaveDialog
DO BEGIN
SendMessage(GetParent(Handle),cdm_SetControlText,E dt1,
Integer(PChar(ExtractFileName(file_id))));
SetWindowText(GetParent(Handle),PChar(Title))
END

@Sailor, what is "Edt1", "file_id" and "Title"?

DeddyH 12. Jul 2011 09:25

AW: Save dialog - update file extension in dialog on type change
 
I just found this article, hope it helps.

WojTec 12. Jul 2011 10:40

Re: Save dialog - update file extension in dialog on type change
 
Thanks :) But it don't working on Vista-based - on XP is ok, but on newer not. Why I'm not surprised? Ah. Do you know some trick to do it working on Vista/7 too?

DeddyH 12. Jul 2011 10:51

AW: Save dialog - update file extension in dialog on type change
 
Taken from the MSDN:
Zitat:

[Starting with Windows Vista, the Open and Save As common dialog boxes have been superseded by the Common Item Dialog. We recommended that you use the Common Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
This leads to this article: http://msdn.microsoft.com/en-us/library/bb776913

A quick google search brought up this piece of code, maybe it can be useful: http://www.mail-archive.com/forum@ps.../msg17009.html

WojTec 12. Jul 2011 12:49

Re: Save dialog - update file extension in dialog on type change
 
So, there is TSaveDialog. How to update edit inside on Vista-based Windowses?

DeddyH 12. Jul 2011 12:52

AW: Save dialog - update file extension in dialog on type change
 
I don' t know because I didn' t test the code. But things such as "SetFileNameLabel" sound interesting to me.

Sailor 12. Jul 2011 18:16

AW: Save dialog - update file extension in dialog on type change
 
Edt1 is defined in Dlgs, it means the corresponding edit box.
Title is a property of (Save) dialogs and file_id is the file name
you care about. It works fine under Vista too, under Windows7 I
don't know.


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz