Silverfrost Forums

Welcome to our forums

Dynamic color highlighting of controls

6 Mar 2015 8:39 #15818

I tried to use dynamic highlighting of different controls (it's very good reminder/warning/help) but succeeded only with radiobuttons. Here is text example with GUI and callback which changes colors. Click on radiobutton and see that it works OK. But changing number to 10 should change its background color but it does not. Buttons also do not change colors. Am i wrong with something?

use clrwin 
common lcRb, krb, lcButton, Number, lcNumber
integer, external ::  cbChng 

krb    = 0
Number = 9	

i=winio@('%ww&') 
i=winio@('Highlight rb %ta%^rb[HighLight me]%lc%ff&', krb, cbChng, lcRb) 
i=winio@('Highlight if >10 %ta%dd%6^rd%lc%ff&',1, Number, cbChng, lcNumber)
i=winio@('%cn%^bt[Highlight Button]%lc %bt[Exit]&', cbChng, lcButton)
i=winio@('%ac[esc]','exit') 
end 

integer function cbChng() 
use clrwin 
common lcRb, krb, lcButton, Number, lcNumber

if(krb.eq.0)  icolRb = RGB@(255,255,255) 
if(krb.eq.1)  icolRb = RGB@(255,190,255) 
call set_control_back_colour@(lcRb,    icolRb) 

if(Number.lt.10) icolNumber = RGB@(255,255,255) 
if(Number.ge.10) icolNumber = RGB@(255,190,255) 
call set_control_back_colour@(lcNumber,icolNumber) 

call set_control_back_colour@(lcButton,icolRb) 

cbChng=2 
end function
6 Mar 2015 1:21 #15821

set_control_back_colour@ does not work for %bt which has its own mechanism...

winapp
integer RGB@,winio@
integer bcol,green
common  bcol,green
integer,external::cb
green = 255
bcol = RGB@(255,green,255)
i = winio@('%`bc&', bcol)
i = winio@('%^bt[Change]', cb)
end

integer function cb()
integer bcol,green
common  bcol,green
integer RGB@
green = 255 - green
bcol = RGB@(255,green,255)
cb = 1
end 
6 Mar 2015 9:47 #15823

Thanks, i knew this way of coloring for buttons, but did not know that it updatable. Also i supposed that set_control_back_colour@ changes colors of any control as its name says. Will it do that for all controls in the future?

And how about %rd/%rf

7 Mar 2015 7:17 #15825

Dan

Some questions are best answered by trial and error. set_control_back_colour@ does not work for %bt and that will not change because %bt is a native ClearWin+ button that has its own paint. Other native ClearWin+ controls may have a similar limitation.

My guess is that %rd and %rf will respond to set_control_back_colour@ (the documentation may have something to say on this).

If you find a control does not respond and you need it to, then please let me know and I will see what can be done.

7 Mar 2015 11:42 #15826

Paul, Yes, the example above exactly demonstrates that background color of %rd is not changing while documentation as i understand it says it should. Do you see different behavior?

7 Mar 2015 3:27 #15833

Seems to work OK...

winapp
integer i,num,hwnd,winio@
integer,external::cb
common hwnd
num = 0
i = winio@('%rd&', num)
i = winio@('%lc&', hwnd)
i = winio@('%nl%cn%^bt[Change]', cb)
end

integer function cb()
include <windows.ins>
logical grey
integer hwnd,colour
common hwnd
save grey
data grey/.FALSE./
if(grey)then
  colour = RGB@(255,255,255)
else
  colour = RGB@(180,180,180)
endif
grey = .NOT.grey    
call set_control_back_colour@(hwnd, colour)
cb = 2
end 
8 Mar 2015 12:12 #15839

Thanks, Paul. Took me an hour to find where the problem is even knowing after your post that somehow it should work. And the reason is in %lc or %dd. If i change one your line to

 i = winio@('%dd%rd&', 1, num) 

adding just %dd it stops working

8 Mar 2015 7:21 #15840

OK. I will fix that so that it will work with the next release.

Please login to reply.