Suneido

Integrated Application Platform

  • Home
  • Learning
    • Suneido Manual
    • Beginners
      • Inside Suneido
      • The Suneido Programming Language
      • The Suneido Database
      • Installing Suneido
      • Building Suneido
      • IDE Go To Tour
      • Upgrading To A New Release
    • Advanced
      • Canvas Control
      • DrawControl Part 1
      • DrawControl Part 2
      • DrawControl Part 3
      • SAX Like XML Processing
      • A Plug-In Architecture
      • A Simple Wizard Framework
      • An HTML Include Facility
      • An RSS 2 Feed Creator
      • MIME Generation
      • A New Add-on Facility
      • Workspace Improvement Hack
    • Mockito for Suneido
    • The Suneido Task Scheduler
    • Contributing To Suneido
    • Contributor Assignment of Copyright
    • Language Translation
    • Future Directions
    • Interview With Andrew Mckinlay
  • Forum
    • Announcements
    • Internals & Enhancements
    • Cookbook
    • General
  • FAQ
  • Screenshots
  • Downloads
  • Links

Change background color of Editor Control

Integrated Application Platform › Forums › General › Change background color of Editor Control

  • This topic has 4 replies, 3 voices, and was last updated 10 years ago by gmauro.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • March 2, 2013 at 11:47 am #747
    mauro-g
    Participant

    Hi, there is a way to change the background color of an EditorControl ?
    For example:

    w1 = Window(#(Vert (Editor font: “Verdana” size: 16 readonly:true)))
    w1.Vert.Editor.Set(“Hello”)

    Could I change the usual gray color of the background read-only window?

    March 4, 2013 at 3:20 pm #966
    j_ferguson
    Moderator

    Yes, there is a method for EditorControl to do that, but when readonly, it looks like the gray color overrides any background color that you set, so it only seems to work when the readonly option is turned off.

    // works with the readonly option commented
    w1 = Window(Object(‘Vert’ Object(‘Editor’ font: “Verdana” size: 16 /*readonly:true*/)))
    w1.Vert.Editor.Set(“Hello”)
    w1.Vert.Editor.SetBgndColor(RGB(50,50,255))

    March 6, 2013 at 12:59 pm #967
    gmauro
    Participant

    Thank you! After some research I discovered that if you catch the CTLCOLORSTATIC message, you can change the readonly background color too!

    So, if you add something like this to the EditControl:

    CTLCOLORSTATIC(wParam)
    {
    if .textcolor isnt ""
    SetTextColor(wParam, .textcolor)
    SetBkColor(wParam, .color)
    return .brush
    }

    SetBgndColor(…) will change the background even if the control is read-only! 🙂

    Now my problem is that if you use that code, then the readonly background color will always be the same of the not-readonly window…

    March 6, 2013 at 3:22 pm #968
    j_ferguson
    Moderator

    I suppose you could add a method SetReadOnlyBgndColor to EditControl that would behave similarly to SetBgndColor except its color and brush would be used in the CTLCOLORSTATIC message. Then you could have different colors for both states.

    March 6, 2013 at 6:15 pm #969
    gmauro
    Participant

    Yes, I have modified EditControl in this way:

    in the New method you must replace:

    New(mandatory = false, readonly = false, style = 0, bgndcolor = "",
    textcolor = "", hidden = false, tabover = false)
    {
    ...
    ...
    if Object?(bgndcolor)
    bgndcolor = RGB(bgndcolor[0], bgndcolor[1], bgndcolor[2])
    .SetBgndColor(bgndcolor)
    if Object?(textcolor)
    textcolor = RGB(textcolor[0], textcolor[1], textcolor[2])
    .textcolor = textcolor
    }

    with this:

    New(mandatory = false, readonly = false, style = 0,  hidden = false, tabover = false
    bgndcolor = "", textcolor = "", bgndcolor_readonly = "", textcolor_readonly = "")
    {
    ...
    ...
    if Object?(bgndcolor)
    bgndcolor = RGB(bgndcolor[0], bgndcolor[1], bgndcolor[2])
    .SetBgndColor(bgndcolor)
    if Object?(bgndcolor_readonly)
    bgndcolor_readonly = RGB(bgndcolor_readonly[0], bgndcolor_readonly[1], bgndcolor_readonly[2])
    if (bgndcolor_readonly == "")
    .SetReadOnlyBgndColor(RGB(240, 240, 240))
    else
    .SetReadOnlyBgndColor(bgndcolor_readonly)
    if Object?(textcolor)
    textcolor = RGB(textcolor[0], textcolor[1], textcolor[2])
    .textcolor = textcolor
    if Object?(textcolor_readonly)
    textcolor_readonly = RGB(textcolor_readonly[0], textcolor_readonly[1], textcolor_readonly[2])
    .textcolor_readonly = textcolor_readonly
    }

    Then you have to add these methods:

    SetReadOnlyBgndColor(color)
    {
    .bgndcolor_readonly = color is "" ? RGB(240, 240, 240) : color
    .bgndbrush_readonly = color is "" ? GetStockObject(SO.WHITE_BRUSH) : CreateSolidBrush(color)
    .color_readonly = .bgndcolor_readonly
    .brush_readonly = .bgndbrush_readonly
    .Repaint()
    }
    CTLCOLORSTATIC(wParam) //this is for the readonly case
    {
    if .textcolor_readonly isnt ""
    SetTextColor(wParam, .textcolor_readonly)
    SetBkColor(wParam, .color_readonly)
    return .brush_readonly
    }

    With these mods, you can do something like:

    w1 = Window(#(Vert (Editor font: “Verdana” size: 16 readonly: false)))
    w1.Vert.Editor.Set(“Hello”)
    w1.Vert.Editor.SetBgndColor(RGB(255,0,0))
    w1.Vert.Editor.SetReadOnlyBgndColor(RGB(0,255,0))

    w1.Vert.Editor.SetReadOnly(true) // <-- this will make the editor readonly and the background green w1.Vert.Editor.SetReadOnly(false) // <-- this will make the editor editable and the background red

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

Search Forums

Log In
Welcome to the new Suneido Web Site and Forum.
Register
Lost Password
users of the previous PHPBB Forum should be able to log in with their previous username and password.

Recent Topics

  • Alpha copy of gSuneido to play with
  • how to start jsuneido ?
  • Problem Starting Suneido…
  • Dialog not showing buttons
  • New link for Suneidojo

Contact Us | Legal Statement | Privacy Statement | SiteMap

Copyright © 2023 Axon® Development Corporation. All Rights Reserved. - Open Source Integrated Database and Programming Language