Code: Alles auswählen
#MB_TIMEDOUT = $7D00
Prototype.i MBTimeOut(hwnd.i, lpText.s, lpCaption.s, uType.l, wLanguageId.w, dwMilliseconds.l)
Procedure MessageBoxTimeout(hwnd.i, lpText.s, lpCaption.s, uType.l, dwMilliseconds.l)
  Protected hDLL = GetModuleHandle_("user32")
  Protected FuncString.s
  Protected MBTimeOut.MBTimeOut
  
  CompilerIf #PB_Compiler_Unicode
    FuncString.s = Space(17)
    PokeS(@FuncString, "MessageBoxTimeoutW", -1, #PB_Ascii)
  CompilerElse
    FuncString.s = "MessageBoxTimeoutA"
  CompilerEndIf
  
  If hDLL
    MBTimeOut = GetProcAddress_(hDLL, @FuncString)
    If MBTimeOut
      ProcedureReturn MBTimeOut(hwnd, lpText, lpCaption, uType, 0, dwMilliseconds)
    EndIf
  Else
    Debug "Error: MessageBoxTimeout"
  EndIf
EndProcedure
; Beispiel:
Select MessageBoxTimeout(0, "Mögen Sie PureBasic?" + #LF$ + "Sie haben 5 Sekunden zu antworten!", "Frage:", #MB_YESNO, 5000)
  Case #IDYES
    Debug "Sie haben 'Ja' gewählt!"
  Case #IDNO
    Debug "Sie haben 'Nein' gewählt!"
  Case #MB_TIMEDOUT
    Debug "Sie waren zu langsam ;-)"
EndSelectGruß
Thomas



