Re: setTextColor problems

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

On Sunday 06 January 2002 01:45 pm, you wrote:
>
> Hi,
>
> I've been using Euphoria for less than a week, so bear with me.
>
> I'm having trouble setting a static label's colour with Win32Lib...
>
> e.g.    setTextColor (Window , color)
>
> I've used Judith's **fine** IDE to flesh out a basic form.
> I've placed an LText label on the form, went to the font property box
> and brought up the **Font Dialog Box**... and selected my font color, etc.
> and the IDE didn't respond.
>
> No problem, I thought, I'll just edit the source code that Judith's IDE
> produced.
>
> this is the snippet....
> --------------------------
> global constant LText4 = create( LText, "Blueberry Pies", Window1, 168, 12,
> 364, 80, 0 ) setWindowBackColor( LText4,16771818)
> setFont( LText4,"Arial", 26, Bold)
> setTextColor( LText4, Blue )
> --------------------------
>
> I can set the above settings, **except** the colour.
> I've tried various sample programs to see if I could get some response, but
> nothing.
>
> Is setTextColor broken in Win32Lib? or is it something else?

Yes and no; here's Derek's answer to the same question back in August:

> is it possible to set the color of the text for a label in Win32lib?
> setTextColor doesn't seem to work for a label

Hi,
your are right in that normally setTextColor() doesn't work for LText, RText
and CText controls. This is because the standard events for these built-in
controls are trapped by the Windows DLL which of course ignore some of the
settings that Win32lib makes.

But, all is not lost. If you really want to do this sort of thing (and who
doesn't) you can try the type of solution I've given an example for here...

--------------------
include win32lib.ew
without warning
constant
    mainWin = create(Window, "Test Coloured Labels", 0, 0, 0, 400, 300, 0),
    labelArea = create(LText, "", mainWin, 5, 5, 200, 25, 0)

procedure labelArea_Paint(integer left, integer top, integer width, integer
height)
    -- Draw the background
    setPenColor(labelArea, Blue)
    drawRectangle(labelArea, 1, left, top, width, height)

    -- Draw a border
    setPenColor(labelArea, BrightCyan)
    drawRectangle(labelArea, 0, left, top, width, height)
    drawRectangle(labelArea, 0, left+1, top+1, width-1, height-1)

    -- Draw the text
    setPenPos(labelArea, 3, 3)
    wPuts(labelArea, "Hello, World!")

end procedure
onPaint[labelArea] = routine_id("labelArea_Paint")

-- These need only to be done once, not every paint event.
setFont(labelArea, "Courier New", 14, Normal)
setTextColor(labelArea, BrightWhite)

WinMain(mainWin, 0)

---------------------
Hope this helps.

Derek.


Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu