Модераторы: Poseidon, Snowy, bems, MetalFan

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Создание собственного окошка сообщения. Как сделать что там все было свое? 
V
    Опции темы
Yanis
Дата 25.7.2006, 17:38 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 2937
Регистрация: 9.2.2004
Где: Москва

Репутация: 72
Всего: 111



Цитата(Snowy @  25.7.2006,  17:03 Найти цитируемый пост)
Эти значения прописаны в самих виндах, а не в ехешнике. 

Угу. В user32.dll вроде. 


--------------------
user posted image *щёлк*
PM MAIL WWW ICQ   Вверх
svarogik
Дата 25.7.2006, 18:01 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 159
Регистрация: 20.3.2006

Репутация: нет
Всего: нет



А как по этому выскочившему окошку проверять можно ли закрывать программу,  это окошко что возвращает какие то значения? 
PM MAIL   Вверх
Snowy
Дата 25.7.2006, 18:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Модератор
Сообщений: 11363
Регистрация: 13.10.2004
Где: Питер

Репутация: 192
Всего: 484



Читай справку по TForm.ShowModal
Yf выходе модальный результат.
Назначь нужный кнопкам. 
PM MAIL   Вверх
kostas
Дата 29.7.2006, 08:53 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 100
Регистрация: 21.7.2006

Репутация: 3
Всего: 4



Цитата(Snowy @  25.7.2006,  16:03 Найти цитируемый пост)
Не получится.Эти значения прописаны в самих виндах, а не в ехешнике. 

а вот и нет, можешь попробовать сам smile этот способ работает, по крайней мере для MessageDlg 

Это сообщение отредактировал(а) kostas - 29.7.2006, 08:55
PM ICQ   Вверх
GRU
Дата 10.8.2006, 22:27 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 26
Регистрация: 20.7.2004

Репутация: 1
Всего: 1



вот нашол. Протестируй ;)

Код

unit MyDialogs;

interface

