Silverfrost Forums

Welcome to our forums

%cw – forget user selected text

29 Dec 2020 5:21 #26843

A simple question, but I cannot find an answer scanning the documentation.

When writing tabular data to a %cw the user can highlight parts of the text. If more lines are then written to the %cw, the new text at the position previously highlighted remains highlighted. Is there a way to prevent this happening, so that none of the new data is highlighted?

The image in the link below shows a highlighted row of data (which the user has copied to another application). When the filter selections are changed and the %cw is updated with new data I would like the 4th row of the data to lose its highlighted status. Is this possible?

https://www.dropbox.com/s/93szdr5xmklwf39/query.jpg?dl=0

29 Dec 2020 10:05 #26846

Ken

I haven't time to test this but here are the components of a call that should work...

C_EXTERNAL CANCEL_SELECTION@ '__cancel_selection'(VAL7)
integer(7) hwnd
iw = winio@('%`30.20cw', 10, hwnd)
write(10,*) 'Testing'
call CANCEL_SELECTION@(hwnd)
29 Dec 2020 11:46 #26847

Thank you Paul, that works perfectly ........

program demo
implicit none
integer iw, m_unit, t_unit
integer, external :: new_data_cb
integer(7) handle_top, handle_main
common m_unit, t_unit, handle_top, handle_main
    m_unit = 30
    t_unit = 40
    iw = winio@('%fn[Consolas]&')
    iw = winio@('%`bg%`30.2cw[local_font]&',rgb@(240,240,240),t_unit,handle_top)
    iw = winio@('%ff%ac[Ctrl+C]&', 'COPY')
    iw = winio@('%cm[Copy]&', 'COPY')
    iw = winio@('%`bg[white]%`30.20cw[vscroll,local_font]&',m_unit,handle_main)
    iw = winio@('%ta%^bt[New_data_1]&',new_data_cb)
    iw = winio@('%sc&', new_data_cb)
    iw = winio@(' ')
end program demo

integer function  new_data_cb()
use clrwin
implicit none
C_EXTERNAL CANCEL_SELECTION@ '__cancel_selection'(VAL7)
integer i
integer m_unit, t_unit
integer(7) handle_top, handle_main
logical :: first=.true.
character(len=28), parameter :: fmt1 = '('    Id   XXXXXX   YYYYYY')'
character(len=35), parameter :: fmt2 = '('-----------------------------')'
character(len=24), parameter :: fmt3 = '(3X,I3,3X,F6.2,3X,F6.2)'
common  m_unit, t_unit, handle_top, handle_main
  if (first) then
    call SET_MAX_LINES@(handle_main,101)
    write(t_unit,fmt1)
    first = .false.
  end if 
  call CANCEL_SELECTION@(handle_top)       !### Clears any user selected text in both %cw areas
  call CANCEL_SELECTION@(handle_main)      !###
  write(m_unit,fmt2)
  do i = 1, 100
    write(m_unit,fmt3) i, 100.d0*random@(), random@()
  end do
  new_data_cb = 2
end function new_data_cb
30 Dec 2020 7:10 #26848

I will add this routine to clearwin.ins etc. so the special interface will only be temporary.

Please login to reply.