Silverfrost Forums

Welcome to our forums

Missing something here

5 Dec 2017 12:12 #20936

I'm trying set the text and background colours of a button control. From the documentation, the following code 'should' work, but doesn't. It switches both the background and text colours back and forth.

!	winapp
    use mswin
    integer,external:: button6
    integer button_handle
    common/lc/button_handle
	i = winio@('%^bt[Ignore Data]&',button6)
    i = winio@('%lc',button_handle)  
	END 
	integer function button6()
    use mswin
    integer:: toggle=0
    integer button_handle
    common/lc/button_handle
    button6 = 1
    if(toggle.eq.0) then
	call set_control_text_colour@(button_handle,rgb@(255,0,0))
	call set_control_back_colour@(button_handle,rgb@(255,255,0))
	else
	call set_control_text_colour@(button_handle,rgb@(0,255,255))
	call set_control_back_colour@(button_handle,rgb@(0,0,255))
    endif
    toggle = mod(toggle+1,2)
    	print *,toggle
	return
	end

Obviously, I'm missing something. Setting the background color with a variable, then updating the variable to change the background works, but there's no equivalent for the text colour from what I see in the documentation.

5 Dec 2017 4:52 #20937

Paul or others may find why it does not work but a bit different method works fine

use mswin 
integer,external:: button6 

common/lc/ibt_textColor, ibt_bkgColor

  ibt_textColor=rgb@(255,255,255)
  ibt_bkgColor=rgb@(255,0,0)

i=winio@('%`bc%`bu%^bt[Ignore Data]%es', ibt_bkgColor, ibt_textColor, button6) 

END 
!...................................
integer function button6() 
use mswin 
integer:: toggle=0 
common/lc/ibt_textColor, ibt_bkgColor
save toggle

if(toggle.eq.0) then 
  ibt_textColor=rgb@(0,0,0)
  ibt_bkgColor =rgb@(222,222,0)
else 
  ibt_textColor=rgb@(255,255,255)
  ibt_bkgColor =rgb@(255,0,0)
endif 

call window_update@(ibt_textColor)
call window_update@(ibt_bkgColor)

toggle = mod(toggle+1,2) 
print *,toggle 

button6 = 2
end 
5 Dec 2017 5:27 #20940

Thanks, Dan. Works great.

5 Dec 2017 7:53 #20944

set_control_text_colour@ and set_control_back_colour@ work for %rd etc. but apparently not for %bt (even when combined with %bc).

5 Dec 2017 3:01 #20954

Thanks, Paul. Good to know.

Please login to reply.