![]() |
Re: [Artikel] Selbst-schließende Messagebox - MessageBoxTime
|
Re: [Artikel] Selbst-schließende Messagebox - MessageBoxTime
Hi!
Habe den Link im ersten Beitrag angepasst! Ciao, Frederic |
Re: [Artikel] Selbst-schließende Messagebox - MessageBoxTime
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): ![]()
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. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:47 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz