VRuby; set color and background of a text label (VRStatic)

Discussion in 'Ruby' started by Armin Roehrl, Feb 9, 2004.

  1. Armin Roehrl

    Armin Roehrl Guest

    Hi,

    how do I set the color and the background of a
    VRStatic control?

    I tried:
    --
    require 'vr/vruby'
    require "vr/vrcontrol"

    frm=VRLocalScreen.newform

    def frm.construct
    self.caption= "VisualuRuby Sample1"
    addControl(VRStatic, "label1","This is Static",200,50,200,40)
    #@label1.setcolor(RGB(0xff,0xff,0xff))
    p @label1.methods.grep(/olor/)
    @label1.textColor=RGB(0xff,0xff,0xff)
    end

    frm.create
    frm.show
    VRLocalScreen.messageloop
    ---
    and get:

    sample.rb:11:in `textColor=': Not in WM_PAINT event handling (StandardError)
    from sample.rb:11:in `construct'
    from c:/ruby/lib/ruby/site_ruby/1.8/vr/vruby.rb:508:in `create'
    from sample.rb:14

    Thanks for your help,
    -A.
    Armin Roehrl, Feb 9, 2004
    #1
    1. Advertising

  2. Armin Roehrl

    daz Guest

    "Armin Roehrl" wrote:
    > Hi,
    >
    > how do I set the color and the background of a
    > VRStatic control?
    >


    Hi Armin,

    This uses vrctlcolor.rb which you should have in your vr/contrib folder.


    # (VRuby is for Windows only)
    #----------------------------
    require 'vr/vruby'
    require 'vr/vrcontrol'
    require 'vr/vrhandler' # (only using- vr/contrib/vrctlcolor)

    class ARForm < VRForm
    include VRCtlColor

    def construct
    self.caption= "Example - Colored VRStatic"
    addControl(VRStatic, 'lab1', "Static Text\n... continued", 100,50,200,80)

    addCtlColor(@lab1)
    @lab1.setTextColor(RGB(200,0,0))
    @lab1.setBkColor(RGB(255,224,208))
    end
    end

    VRLocalScreen.showForm(ARForm, 0, 0, 400, 400)
    VRLocalScreen.messageloop
    #----------------------------


    daz
    daz, Feb 9, 2004
    #2
    1. Advertising

  3. Armin Roehrl

    Armin Roehrl Guest

    daz, thanks a lot!

    My modified code below does not change the color
    of the text.
    If I uncomment the # in MyForm the color changes.
    What can I do so that the color-change in a VRPanel works?

    ----

    require 'vr/vruby'
    require 'vr/vrhandler'
    require 'vr/vrdialog'
    require 'vr/vrcomctl'
    require 'vr/rscutil'
    require 'vr/vrlayout


    class Adresse < VRPanel
    include VRMenuUseable
    include VRGridLayoutManager
    include WStyle
    include WConst
    include VRMessageParentRelayer
    include VRStdControlContainer
    include VRCtlColor

    def construct
    unit=10.0/9.0
    self.setDimension(2,2)
    addControl(VRStatic, "fn", "Firma:", 1, 1, 10, 10)
    addControl(VRStatic, "firmenName", "Müller GmbH", 14, 1, 20, 10)
    addCtlColor(@firmenName)
    @firmenName.setTextColor(RGB(200,0,0))
    @firmenName.setBkColor(RGB(255,224,208))
    end
    end

    module MyForm
    include VRMenuUseable
    include VRGridLayoutManager
    include WStyle
    include WConst
    include VRCtlColor

    def construct
    unit=10.0/9.0
    setDimension(10,10)
    addControl(Adresse, "panel","p", 0.1+1.3*unit ,0.2,4.75*unit,3)
    #addControl(VRStatic, "fn", "Firma:", 1, 1, 10, 10)
    #addControl(VRStatic, "firmenName", "Müller GmbH", 5, 1, 20, 10)
    #addCtlColor(@firmenName)
    #@firmenName.setTextColor(RGB(200,0,0))
    #@firmenName.setBkColor(RGB(255,224,208))
    end

    end


    frm=VRLocalScreen.newform
    frm.extend MyForm
    frm.create.show
    VRLocalScreen.messageloop
    exit

    ----

    Thank you,
    -A



    >"Armin Roehrl" wrote:
    >
    >
    >>Hi,
    >>
    >> how do I set the color and the background of a
    >>VRStatic control?
    >>
    >>
    >>

    >
    >Hi Armin,
    >
    >This uses vrctlcolor.rb which you should have in your vr/contrib folder.
    >
    >
    ># (VRuby is for Windows only)
    >#----------------------------
    >require 'vr/vruby'
    >require 'vr/vrcontrol'
    >require 'vr/vrhandler' # (only using- vr/contrib/vrctlcolor)
    >
    >class ARForm < VRForm
    > include VRCtlColor
    >
    > def construct
    > self.caption= "Example - Colored VRStatic"
    > addControl(VRStatic, 'lab1', "Static Text\n... continued", 100,50,200,80)
    >
    > addCtlColor(@lab1)
    > @lab1.setTextColor(RGB(200,0,0))
    > @lab1.setBkColor(RGB(255,224,208))
    > end
    >end
    >
    >VRLocalScreen.showForm(ARForm, 0, 0, 400, 400)
    >VRLocalScreen.messageloop
    >#----------------------------
    >
    >
    >daz
    >
    >
    >
    >
    >
    >
    >
    >
    >
    Armin Roehrl, Feb 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. juavizga
    Replies:
    0
    Views:
    138
    juavizga
    Aug 7, 2003
  2. fig000
    Replies:
    0
    Views:
    4,526
    fig000
    Sep 6, 2004
  3. Kamaljeet Saini
    Replies:
    0
    Views:
    363
    Kamaljeet Saini
    Feb 13, 2009
  4. Replies:
    1
    Views:
    255
    marss
    Feb 14, 2007
  5. Knut Krueger
    Replies:
    8
    Views:
    236
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page