1. RE: Re[2]: copyToBitmapFile
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 04, 2001
- 362 views
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 > > > > out to a file? > > Sorry my previous reply was a bit short, I had to get in to collage > very soon :) You should be able to just substitute the pixmap for the > window, and use same functions. This might help if the problem turns > out to be parts of the window were not getting painted (maybe because > they were covered by another window or something), this shouldn't be a > problem with a Pixmap control). > > How exactly is the outputed image getting corrupted? Maybe you could > post a sample program that shows the problem... > > > Btw, I'm using your window finding routines, they're very useful. > > Thought you'd like to here some praise :). > > Thanks, always nice to hear if people are actually using any of the > stuff I write :) > > > Thanks, > > Cassidy > > Thomas Parslow (PatRat) ICQ #:26359483 > Rat Software > http://www.rat-software.com/ > Please leave quoted text in place when replying > >
2. RE: Re[2]: copyToBitmapFile
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 04, 2001
- 346 views
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>