Einzelnen Beitrag anzeigen

Benutzerbild von rweinzierl
rweinzierl

Registriert seit: 22. Mär 2005
98 Beiträge
 
#5

AW: MessageDLG nicht sichtbar

  Alt 3. Jul 2013, 10:03
Den Umweg mit der WINAPI-Version möchte ich ungern machen.

Hallo

Ich bin den Umweg über die WINAPI gegangen. Ich habe alle MessageDlg nochmals gekapselt also z.B. in myMessage_DLG und dann an dieser einen Stelle den Aufruf in die MessageBox umgebogen.

(Dann gehts auch in vorhandenen Projekten mit vertretbarem Aufwand)

Hat den zusätzlichen Vorteil das die MessageBox Dialoge übersetzt sind.

Ausserdem hat die orginal MessageBox der WinAPI zusätzliche Möglichkeiten (GExperts Stg-D)

mfg

Reinhold



Delphi-Quellcode:

function ErsetzteMessage_DlgDurchMessgeBox(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
var uType: UINT;
boolAlsBoxMoeglich : boolean;
iResultVonBox: integer;
begin

uType := MB_ICONQUESTION;
case DlgType of
  mtWarning : uType :=MB_ICONWARNING ;
  mtError : uType :=MB_ICONERROR ;
  mtInformation : uType :=MB_ICONINFORMATION ;
  mtConfirmation : uType := MB_ICONQUESTION;
end;

boolAlsBoxMoeglich := false;

if Buttons = [mbOK] then
  begin
  uType := uType or MB_OK;
  boolAlsBoxMoeglich := true;
  end;


if Buttons = [ mbOK, mbCancel] then
  begin
  uType := uType or MB_OKCANCEL ;
  boolAlsBoxMoeglich := true;
  end;

if Buttons = [ mbAbort, mbRetry, mbIgnore] then
  begin
  uType := uType or MB_ABORTRETRYIGNORE ;
  boolAlsBoxMoeglich := true;
  end;

if Buttons = [ mbYes, mbNo,mbCancel ] then
  begin
  uType := uType or MB_YESNOCANCEL ;
  boolAlsBoxMoeglich := true;
  end;

if Buttons = [ mbYes, mbNo ] then
  begin
  uType := uType or MB_YESNO ;
  boolAlsBoxMoeglich := true;
  end;

if Buttons = [ mbRetry , mbCancel ] then
  begin
  uType := uType or MB_RETRYCANCEL ;
  boolAlsBoxMoeglich := true;
  end;


if boolAlsBoxMoeglich then
  begin
// uType := uType or MB_SYSTEMMODAL; Dann ist es bestimmt oben !!!
  iResultVonBox := MessageBox(application.Handle , pchar(Msg),'Mein Caption', uType );

  case iResultVonBox of
    IDOK : result := mrOK ;
    IDCANCEL : result := mrCANCEL ;
    IDABORT : result := mrABORT;
    IDRETRY : result := mrRETRY ;
    IDIGNORE : result := mrIGNORE ;
    IDYES : result := mrYES ;
    IDNO : result := mrNO ;
    else
      result := mrOK;
  end;

  end
else
  begin
  result := MessageDlg(Msg, DlgType, Buttons, HelpCtx) ;
  end;



end;
  Mit Zitat antworten Zitat