|
Post by sarossell on Dec 15, 2019 9:49:47 GMT -5
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?
Thanks!
:@)
|
|
|
Post by Rod on Dec 15, 2019 11:04:32 GMT -5
On my iPhone but the solution is to show and hide controls preset with colours. Will try to find an example.
|
|
|
Post by Rod on Dec 15, 2019 11:11:51 GMT -5
If the error condition was in a textbox then relatively easy to swap one for another. Whole window swap with statictext I would need check out some more.
'set the foreground and background colors 'these apply to the window and all controls BackgroundColor$ = "darkblue" ForegroundColor$ = "black" WindowWidth = 550 WindowHeight = 410 'override the BackgroundColor$ for the textbox TextboxColor$ = "red" textbox #main.textbox1, 30, 20, 100, 20 TextboxColor$ = "blue" textbox #main.textbox2, 30, 60, 100, 20 TextboxColor$ = "yellow" textbox #main.textbox3, 30, 100, 100, 20 TextboxColor$ = "green" textbox #main.textbox4, 30, 100, 100, 20 button #main.button,"Click Me", [clicked],UL,30, 140,100,20 open "untitled" for dialog as #main #main "trapclose [quit]" 'hide the fourth textbox #main.textbox4 "!hide" [main.inputLoop] 'wait here for input event wait
[clicked] 'toggle hidden graphicbox if clicked then #main.textbox3 "!hide" #main.textbox4 "!show" #main.textbox4 "!setfocus" clicked=0 else #main.textbox4 "!hide" #main.textbox3 "!show" #main.textbox3 "!setfocus" clicked=1 end if wait
[quit] close #main end
|
|
|
Post by Rod on Dec 15, 2019 11:28:42 GMT -5
Possible but it brings with it complications of two sets of controls.
nomainwin BackgroundColor$ = "blue" ForegroundColor$ = "white" statictext #example0.label0, "Now close the window!!", 10, 10, 200, 25 open "Demonstrate trapclose" for window as #example0 #example0 "trapclose [branch]"
BackgroundColor$ = "green" ForegroundColor$ = "red" statictext #example1.label1, "Now close the window!!", 10, 10, 200, 25 open "Demonstrate trapclose" for window as #example1 #example1 "trapclose [branch]"
#example1 "hide"
timer 1500,[error] wait
[error] timer 0 #example0 "hide" #example1 "show"
wait
[branch] close #example0 close #example1 end
|
|
|
Post by sarossell on Dec 15, 2019 11:52:50 GMT -5
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!
|
|
|
Post by Rod on Dec 15, 2019 13:17:05 GMT -5
Well relocate or resize the window to a pixel or off screen. But we are getting beyond workround. Strategy rethink required.
|
|
|
Post by sarossell on Dec 15, 2019 16:21:03 GMT -5
Well relocate or resize the window to a pixel or off screen. But we are getting beyond workround. Strategy rethink required. You've given me much food for thought. Thanks again!
|
|
|
Post by mknarr on Dec 15, 2019 17:31:16 GMT -5
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
|
|
|
Post by sarossell on Dec 15, 2019 19:26:54 GMT -5
mknarrClever. I don't know why I never thought of using two controls in the same place to show transition like that. Very cool. Thanks!
|
|
|
Post by Rod on Dec 16, 2019 3:12:47 GMT -5
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.
nomainwin WindowWidth = 550 WindowHeight = 410 graphicbox #main.bac, 0,0,550,410 TextboxColor$ = "red" textbox #main.textbox1, 30, 70, 100, 20 TextboxColor$ = "blue" textbox #main.textbox2, 30, 110, 100, 20 TextboxColor$ = "yellow" textbox #main.textbox3, 30, 150, 100, 20 button #main.button,"Click Me", [clicked],UL,30, 190,100,20 open "untitled" for window as #main #main "trapclose [quit]" #main.bac "fill white " #main.bac "font comic_sans 24 ; color black ;place 30 50;\The Text" #main.bac "flush main"
timer 2000,[alarm] wait
[alarm] timer 0 #main.bac "delsegment main" #main.bac "fill red; backcolor red ;color yellow;place 30 50;\The Text" #main.bac "flush main" wait
[clicked] notice "I worked" wait
[quit] close #main end
|
|
|
Post by sarossell on Dec 16, 2019 4:54:31 GMT -5
RodWow! That's perfect. Thank you!!
|
|