![]() |
|
|||||||
| Source Code PowerBASIC and related source code. Please do not post questions or discussions, just source code. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Timed MsgBox with option to continue in PbWin or PB/CC
Needed to pause some batch files to display messages.
This also works if compiled using PB/CC to display a normal line of text. Doesn't use MessageBoxTimeoutA which may fail in earlier windows. 'Usage: CALL Sleeper(2000) or Sleeper.exe 2000 Code:
#DIM ALL
#COMPILE EXE 'Sleeper.bas
#INCLUDE "win32api.inc"
FUNCTION PBMAIN AS LONG
Sleeper 2000 'sleeper.exe can be passed a value on the command line
END FUNCTION
FUNCTION Sleeper (milliseconds AS DWORD) AS LONG
LOCAL hThread AS DWORD
IF LEN(COMMAND$) THEN 'override passed value
milliseconds = ABS(VAL(COMMAND$)) 'use value in COMMAND$
END IF
THREAD CREATE TimedMessageBoxThread(milliseconds) TO hThread
SLEEP 50
WaitForSingleObject hThread, milliseconds
THREAD CLOSE hThread TO hThread
END FUNCTION
THREAD FUNCTION TimedMessageBoxThread(BYVAL milliseconds AS DWORD) AS LONG
#IF %DEF(%PB_CC32)
? "Press ENTER to continue or WAIT" + STR$(milliseconds) + " milliseconds"
WAITKEY$
#ELSE
? "Click OK to continue or WAIT" + STR$(milliseconds) + " milliseconds"
#ENDIF
END FUNCTION
Last edited by Mike Doty; May 1st, 2009 at 04:50 PM. |
|
#2
|
|||
|
|||
|
Oops.
Last edited by Michael Mattias; May 2nd, 2009 at 05:42 PM. Reason: I WAS in the wrong thread |
|
#3
|
|||
|
|||
|
I think you are in the wrong thread.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|