Re: [WIN32LIB] Font Confusion
- Posted by Derek Parnell <ddparnell at bigpond.com> Jul 07, 2002
- 357 views
Travis, here is the same example with self-centering text... -------------------- -- colorlabel.exw -- -- This demonstrates one method of creating coloured labels. without warning with trace include win32lib.ew constant SimpleWin = create( Window, "Simple Window", 0, 0, 0, 200, 140, 0 ), lbl1 = create(Window, "Label One", SimpleWin, 5, 5, 120, 20, {WS_VISIBLE,WS_CHILD}), lbl2 = create(Window, "Label Two", SimpleWin, 5, 35, 120, 20, {WS_VISIBLE,WS_CHILD}), lbl3 = create(Window, "Label Three", SimpleWin, 5, 65, 120, 20, {WS_VISIBLE,WS_CHILD}), btn1 = create(Button, "Flip", SimpleWin, 135, 5, 50, 25, 0) sequence lblList lblList = {lbl1,lbl2,lbl3} setFont(lbl1, "Arial", 10, Normal) setFont(lbl2, "Courier New", 14, Normal) setFont(lbl3, "Times Roman", 12, Normal) defineUserProperty(lbl1, "TextColor", BrightRed) defineUserProperty(lbl1, "TextBG", Black) defineUserProperty(lbl2, "TextColor", BrightCyan) defineUserProperty(lbl2, "TextBG", Brown) defineUserProperty(lbl3, "TextColor", BrightWhite) defineUserProperty(lbl3, "TextBG", Blue) with trace integer vPainting vPainting = False ------------------------------------------------ procedure onPaint_lbls(integer self, integer event, sequence parms) ------------------------------------------------ sequence lVal sequence lTE sequence text sequence lEx if vPainting = False then vPainting = True lVal = getUserProperty(self, "TextColor") setTextColor( self, lVal[1]) lVal = getUserProperty(self, "TextBG") setWindowBackColor(self, lVal[1]) text = getText(self) lTE = getTextExtent(self, text) lEx = getClientSize(self) wPuts( {self, floor((lEx[3] - lTE[1])/2), floor((lEx[4] - lTE[2])/2)}, text ) vPainting = False end if end procedure setHandler(lblList, w32HPaint, routine_id("onPaint_lbls")) integer vPhase vPhase = 0 sequence vLblText vLblText = {{"One","1"}, {"Two","2"},{"Three","3"}} ------------------------------------------------ procedure onClick_btn1(integer self, integer event, sequence parms) ------------------------------------------------ atom c1, c2 sequence lVal vPhase = not vPhase for i = 1 to length(lblList) do -- Swap Fg and Bg colors lVal = getUserProperty(lblList[i], "TextColor") c1 = lVal[1] lVal = getUserProperty(lblList[i], "TextBG") c2 = lVal[1] setUserProperty(lblList[i], "TextColor", c2) setUserProperty(lblList[i], "TextBG", c1) -- Change width of text. setText(lblList[i], "Label " & vLblText[i][1+vPhase]) end for repaintWindow(SimpleWin) end procedure setHandler(btn1, w32HClick, routine_id("onClick_btn1")) WinMain( SimpleWin, Normal) -------------------- ----- Original Message ----- From: "Travis Beaty" <travis_beaty at mcleodusa.net> To: "EUforum" <EUforum at topica.com> Sent: Monday, July 08, 2002 3:33 AM Subject: RE: [WIN32LIB] Font Confusion > > > Secondly, did you ever test that code I sent on Windows ME to see if it > crashed, and if so, why? Just curious ... got a long way to go in this > project before that becomes a real concern. > This was caused because of bugs in the resource management in the library. I'm rewriting that subsystem, so hopefully this problem will go away. ----------- Derek