AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Tutorials [Artikel] Selbst-schließende Messagebox - MessageBoxTimeout
Tutorial durchsuchen
Ansicht
Themen-Optionen

[Artikel] Selbst-schließende Messagebox - MessageBoxTimeout

Ein Tutorial von Luckie · begonnen am 8. Jul 2006 · letzter Beitrag vom 20. Okt 2008
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von Luckie
Luckie
Registriert seit: 29. Mai 2002
Selbst-schließende Messagebox - undokumentierte API-Funktion MessageBoxTimeout

In diesem Artikel geht es um die undokumentierte API-Funktion MessageBoxTimeout, eine sich selbst schließende MessageBox.

Artikel: Selbst-schließende Messagebox - undokumentierte API-Funktion MessageBoxTimeout

[edit=fkerber]Link erneuert. Mfg, fkerber[/edit]
Ein Teil meines Codes würde euch verunsichern.
 
OG Karotte
 
#11
  Alt 20. Okt 2008, 15:57
Hier ist er...

[Edit] Mist, zu langsam (und das auch noch ohne Google)...[/Edit]
  Mit Zitat antworten Zitat
Benutzerbild von fkerber
fkerber

 
Delphi XE Professional
 
#12
  Alt 20. Okt 2008, 16:44
Hi!

Habe den Link im ersten Beitrag angepasst!


Ciao, Frederic
Frederic Kerber
  Mit Zitat antworten Zitat
Benutzerbild von juergen
juergen

 
Delphi 11 Alexandria
 
#13
  Alt 20. Okt 2008, 19:55
Hallo zusammmen,

hmm, interessant.
Bei Codegear habe ich noch folgendes gefunden (2 Flüchtigkeitsfehler wurden hierbei in meinem Beispielcode -ausgehend vom Code auf der Codegearseite- korrigiert):
Link zu Codegear
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    btn1: TButton;
    procedure btn1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

function MessageBoxTimeOut(hWnd: HWND; lpText: PChar; lpCaption: PChar;
                           uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;
function MessageBoxTimeOutA(hWnd: HWND; lpText: PChar; lpCaption: PChar;
                            uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;

function MessageBoxTimeOutW(hWnd: HWND; lpText: PWideChar; lpCaption: PWideChar;
                            uType: UINT; wLanguageId: WORD; dwMilliseconds: DWORD): Integer; stdcall;

implementation
 {$R *.dfm}

// this const is not defined in Windows.pas
const
  MB_TIMEDOUT = 32000;
function MessageBoxTimeOut; external user32 name 'MessageBoxTimeoutA';
function MessageBoxTimeOutA; external user32 name 'MessageBoxTimeoutA';
function MessageBoxTimeOutW; external user32 name 'MessageBoxTimeoutW';
//Now, to call the function, it is as easy as setting the flags and making the call.
//There may be other results returned that I am not aware of besides the standard IDxxx return
//values and the MB_TIMEDOUT result defined above.

procedure TForm1.btn1Click(Sender: TObject);
var
  iResult: Integer;
  iFlags: Integer;
begin
  // Define a MessagBox with an OK button and a timeout of 2 seconds
  iFlags := MB_OK or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION;
  iResult := MessageBoxTimeout(Application.Handle, 'Test a timeout of 2 seconds.',
                             'MessageBoxTimeout Test', iFlags, 0, 2000);
  // iResult will = 1 (IDOK)
  ShowMessage(IntToStr(iResult));

  // Define a MessageBox with a Yes and No button and a timeout of 5 seconds
  iFlags := MB_YESNO or MB_SETFOREGROUND or MB_SYSTEMMODAL or MB_ICONINFORMATION;
  iResult := MessageBoxTimeout(Application.Handle, 'Test a timeout of 5 seconds.',
                              'MessageBoxTimeout Test', iFlags, 0, 5000);
  // iResult = MB_TIMEDOUT if no buttons clicked, otherwise
  // iResult will return the value of the button clicked
  case iResult of
  IDYES: // Pressed Yes button
    ShowMessage('Yes');
  IDNO: // Pressed the No button
    ShowMessage('No');
  MB_TIMEDOUT: // MessageBox timed out
    ShowMessage('TimedOut');
  end;
end;

end.
Jürgen
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:48 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