From: Dirk B. <db...@us...> - 2006-01-15 09:29:26
|
Update of /cvsroot/win32forth/win32forth/apps/PlayVirginRadio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv578/apps/PlayVirginRadio Modified Files: PlayVirginRadio.f Log Message: Made the popup menu work, added an 'About' dialog, and some clean up of the code. Index: PlayVirginRadio.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/apps/PlayVirginRadio/PlayVirginRadio.f,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PlayVirginRadio.f 11 Jan 2006 17:45:19 -0000 1.7 --- PlayVirginRadio.f 15 Jan 2006 09:29:14 -0000 1.8 *************** *** 4,22 **** \ \ Created: Montag, Mai 16 2005 - dbu ! \ Updated: Samstag, Juni 04 2005 - dbu \ ! \ Simple application that play's "Virgin Radio" from the net ! \ The w32fHtmlDisplay.dll is nedded. ! cr .( Loading Player 4th...) anew -PlayVirginRadio.f ! needs apps\Player4\TrayWindow.f needs HtmlControl.f needs Resources.f true value turnkey? - \ false value turnkey? \ ----------------------------------------------------------------------------- --- 4,24 ---- \ \ Created: Montag, Mai 16 2005 - dbu ! \ Updated: Sonntag, Januar 15 2006 - dbu \ ! \ Simple application that plays the "Virgin Radio Classic Rock" ! \ Radio statio over the internet. ! \ ! \ It also shows how to use the 'TrayWindow' and 'HtmlControl' classes. ! cr .( Loading Play Virgin Radio...) anew -PlayVirginRadio.f ! needs TrayWindow.f needs HtmlControl.f + needs SoundVolume.f needs Resources.f true value turnkey? \ ----------------------------------------------------------------------------- *************** *** 31,35 **** :M WindowStyle: ( -- n ) ! [ WS_OVERLAPPED WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX or WS_MINIMIZEBOX or ] literal ;M --- 33,37 ---- :M WindowStyle: ( -- n ) ! [ WS_OVERLAPPED WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX or ] literal ;M *************** *** 43,46 **** --- 45,49 ---- :M WM_CLOSE ( h m w l -- res ) + SoundOff Stop: Player DestroyWindow: Player *************** *** 49,62 **** bye 0 ;M - :M ShowWindow: ( -- ) - IsVisible?: self 0= - if ShowWindow: super - then ;M - - :M HideWindow: ( -- ) - IsVisible?: self - if HideWindow: super - then ;M - :M GetTooltip: ( -- addr len ) WindowTitle: self zcount ;M --- 52,55 ---- *************** *** 66,142 **** SetURL: Player ;M - :M Pause: ( -- ) - Stop: Player ;M - - :M Resume: ( -- ) - Refresh: Player ;M - :M On_Init: ( -- ) On_Init: super - 1001 SetId: Player self Start: Player ;M ! :M DefaultIcon: ( -- hIcon ) \ return the default icon handle for window LoadAppIcon ;M ;Object ! \ ----------------------------------------------------------------------------- ! \ Turn the sound on and off ! \ ----------------------------------------------------------------------------- ! WinLibrary winmm.dll ! : (volume!) ( left-sound-volume right-sound-volume -- ) ! depth 2 >= ! if 0max 99 min 65535 100 */ 65536 * swap ! 0max 99 min 65535 100 */ + ! 0 Call waveOutSetVolume drop ! else cr ." No enough parameters !!! " ! then ; ! : volume! ( sound-volume -- ) ! dup (volume!) ; ! 100 value volume ! : SoundOn ( -- ) ! 100 dup to volume volume! ; ! : SoundOff ( -- ) ! 0 dup to volume volume! ; ! : SoundOnOff ( -- ) ! volume 0= ! if SoundOn ! else SoundOff ! then ; \ ----------------------------------------------------------------------------- \ Define the Popup bar \ ----------------------------------------------------------------------------- ! \ POPUPBAR player-popup-bar ! \ POPUP " " ! \ MENUITEM "&Sound on/off" SoundOnOff ; ! \ MENUSEPARATOR ! \ MENUITEM "&Exit\tAlt+F4" DestroyWindow: MainWindow ; ! \ ENDBAR \ ----------------------------------------------------------------------------- \ ----------------------------------------------------------------------------- ! : uninit-player ( -- ) DestroyWindow: MainWindow ! \ SoundOn ; ! unload-chain chain-add-before uninit-player \ ----------------------------------------------------------------------------- \ ----------------------------------------------------------------------------- ! : InitPlayer ( -- ) Start: MainWindow Play: MainWindow \ start playing radio... HideWindow: MainWindow \ hide the window in the traybar ! \ player-popup-bar SetPopupBar: MainWindow ; --- 59,143 ---- SetURL: Player ;M :M On_Init: ( -- ) On_Init: super self Start: Player ;M ! :M DefaultIcon: ( -- hIcon ) LoadAppIcon ;M ;Object + \ ------------------------------------------------------------------------------ + \ Define the "About" dialog + \ ------------------------------------------------------------------------------ ! :Object AboutDialog <SUPER dialog ! IDD_ABOUT_FORTH forthdlg find-dialog-id constant template ! create about-head ! z," Play Virgin Radio" ! create about-msg1 ! z," Written in 2005/2006 by:\n" ! +z," Dirk Busch - di...@wi...\n" ! create about-msg2 ! z," This Application plays the 'Virgin Radio Classic Rock'\n" ! +z," Radio statio over the internet." ! create about-msg3 ! z," This application was build with Win32Forth\n" ! +z," Version " -null, version# ((version)) +z", ! +z," . See www.win32forth.org for\n" ! +z," more information about Win32Forth." ! :M On_Init: ( hWnd-focus -- f ) ! about-head zcount IDD_ABOUT_HEAD SetDlgItemText: self ! about-msg1 zcount IDD_ABOUT_TEXT SetDlgItemText: self ! about-msg2 zcount IDD_ABOUT_TEXT2 SetDlgItemText: self ! about-msg3 zcount IDD_ABOUT_TEXT3 SetDlgItemText: self ! 1 ;M ! ! :M On_Command: ( hCtrl code ID -- f1 ) ! CASE ! IDCANCEL OF 0 end-dialog ENDOF ! false swap ( default result ) ! ENDCASE ;M ! ! :M Start: ( -- f ) ! Addr: MainWindow template run-dialog ;M ! ! ;Object \ ----------------------------------------------------------------------------- \ Define the Popup bar \ ----------------------------------------------------------------------------- ! popupbar player-popup-bar ! popup " " ! menuitem "&Turn sound on/off" SoundOnOff ; ! menuseparator ! menuitem "&Close Virgin Radio Player" DestroyWindow: MainWindow ; ! menuseparator ! menuitem "&About Virgin Radio Player" Start: AboutDialog ; ! endbar \ ----------------------------------------------------------------------------- \ ----------------------------------------------------------------------------- ! : UnloadPlayer ( -- ) DestroyWindow: MainWindow ! SoundOn \ turn the sound on ; ! unload-chain chain-add-before UnloadPlayer \ ----------------------------------------------------------------------------- \ ----------------------------------------------------------------------------- ! : StartPlayer ( -- ) Start: MainWindow Play: MainWindow \ start playing radio... + SoundOn \ turn the sound on HideWindow: MainWindow \ hide the window in the traybar ! player-popup-bar SetPopupBar: MainWindow ; *************** *** 162,167 **** \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ! : go ( -- ) ! InitPlayer Turnkeyed? IF MessageLoop bye --- 163,168 ---- \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ! : Main ( -- ) ! StartPlayer Turnkeyed? IF MessageLoop bye *************** *** 171,183 **** \ Tell Imageman that we don't need the w32fconsole.dll if possible ! \ (in older w32f versions you have to modify ! \ Imageman.f to do this). ! \+ VIMAGE also VIMAGE \+ CONSOLE-DLL? false to CONSOLE-DLL? \ Create the exe-file ! ' go turnkey PlayVirginRadio.exe ! \ add the Application Icon s" apps\PlayVirginRadio\Virgin.ico" s" PlayVirginRadio.exe" AddAppIcon --- 172,183 ---- \ Tell Imageman that we don't need the w32fconsole.dll if possible ! \ (in older w32f versions you have to modify Imageman.f to do this). ! \+ VIMAGE also VIMAGE \+ CONSOLE-DLL? false to CONSOLE-DLL? \ Create the exe-file ! ' Main turnkey PlayVirginRadio.exe ! \ add the Application icon to the EXE file s" apps\PlayVirginRadio\Virgin.ico" s" PlayVirginRadio.exe" AddAppIcon *************** *** 185,188 **** [else] s" apps\PlayVirginRadio\Virgin.ico" s" PlayVirginRadio.exe" AddAppIcon ! go [then] --- 185,188 ---- [else] s" apps\PlayVirginRadio\Virgin.ico" s" PlayVirginRadio.exe" AddAppIcon ! Main [then] |