uses
  Forms, Dialogs, StdCtrls;

  //----
  function MyMessageDlg(Msg: String; MsgDlgType: TMsgDlgType;
    Buttons: TMsgDlgButtons): Integer;
  procedure MyShowMessage(const Msg: string);
  procedure MyShowMessagePos(const Msg: string; X, Y: Integer);
  function MyMessageDlgPos(const Msg: string; DlgType: TMsgDlgType;
    Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;

  function MyOpenDialog(Msg: String; MsgDlgType: TMsgDlgType;
    Buttons: TMsgDlgButtons): Integer;

implementation

function MyMessageDlg(Msg: String; MsgDlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons): Integer;

  function DialogCaption(DlgCaption: string): string;
  begin
    Result := DlgCaption;
    if DlgCaption = 'Warning' then Result := '1111';
    if DlgCaption = 'Error' then Result := '2222';
    if DlgCaption = 'Information' then Result := '3333';
    if DlgCaption = 'Confirm' then Result := '4444';
  end;

  function ButtonNames(ButtonName: string): string;
  begin
    Result := ButtonName;
    if ButtonName = 'Yes' then Result := '00';
    if ButtonName = 'No' then Result := '11';
    if ButtonName = 'OK' then Result := '22';
    if ButtonName = 'Cancel' then Result := '33';
    if ButtonName = 'Abort' then Result := '44';
    if ButtonName = 'Retry' then Result := '55';
    if ButtonName = 'Ignore' then Result := '66';
    if ButtonName = 'All' then Result := '77';
    if ButtonName = 'NoToAll' then Result := '88';
    if ButtonName = 'YesToAll' then Result := '99';
    if ButtonName = 'Help' then Result := 'AA';
  end;

  function StrCRLF(const StrMsg: string): string;
  var
    nLen, i: Integer;
  begin
    nLen := Length(StrMsg);
    i := 1;
    while (i <= nLen) do begin
      if StrMsg[i] in [';','~']
        then Result := Result + #13
        else Result := Result + StrMsg[i];
      Inc(i);
    end;
  end;

var
  CenterForm: Boolean;
  I: Integer;
  Btn: TButton;
  AForm: TForm;

begin
  CenterForm := {Form1 <> nil;}Screen.ActiveForm <> nil;
  AForm := Screen.ActiveForm;

  with CreateMessageDialog(StrCrLf(Msg), MsgDlgType, Buttons) do
  try
    if CenterForm
    then begin
      Left := AForm.Left + (AForm.Width div 2)-(Width div 2);
      Top := AForm.Top + (AForm.Height div 2)-(Height div 2);
      Caption := DialogCaption(Caption);
    end;

    for I := 0 to ComponentCount -1 do begin
      if Components[i] Is TButton
      then begin
        Btn := TButton(Components[I]) ;
        Btn.Caption := ButtonNames(Btn.Name);
      end;
    end;
    Result := ShowModal;
  finally
    Free;
  end;
end;

procedure MyShowMessage(const Msg: string);
begin
  MyShowMessagePos(Msg, -1, -1);
end;

procedure MyShowMessagePos(const Msg: string; X, Y: Integer);
begin
  MyMessageDlgPos(Msg, mtCustom, [mbOK], 0, X, Y);
end;

function MyMessageDlgPos(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer;
begin
  Result := MyMessageDlg(Msg, DlgType, Buttons);
end;

//---------------------------?????????---------------------------------------

function MyOpenDialog(Msg: String; MsgDlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons): Integer;

  function DialogCaption(DlgCaption: string): string;
  begin
    Result := DlgCaption;
    if DlgCaption = 'Warning' then Result := 'AA';
    if DlgCaption = 'Error' then Result := 'BB';
    if DlgCaption = 'Information' then Result := 'CC';
    if DlgCaption = 'Confirm' then Result := 'DD';
  end;

  function ButtonNames(ButtonName: string): string;
  begin
    Result := ButtonName;
    if ButtonName = 'Yes' then Result := '00';
    if ButtonName = 'No' then Result := '11';
    if ButtonName = 'OK' then Result := '22';
    if ButtonName = 'Cancel' then Result := '33';
    if ButtonName = 'Abort' then Result := '44';
    if ButtonName = 'Retry' then Result := '55';
    if ButtonName = 'Ignore' then Result := '66';
    if ButtonName = 'All' then Result := '77';
    if ButtonName = 'NoToAll' then Result := '88';
    if ButtonName = 'YesToAll' then Result := '99';
    if ButtonName = 'Help' then Result := 'AA';
    if ButtonName = 'Open' then Result := 'BB';
  end;

  function StrCRLF(const StrMsg: string): string;
  var
    nLen, i: Integer;
  begin
    nLen := Length(StrMsg);
    i := 1;
    while (i <= nLen) do begin
      if StrMsg[i] in [';','~']
        then Result := Result + #13
        else Result := Result + StrMsg[i];
      Inc(i);
    end;
  end;

var
  CenterForm: Boolean;
  I: Integer;
  Btn: TButton;
  AForm: TForm;

begin
  CenterForm := {Form1 <> nil;}Screen.ActiveForm <> nil;
  AForm := Screen.ActiveForm;
  
  with CreateMessageDialog(StrCrLf(Msg), MsgDlgType, Buttons) do
  try
    if CenterForm
    then begin
      Left := AForm.Left + (AForm.Width div 2)-(Width div 2);
      Top := AForm.Top + (AForm.Height div 2)-(Height div 2);
      Caption := DialogCaption(Caption);
    end;

    for I := 0 to ComponentCount -1 do begin
      if Components[i] Is TButton
      then begin
        Btn := TButton(Components[I]) ;
        Btn.Caption := ButtonNames(Btn.Name);
      end;
    end;
    Result := ShowModal;
  finally
    Free;
  end;
end;

end.


Это сообщение отредактировал(а) GRU - 10.8.2006, 23:17
PM MAIL   Вверх
Snowy
Дата 11.8.2006, 00:43 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Модератор
Сообщений: 11363
Регистрация: 13.10.2004
Где: Питер

Репутация: 192
Всего: 484



Цитата(kostas @  29.7.2006,  08:53 Найти цитируемый пост)
а вот и нет, можешь попробовать сам  этот способ работает, по крайней мере для MessageDlg 
MesageDlg - не есть WinAPI функция.
Строки для неё заложены в ресурсы ехешника.
А вот строки для MessageBox заложены в винду и зависят от её языка.
PM MAIL   Вверх
Snowy
Дата 11.8.2006, 00:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Модератор
Сообщений: 11363
Регистрация: 13.10.2004
Где: Питер

Репутация: 192
Всего: 484



GRU, как-то это не очень компактно.
Проще так:
Код
var
  dlg: TForm;
begin
  dlg := CreateMessageDialog('А ты уверен?', mtConfirmation, [mbYes, mbNo]);
  (dlg.FindComponent('Yes') as TButton).Caption := 'Конечно';
  (dlg.FindComponent('No') as TButton).Caption := 'Не очень';
  if dlg.ShowModal = mrYes then ShowMessage('Он согласился!');
  dlg.Free;
end;

PM MAIL   Вверх
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Delphi: Общие вопросы"
SnowyMetalFan
bemsPoseidon
Rrader

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по Дельфи обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) - крупнейшем в рунете сборнике материалов по Дельфи


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Snowy, MetalFan, bems, Poseidon, Rrader.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Delphi: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0738 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.