Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Q: Changing button caption on Open/Save dialog

115 views
Skip to first unread message

Alif Yukkas

unread,
Sep 8, 1998, 3:00:00 AM9/8/98
to
I want to change button caption on Open/Save dialog.
Actually, I want to change 'Open' button to 'Upload' button on Open dialog
and change 'Save' button to 'Download' button.

Can anyone help me?

---
Alif Yukkas
al...@lintasarta.co.id


Peter Below

unread,
Sep 8, 1998, 3:00:00 AM9/8/98
to
> I want to change button caption on Open/Save dialog.
> Actually, I want to change 'Open' button to 'Upload' button on Open dialog
> and change 'Save' button to 'Download' button.
>
Alif,

you can do this fairly easily in D3/4. Add a handler to the dialogs OnShow
event. Into the handler you put this code:

var
buffer: array [0..40] of char;]
begin
StrCopy( Buffer, 'Download' );
SendMessage( GetParent((Sender as TSaveDialog).handle),
CDM_SETCONTROLTEXT, IDOK, integer(@Buffer));
end;

The code for the open dialog is similar. Add the CommCtrl Unit to your Uses
clause for the CDM message constant.

You can do similar changes to other elements of the dialog. To analyze the
structure of the dialog and get the control IDs required, add the following
OnShow handler to it and execute the dialog. Put a memo on your test form to
see the results:

Function enumchildproc( ctrl: HWND; list: TStrings ): Bool; stdcall;
Var
buf: Array [0..80] of Char;
id : Integer;
caption: array [0..80] of Char;
Begin
result := True;
getClassname( ctrl, buf, 80 );
id := getdlgCtrlid( ctrl );
getwindowtext( ctrl, caption, 80 );
list.add( format('Class: <%s>, id: <%d>, caption: <%s>',
[buf, id, caption] ));
End;

procedure TForm1.SaveDialog1Show(Sender: TObject);
begin
memo1.lines.clear;
memo1.wordwrap := false;
EnumChildWindows( Windows.GetParent( Savedialog1.handle ),
@enumchildproc,
longint(memo1.lines ));
end;

The result on my (german) system is this:

Class: <Static>, id: <1091>, caption: <Speichern &in:>
Class: <ComboBox>, id: <1137>, caption: <>
Class: <Static>, id: <1088>, caption: <>
Class: <ListBox>, id: <1120>, caption: <>
Class: <Static>, id: <1090>, caption: <Datei&name:>
Class: <Edit>, id: <1152>, caption: <> <== this is the target!
Class: <Static>, id: <1089>, caption: <Datei&typ:>
Class: <ComboBox>, id: <1136>, caption: <>
Class: <Button>, id: <1040>, caption: <Mit Sch&reibschutz öffnen>
Class: <Button>, id: <1>, caption: <&Speichern>
Class: <Button>, id: <2>, caption: <Abbrechen>
Class: <Button>, id: <1038>, caption: <&Hilfe>
Class: <ToolbarWindow32>, id: <1>, caption: <>
Class: <#32770>, id: <0>, caption: <>

You will see a number of controls in the list that are hidden. The control
IDs should not change between invocations of the dialog, there is a remote
change that they may change with different versions of the common dialogs
DLL.


Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitely requested!


0 new messages