Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi MessageDLG nicht sichtbar (https://www.delphipraxis.net/175592-messagedlg-nicht-sichtbar.html)

mediatech 3. Jul 2013 07:04

MessageDLG nicht sichtbar
 
Hallo,
habe ein Projekt von D2006 auf Delphi XE2 "portiert". Funktioniert soweit auch, aber: eine (bzw. jede) mit "Messagedlg(...." erzeugte Messagebox wird hinter dem aktiven Formular versteckt, ist also nicht sichtbar. Erst durch antippen der "ALT"-Taste erscheint der Dialog.

Muss ich da irgendwo was einstellen, oder wo steckt der Fehler ?


Andreas

lbccaleb 3. Jul 2013 07:12

AW: MessageDLG nicht sichtbar
 
Übergibst du beim Aufruf von MessageDlg das Hauptformular als Handle?

Edit:
Achso, die Möglichkeit besteht nur in der WinAPI Version. Bei Delphi gibs das gar nicht -.-

baumina 3. Jul 2013 07:25

AW: MessageDLG nicht sichtbar
 
Versuche mal im ProjektQuelltext nach Application.Initialize Application.MainformOnTaskbar := true zu setzen.

mediatech 3. Jul 2013 07:43

AW: MessageDLG nicht sichtbar
 
- Application.MainformOnTaskbar ist auf "true"

Den Umweg mit der WINAPI-Version möchte ich ungern machen. Bei einem neu angelegten Projekt funktioniert das Ganze ja auch. Also muss es sich doch um irgendeine Prokjekt- oder Form-Einstellung handeln ?

rweinzierl 3. Jul 2013 10:03

AW: MessageDLG nicht sichtbar
 
Zitat:

Zitat von mediatech (Beitrag 1220512)
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:13 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz