Author Topic: Label Background Colours  (Read 556 times)

0 Members and 1 Guest are viewing this topic.

Offline WilliGrundmann

  • Newbie
  • Posts: 4
Label Background Colours
« on: April 15, 2020, 03:44:04 AM »
Hi,

I am new to QB64 and InForm.

For a small project I would like to change the background color of a label depending on the data from the serial port. This needs to work without operator interaction.

I tried to do this via code in the __UI_BeforeUpdateDisplay subroutine.  However  Control(AlarmLabel).BackColor= _RGB32(x,y,z) changes the color only once. All following Control(AlarmLabel).BackColor= _RGB32(x,y,z) with a different color have no effect.

Is there another method to change the background color of a label at run time?


Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2712
  • LET IT = BE
    • QB64.org
Re: Label Background Colours
« Reply #1 on: April 15, 2020, 08:18:49 AM »
You can force redraw:

Code: QB64: [Select]
  1. Control(AlarmLabel).BackColor = _RGB32(x,y,z)
  2. Control(AlarmLabel).Redraw = True

Most redrawing is done based on certain detected changes. I don't recall if .BackColor is actively monitored.

And yes, best place for that is in __UI_BeforeUpdateDisplay.

Let me know if that does it, please.
« Last Edit: April 15, 2020, 09:06:04 AM by FellippeHeitor »

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2712
  • LET IT = BE
    • QB64.org
Re: Label Background Colours
« Reply #2 on: April 15, 2020, 08:40:26 AM »
...and welcome to QB64+InForm+the Forum :-)

Offline WilliGrundmann

  • Newbie
  • Posts: 4
Re: Label Background Colours
« Reply #3 on: April 15, 2020, 06:20:02 PM »
HI Phillippe,

Thank you very much for the advice. The background color works fine now.

Most of my programming is for embedded systems using Microchip processors. I do not get involved in PC based software very often. In the past I used QuickBasic and Visual Basic.

QB64 together with Inform may be a more efficient tool for small PC based applications.

Best Regards

Willi Grundmann