RE: Re[2]: copyToBitmapFile

new topic     » goto parent     » topic index » view thread      » older message » newer message

If forgot to mention that I added:
include win32lib.ew
to window.ew and removed a couple of unused variables that was causing 
EXW to complain after the program ended.

Cassidy Napoli wrote:
> Win32Lib is choking.  Here's the complete program:
> [begin code]
> --Winamp Song Ticker to Image
> --Copyright October 2001, A. Cassidy Napoli
> include window.ew
> 
> atom hwnd, rtn
> sequence current_song, playing
> playing = {"IsPlaying.bmp","Wasplaying.bmp","Closed.bmp"}
> 
> --Main Window
> constant Win = create( Window, "The Window", 0, 0, 0, 450, 50, 0 )
> constant songLabel = create( CText, "", Win, 10, 10, 360, 14, 0 )
> constant songPix = create (Pixmap, "My Pixmap", Win, 0, 0, 450, 50, 0)
> ------------------------------
> constant PixLabel = create( CText, "", songPix, 0, 0, 360, 14, 0)
> --The program is choking on this line, with a Win32Lib error:
> --Errorcode: 432
> --getClientRect:getClientRect failed.
> -----------------------------
> 
> --Remove trailing " - Winamp" and leading "XX." from name
> function stripWinampChars (sequence song_name)
>   object char
>   integer count
>   sequence stripped_song
>   char = 0
>   count = 0
>   stripped_song = song_name[1..( (length(song_name) ) - 9)] -- Removes " 
> - Winamp"
>       while not equal({char}, {"."}) do
>         count += 1
>         stripped_song = 
> stripped_song[2..(length(stripped_song))]--Removes "xx."
>         char = song_name[count..count]
>       end while
>   return stripped_song
> end function
> 
> --Start a timer that checks once a second if Winamp is playing,
> --and, if so, set the titlebar to the current song.
> procedure Win_onOpen ()
>        setTimer(Win, Win, 1000)
> end procedure
> 
> procedure makeImage(sequence s )
> 	rtn = deleteFile(playing[2])--This is the file representing what was 
> just playing
> 	rtn = moveFile (playing[1], playing[2])--IsPlaying becomes  WasPlaying
> 	setText(Win, s)
> 	setText(songLabel, s)
> 	rtn = -1
> 	while rtn != 0 do --This is supposed to make sure that the .bmp is 
> created correctly
> 		rtn = deleteFile(playing[1])
> 		rtn = copyToBitmapFile( Win, playing[1], 0, 0, 450, 50 )    
> 	end while
> end procedure
> 
> 
> procedure Win_onTimer(integer id)
> 
> if id then end if
> --Make sure that Winamp is playing before retrieving the songname
> --and stripping useless characters from it
> 
> if   window_Exists("* - Winamp")
> then
> 	hwnd = window_GetHwnd("* - Winamp") 
> 	current_song = stripWinampChars( window_GetCaption(hwnd) )       
> 
>        --Only update if a change has occured
>     if not equal (getText(Win), current_song) and length(current_song) > 
> 5 --Makes sure there the text is worth imaging
> 		then
> 			makeImage(current_song)			
> 	end if
> else 
> 	makeImage("Winamp Ticker not playing.")
> end if
> 
> end procedure
> 
> procedure Win_onClose()
> rtn = copyFile( playing[3], playing[1] , 0) --playing[3] is a permenant 
> image to be displayed when the program is off.
> end procedure
> 
> onTimer[Win] = routine_id("Win_onTimer")
> onOpen[Win]  = routine_id("Win_onOpen")
> onClose[Win] = routine_id("Win_onClose")
> WinMain( Win, Normal )
> 
> [end code]
> 
> Thomas Parslow (PatRat) wrote:
> > Hi,
> > 
> > > I know I'll sound stupid, but how do I do that?  I can create a pixmap
> > > no problem, but how would I attach a line of text to it, then write that 
<snip>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu