вот нашол. Протестируй ;)
| Код | 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.
|
|