![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Well this is tougher than one might think. I came up with a solution
utilizing the PlaySound function instead of mciSendString. The
PlaySound API specifies a synchronous mode which will only return
after the wave file is completely played. It fails to mention that
this only works if the API is called while there is a *visible*
window. What should of been a single line change to your program
became the following:
LIBRARY WINMM.DLL
Function: PlaySoundA ( zSound Mod Flags -- res )
\ Play Wave File from Disk, Return Immediately
: PLAY-FILE ( zaddr --- )
NULL SND_FILENAME SND_ASYNC OR PlaySoundA DROP ;
\ Play Wave File from Disk, Return when Complete
: PLAY-FILE-WAIT ( zaddr --- )
HINST SND_FILENAME SND_SYNC OR PlaySoundA DROP ;
: PLAY-CMDLINE ( -- ) \ Play file on command line
CMDLINE PAD ZPLACE PAD PLAY-FILE-WAIT ;
\ For some lame reason, the play SND_SYNC function does not work
\ unless there is a *visible* window. So we'll create a window
\ off in the weeds. Welcome to Kludge city.
: SHOW-ME ( -- )
HWND SW_SHOWNORMAL ShowWindow DROP ;
CREATE APP-CLASS ,Z" SF-Play"
CREATE APP-TITLE ,Z" Play"
[SWITCH APP-MESSAGES DEFWINPROC ( msg -- res )
WM_DESTROY RUN: 0 PostQuitMessage DROP 0 ;
WM_CREATE RUN: SHOW-ME PLAY-CMDLINE
HWND WM_CLOSE 0 0 PostMessage DROP 0 ;
SWITCH]
:NONAME MSG LOWORD APP-MESSAGES ; 4 CB: APP-WNDPROC
: /APP-CLASS ( -- )
0 CS_OWNDC OR
CS_HREDRAW OR
CS_VREDRAW OR \ class style
APP-WNDPROC \ wndproc
0 \ class extra
0 \ window extra
HINST \ hinstance
0 \
NULL IDC_ARROW LoadCursor \
WHITE_BRUSH GetStockObject \
0 \ no menu
APP-CLASS \ class name
DefineClass DROP ;
: /APP-WINDOW ( -- hwnd )
WS_EX_TOOLWINDOW \ extended style
APP-CLASS \ window class name
NULL \ window caption
WS_POPUP \ window style
10000 10000 0 0 \ kludge position and size
0 \ parent window handle
0 \ window menu handle
HINST \ program instance handle
0 \ creation parameter
CreateWindowEx ;
: DO-IT ( -- )
/APP-CLASS /APP-WINDOW DROP ;
: WINMAIN ( -- )
DO-IT DISPATCHER
'ONSYSEXIT CALLS ( Execute System Exit Chain )
0 ExitProcess ;
' WINMAIN 'MAIN !
-1 THRESHOLD \ No Xref file
PROGRAM PLAY
BYE
I position the window "off in the weeds" so you won't see it and I
specify the WS_EX_TOOLWINDOW extended window style which prevents the
app from appearing on the task bar.
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Richard Owlett
Sent: Friday, December 19, 2003 4:41 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: A run once and exit EXE
Mike Ghan wrote:
> Richard,
>
> Try the following:
>
> : TEST ( -- )
> doesit ( assume this returns when sound complete )
> 'ONSYSEXIT CALLS ( Execute System Exit Chain )
> 0 ExitProcess ;
>
replacing my TEST by yours gives TOTAL failure, as in NOTHING happens
;{
I think the *CRITICAL* issue is waiting for mciSendString to complete.
It does not seem to have an identifiable handle.
so how to wait for it ? ???????????????{
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sun Dec 21 2003 - 11:27:41 PST
This archive was generated by hypermail 2.2.0 : Wed Nov 19 2008 - 03:04:21 PST