Re: Colored statusbar or label
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 12, 2004
- 555 views
On Thu, 11 Nov 2004 22:19:25 +1100, Patrick Barnes <mrtrick at gmail.com> wrote: > On Thu, 11 Nov 2004 00:04:11 -0800, Derek Parnell > <guest at rapideuphoria.com> wrote: > > posted by: Derek Parnell <ddparnell at bigpond.com> > > Sure, just use LText to simulate this... > <SNIP> > Interesting! > I think I'll do that. Argh... whatever I did broke it. Can you figure out why this code doesn't show any hint text? without warning include win32lib.ew constant Win = create(Window, "TEST", 0, 0, 0, 100, 100, 0) setClientRect(Win, 400,400 ) constant colors = { BrightGreen, BrightBlue, BrightRed, Yellow} constant hints = { "Green Bar", "Blue Bar", "Red Bar", "Yellow Bar" } --Create a new health bar with 'players' players. function newHealthBar(integer win, integer num_of_players, sequence hints) sequence tmp_hb tmp_hb = {} for i = 1 to num_of_players do tmp_hb &= createEx(LText, "", win, 0, 0, 0, 0,0, WS_EX_CLIENTEDGE) setWindowBackColor(tmp_hb[i], colors[i] ) setHint(tmp_hb[i], hints[i] ) end for return tmp_hb end function constant scores = {rand(100), rand(100), rand(100), rand(100)} constant total = scores[1] + scores[2] + scores[3] + scores[4] constant players = 4 constant hb = newHealthBar(Win, players, hints) procedure scaleHealthBar(integer total, sequence scores, integer win) sequence w_rect integer left_side, width w_rect = getClientSize(win) left_side = 0 width = 0 --Re-position each bar to fit the score/window for i = 1 to length(scores) do width = floor(w_rect[3]*scores[i]/total) setRect(hb[i], left_side, w_rect[4]-20, width, 23, 1) left_side += width end for end procedure procedure Resize_Win(integer self, integer event, sequence parms) scaleHealthBar( total, scores, Win) end procedure setHandler(Win, w32HResize, routine_id("Resize_Win")) WinMain(Win , Normal) -- MrTrick