Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to refresh a screen with a new background color

Status
Not open for further replies.

Foxtrotter

IS-IT--Management
Jan 5, 2011
57
US
Hey guys, I'm sure this is something really simple but I have not yet figured out how to change the background color of my screen and then refresh the screen so that the new color is in effect. The goal is that when a certain event happens, I need the background of this particular screen to change to a new color (yet to be decided). By the way, the screen color is set to automatic which currently is displaying as white.

I can change the normally white background color to gray using set color of scheme 1 to RGB(0,0,0,192,192,192) but it doesn't change until I exit out of the screen and go back in. I have tried modify window color, show window, activate window etc. but that doesn't seem to do it.

Like, I said, I'm sure it's something simple but please tell me as I'm about to lose my mind. I thought this would be simple!
 
No, it's not that simple at all. Once a "screen" is painted, it's a static object. The only way to change its appearance is to recreate it.

You'd have to terminate the current READ and re-run the SPR.
 
Wow. I believe I'll rethink the objective a bit then.

Thanks Danfreeman!
 
Hello,
Try the following:-

SET COLOR TO rgb(000,000,000,150,150,150)
CLEAR

This should produce a grey screen.

 
Hi philthoms,

That does indeed change the background of the screen but it wipes out all labels and gets. If you issue a show gets it will redraw the gets but not the labels/lines/rectangles etc. I don't know how to get it to completely redraw the screen other than doing what danfreeman suggested.
 
In theory it's not all that tough.

Code:
glQuitting = .f.
Do While Not glQuitting
   Do your.spr
Enddo

When the condition occurs that you want to change colors, change colors, CLEAR READ and the loop will re-run the spr. When it's time to exit, set glQuitting = .t. and CLEAR READ.

Of course, it's up to you to maintain state. All of the variables need to be created outside the spr where many of us did that in the setup code inside the screen.

There is one other esoteric option. Because of the way the screen generator generates code, you can put the DO WHILE as the last code of setup, and the ENDDO as the first line of cleanup. The generated code will tack together the pieces to make the gets/READ a complete program inside a loop.
 
I have considered that but in this particular screen it is reading data from a bunch of different sources with list boxes etc and I will have to maintain state during the "Refresh". It could be done but luckily they have decided I can just put a large title field on each of the screens and change the background of that field instead. Much easier to do.

Thanks for all the suggestions though.

 
It always helps when they change requirements. ;-)

But just to make sure you understood that last suggestion, putting DO WHILE at the end of setup code and ENDDO at the beginning of cleanup code, only the SAY/GET/READ would be inside the loop. The variables wouldn't go out of scope and wouldn't change value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top