'=========================================================================== ' Subject: MARQUEE PROGRAM Date: 10-16-99 (19:56) ' Author: David Szafranski Code: LB ' Origin: digital_paris@csi.com Packet: LIBERTY.ABC '=========================================================================== ' Marquee Program draws LED lights and scrolls them in an electronic marquee fashion ' It's a bit slow so if you can improve the speed, please let me know. ' Feel free to modify or use this code in any manner you choose! ' For Liberty Basic 1.41 ' David Szafranski Aug 1999 http://libertynow.webjump.com/ nomainwin WindowWidth = 637 WindowHeight = 300 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) graphicbox #main.back, 0, 0, 629, 370 graphicbox #main.statusBar, 0, 270, 629, 30 textbox #main.textbox1, 85, 230, 350, 20 button #main.startbutton, "Start!", [start], UL, 470, 230, 75, 20 button #main.stopbutton, "Stop!", [stop], UL, 550, 230, 75, 20 Menu #main, "&File", "&Exit", [quit] Menu #main, "&Help", "&Help", [help], "&About", [about] open "LED Marquee!" for window as #main open "user" for dll as #user open "gdi" for dll as #gdi print #main, "trapclose [quit]" print #main, "resizehandler [redrawStatbar]" print #main.textbox1, "!setfocus"; print #main.statusBar, "font Arial 0 15"; print #main.startbutton, "!font Arial 0 15"; print #main.stopbutton, "!font Arial 0 15"; print #main.textbox1, "!font Arial 0 15"; print #main.back, "fill black; flush"; print #main.statusBar, "fill lightgray"; gosub [drawStatusBar] 'create statusbar text$ = "Marquee text:" gosub [setStatus1Text] [mainLoop] input aVar$ goto [mainLoop] [start] ' create array of info from textbox1 print #main.back, "fill black"; redim ledArray(349,12) 'array to keep pixel on/off status for textbox count = 0 h = hwnd(#main.textbox1) calldll#user,"GetDC", h as word, hdc as word for x = 1 to 349 for y = 5 to 16 calldll #gdi, "GetPixel",_ hdc AS short,_ x AS short,_ y AS short,_ result AS long if result = 0 then '0 = black ledArray(x-1,y-5) = 1 count = 0 else ' ledArray(x-1,y-5) = 0 count = count + 1 numColumns = x if count = 384 then 'exit if more than 3 blank spaces 12h x 8w x 4columns y = 17 x = 400 end if end if next y next x calldll#user,"ReleaseDC",h as word,hdc as word,result as ushort ' get LED bmp image from statusBar ledSize = 17 imageHeight = 12 * ledSize imageWidth = 637 - 8 - ledSize print #main.statusBar, "getbmp led "; 442; " "; 6; " "; ledSize; " "; ledSize ' get blank black column image to be used to erase the last column on right 'entrance' print #main.back, "getbmp blank "; 0; " "; 0; " "; ledSize; " "; imageHeight ' print first column of LED's on far right column yoffset = 10 stopFlag = 0 while stopFlag = 0 scan for i = 0 to numColumns-21 print #main.back, "drawbmp blank "; imageWidth; " "; yoffset for j = 0 to 11 if ledArray(i,j) = 1 then print #main.back, "drawbmp led "; imageWidth; " "; j*ledSize + yoffset end if next j ' get image of all but first column print #main.back, "getbmp image "; ledSize-1; " "; yoffset; " "; imageWidth; " "; imageHeight ' copy image to first column, ie shift to the left print #main.back, "drawbmp image "; 0; " "; yoffset next i goto [nextLoop] [stop] stopFlag = 1 [nextLoop] wend goto [mainLoop] [redrawStatbar] hstatbar = 30 newWidth = WindowWidth newHeight = WindowHeight print #main.statusBar, "locate "; 0; " "; newHeight-hstatbar; " "; newWidth; " "; hstatbar print #main.back, "locate 0 0 "; newWidth; " "; newHeight print #main.textbox1, "!locate 85 "; newHeight - 24; " "; 350; " "; 20 print #main.startbutton, "!locate 470 "; newHeight - 24; " "; 75; " "; 20 print #main.stopbutton, "!locate 550 "; newHeight - 24; " "; 75; " "; 20 print #main, "refresh" print #main.back, "fill black"; goto [mainLoop] [help] message$ = "1. Enter a text message into the Textbox in the StatusBar." + chr$(13)+ _ "2. Press Start scrolling marquee." + chr$(13)+ _ "3. Press Stop to stop scrolling action." title$ = "LED Marquee! 1.0" h=hwnd(#main) wtype = 4160 calldll #user, "Messagebox", _ h as word, _ message$ as ptr, _ title$ as ptr, _ wtype as word, _ RESULT as short goto [mainLoop] [about] message$ = "LED Marquee! 1.0" + chr$(13)+ _ "David Szafranski" + chr$(13)+ _ "digital_paris@compuserve.com" title$ = "LED Marquee! 1.0" h=hwnd(#main) wtype = 4160 calldll #user, "Messagebox", _ h as word, _ message$ as ptr, _ title$ as ptr, _ wtype as word, _ RESULT as short goto [mainLoop] [quit] confirm " Do you want to exit? "; a$ if a$="no" then goto [mainLoop] if stopFlag = 1 then UNLOADBMP "led" UNLOADBMP "blank" UNLOADBMP "image" end if close #user close #gdi close #main end ' ***** SUBROUTINES *********** [drawStatusBar] wstatbar = 762 hstatbar = 30 gap = 2 'border width for status bar x = gap-1 'draw outside raisedd3D box y = gap-1 boxWidth = wstatbar-(2*(gap-1))-12 boxHeight = hstatbar-(2*(gap-1))-2 outsideBoxWidth=boxWidth outsideBoxHeight=boxHeight gosub [raisedStatBarBox] x = 440 'draw first raised3D status bar box for LED boxWidth = 20 boxHeight = 20 y = hstatbar/2 - boxHeight/2 -1 statusBoxHeight = boxHeight gosub [raisedStatBarBox] ' draw filled circle for LED print #main.statusBar, "place "; x+1; " "; y+1 print #main.statusBar, "backcolor black" print #main.statusBar, "boxfilled "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "place "; x+boxWidth/2+1; " "; y+boxHeight/2+1 drawingcolor$ = "white" print #main.statusBar, "color "; drawingcolor$ bcolor$ = "red" print #main.statusBar, "backcolor "; bcolor$ radius = 7 print #main.statusBar, "circlefilled "; radius print #main.statusBar, "flush" return [raisedStatBarBox] ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height print #main.statusBar, "color white ; down" print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x; " "; y+boxHeight print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x + boxWidth; " "; y print #main.statusBar, "color darkgray" print #main.statusBar, "place "; x; " "; y+boxHeight print #main.statusBar, "line "; x; " "; y+boxHeight; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "place "; x+boxWidth; " "; y print #main.statusBar, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "flush" return [recessedStatBarBox] ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height print #main.statusBar, "color darkgray ; down" print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x; " "; y+boxHeight print #main.statusBar, "place "; x; " "; y print #main.statusBar, "line "; x; " "; y; " "; x + boxWidth; " "; y print #main.statusBar, "color white" print #main.statusBar, "place "; x; " "; y+boxHeight print #main.statusBar, "line "; x; " "; y+boxHeight; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "place "; x+boxWidth; " "; y print #main.statusBar, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight print #main.statusBar, "flush" return [setStatus1Text] 'grid size 'text label print #main.statusBar, "color black; backcolor lightgray" print #main.statusBar, "place 4 20" 'erase previous text print #main.statusBar, "\ " print #main.statusBar, "place 4 20" 'print new text print #main.statusBar, "\ "; text$ print #main.statusBar, "flush" return