MessageDlg Özelleştirme

Yazdığınız makaleleri ve üyelerimizin işine yarayacağını düşündüğünüz kodlarınızı gönderebilirsiniz. Bu foruma soru sormayın!
Cevapla
ismailkocacan
Üye
Mesajlar: 88
Kayıt: 25 Eyl 2011 06:11
Konum: İstanbul
İletişim:

MessageDlg Özelleştirme

Mesaj gönderen ismailkocacan »

Bilindiği üzere MessageDlg daki ibareler ingilizce.
Nasıl türkçeleştirebiliriz. Forumda da baktığım pas dosyasını düzenleyerek çözüme ulaşanları gördüm.
Bu da benim çözümüm. Biraz uğraştırdı ama uğraşmaya değer...
Ana Formunuza bir tane TApplicationEvents nesnesi bırakın.

Kod: Tümünü seç

  private
    { Private declarations }
    procedure ConvertToTurkish(H: HWND);

procedure TfrmMain.ConvertToTurkish(H: HWND);
begin
  if FindWindowEx(H, 0, 'TButton', '&Yes') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', '&Yes'), WM_SETTEXT, 0,
      Integer(PCHAR('Evet')));
  end;

  if FindWindowEx(H, 0, 'TButton', '&No') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', '&No'), WM_SETTEXT, 0,
      Integer(PCHAR('Hayır')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'OK') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'OK'), WM_SETTEXT, 0,
      Integer(PCHAR('Tamam')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'Cancel') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'Cancel'), WM_SETTEXT, 0,
      Integer(PCHAR('İptal')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'Abort') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'Abort'), WM_SETTEXT, 0,
      Integer(PCHAR('Durdur')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'Retry') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'Retry'), WM_SETTEXT, 0,
      Integer(PCHAR('Tekrar')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'Ignore') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'Ignore'), WM_SETTEXT, 0,
      Integer(PCHAR('Umursama')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'All') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'All'), WM_SETTEXT, 0,
      Integer(PCHAR('Hepsi')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'N&o to All') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'N&o to All'), WM_SETTEXT, 0,
      Integer(PCHAR('Tümünü Hayır')));
  end;

  if FindWindowEx(H, 0, 'TButton', 'Yes To &All') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', 'Yes To &All'), WM_SETTEXT, 0,
      Integer(PCHAR('Tümünü Evet')));
  end;

  if FindWindowEx(H, 0, 'TButton', '&Close') <> 0 then
  begin
    SendMessage(FindWindowEx(H, 0, 'TButton', '&Close'), WM_SETTEXT, 0,
      Integer(PCHAR('Kapat')));
  end;

end;

Daha sonra TApplicationEvent nesnesinin OnMessage Eventine.

Kod: Tümünü seç

procedure TfrmMain.ApplicationEventsMessage(var Msg: tagMSG;
  var Handled: Boolean);
var
  H: HWND;
begin
  H := FindWindow('TMessageForm', 'Information');
  if H <> 0 then
  begin
    SendMessage(H, WM_SETTEXT, 0, Integer(PCHAR('Bilgi')));
    ConvertToTurkish(H);
    exit;
  end;

  H := FindWindow('TMessageForm', 'Warning');
  if H <> 0 then
  begin
    SendMessage(H, WM_SETTEXT, 0, Integer(PCHAR('Dikkat')));
    ConvertToTurkish(H);
    exit;
  end;

  H := FindWindow('TMessageForm', 'Error');
  if H <> 0 then
  begin
    SendMessage(H, WM_SETTEXT, 0, Integer(PCHAR('Hata')));
    ConvertToTurkish(H);
    exit;
  end;

  H := FindWindow('TMessageForm', 'Confirm');
  if H <> 0 then
  begin
    SendMessage(H, WM_SETTEXT, 0, Integer(PCHAR('Onay')));
    ConvertToTurkish(H);
    exit;
  end;
end;
Saygılarımla.
By İsmail Kocacan
Kullanıcı avatarı
conari
Üye
Mesajlar: 2102
Kayıt: 27 Nis 2006 03:10
Konum: İstanbul & Gebze Karışık

Re: MessageDlg Özelleştirme

Mesaj gönderen conari »

şöyle bir şey paylaşılmıştı sitede...

Kod: Tümünü seç

function MyMessageDlg(const Msg: string;
  DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons;
  Captions: array of string;
  DefButton: Integer): Integer;
// Uses: Dialogs, stdctrls //
var
  aMsgDlg      : TForm;
  i            : Integer;
  dlgButton    : TButton;
  CaptionIndex : Integer;
begin
  aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
  aMsgDlg.FormStyle := fsStayOnTop;
  captionIndex := 0;

  for i := 0 to aMsgDlg.ComponentCount - 1 do
  begin
    if (aMsgDlg.Components[i] is TButton) then
    begin
      dlgButton := TButton(aMsgDlg.Components[i]);
      if CaptionIndex > High(Captions) then Break;
      dlgButton.Caption := Captions[CaptionIndex];
      dlgButton.Default := dlgButton.ModalResult = DefButton;
        if dlgButton.Default then
          aMsgDlg.ActiveControl := dlgButton;
      Inc(CaptionIndex);
    end;
  end;
  aMsgDlg.Caption :=   StringReplace(ExtractFileName(Application.Title),'.exe','',[]);
  Result := aMsgDlg.ShowModal;
end;

Kod: Tümünü seç

  if MyMessageDlg('Server Bağlantısında Hata var!!! ' + #10 +
                     'Server, User ve Şifreyi kontrol ediniz.',mtWarning,  [mbYes, mbNo],['Kontrol Et', 'Vazgeç'],mrNo) = mrYes then
Bir kelimenin anlamını öğretsen bile yeter..
ResimResim
Cevapla