Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

Форум «Всё о Паскале» _ Делфи _ Сообщение

Автор: Client 17.06.2009 13:59

Привет!
Можно в showMessage (MessageDlg) сделать кнопки на русском языке? А изменить заголовок?

Автор: volvo 17.06.2009 14:15

http://www.delphisources.ru/pages/faq/base/msgdlg_btn_cpt_chg.html посмотри...

Автор: Client 17.06.2009 14:50

function MyMessageDialog(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string): Integer;
var
aMsgDlg: TForm;
i: Integer;
dlgButton: TButton;
CaptionIndex: Integer;
begin
{ Create the Dialog }
{ Dialog erzeugen }
aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
captionIndex := 0;
{ Loop through Objects in Dialog }
{ Uber alle Objekte auf dem Dialog iterieren}
for i := 0 to aMsgDlg.ComponentCount - 1 do
begin
{ If the object is of type TButton, then }
{ Wenn es ein Button ist, dann...}
if (aMsgDlg.Components[i] is TButton) then
begin
dlgButton := TButton(aMsgDlg.Components[i]);
if CaptionIndex > High(Captions) then Break;
{ Give a new caption from our Captions array}
{ Schreibe Beschriftung entsprechend Captions array}
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := aMsgDlg.ShowModal;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
if MyMessageDialog('How much...?', mtConfirmation, mbOKCancel,
['кнопка1', 'кнопка2']) = mrOk then
ShowMessage('"1" clicked')
else
ShowMessage('"2" clicked');
end;
Как я понял: создаем форму для сообщения (хотя как то странно, форма типа TForm, а создаем CreateMessageDialog) и проходим по ее компонентам, если кнопка - то изменить Caption. А программно то кнопки все равно как OK и Cancel smile.gif
Спасибо!