I got a request to alter the appearance of a window if certain conditions occurred. Basically, the program runs with a normal looking window with light grey background and black text. Statictext was chosen to display a condition message with a huge font. The problem is the condition message changes but sometimes it isn't noticed, so they want to change the background to black and the text color to red when the condition changes. The window has several other controls which is why statictext was chosen for the condition message.
I tried just changing the BackgroundColor$ and ForegroundColor$ wen the conditions occurred, but that didn't change anything. Then I tried making the color changes then hiding and showing the statictext control. That didn't work either. I also tried resizing the window and even tried to use maphandle to change the window handle in an attempt to "trigger" the color change. Nothing worked until I finally just closed the window, changed the colors and condition text, and re-opened the window. This had the added benefit of the window doing a more noticeable "wiggle". Unfortunately, they also use a monitoring program that tracks running programs by their window title. And the moment the window closes, they get an alert that the app has "crashed".
So, my my question is, is there a more elegant solution?
Yeah, my temporary solution was to put all of the controls in a single subroutine with a couple of if..then choices so I could just pass the conditions to the sub. I hadn't considered just hiding the second window instead of closing the first. Your solution is much smoother. Unfortunately, it still triggers their crash monitor because it thinks the window closed instead of just hiding. Gives me some ideas though. Thanks!
Here is something I do in a program. When a person makes an entry the text box with the information changes and so does the color of the text box. This is only part of the whole code but it demonstrates how I draw attention to the fact that they made a change. I disable the textbox so no one can enter date in it.
nomainwin WindowWidth = 800 WindowHeight=600 TextboxColor$="cyan" textbox #entrylist.tb1,425,15,160,20 'cyan Number of entries. TextboxColor$="yellow" textbox #entrylist.tb2,425,15,160,20 'yellow Number of entries button #entrylist.b1, "Toggle", [Change],UL, 300, 400, 100,50 open "Entry List Edit" for window as #entrylist activetextbox=2 #entrylist.tb1, "Yellow" #entrylist.tb2, "!hide" #entrylist.tb1, "!show" #entrylist.tb1, "!disable" #entrylist.tb1, "Cyan"
[Change] select case activetextbox case 1 #entrylist.tb1, "Cyan" #entrylist.tb1, "!hide" #entrylist.tb2, "!show" #entrylist.tb2, "!disable" activetextbox=2 case 2 #entrylist.tb2, "Yellow" #entrylist.tb2, "!hide" #entrylist.tb1, "!show" #entrylist.tb1, "!disable" activetextbox=1 end select wait
Having thought a little more I would try this. Create a graphicbox the size of the window and draw your background color and coloured text too it. Then create your other controls. If the Z order is correct most controls will work over the top of the graphicbox. Statictext wont. It isn’t an approved method but I have seen it used.