forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check boxes in list view control

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
wosl



Joined: 31 Jan 2008
Posts: 30

PostPosted: Mon May 03, 2010 9:18 pm    Post subject: Check boxes in list view control Reply with quote

Hello!

I've an issue with the list view control %`lv together with an array of check box states. The following sample code should check all boxes on and off through pressing the "Swap" button. The boxes can be selected but not deselected. Any suggestion what I did wrong?

Regards
Wosl

FTN95 version used: 5.50

Code:

      winapp
      program ListView
      implicit none
      include <windows.ins>
      integer i,iview,nmax,cswap
      parameter (nmax=10)
      character*2 c2
      character*16 info(0:nmax)
      integer isel(nmax),icheck(nmax)
      external cswap
      common icheck
      info(0) ='|Index_40|Value_80'
      do i=1,nmax
         isel(i)=0
         icheck(i)=0
         write (c2,'(i2)') i
         info(i)='|'//c2//'|Item '//c2
      end do
      isel(5)=1
      iview=1
      i=winio@('%ww%ca[ListView Test]&')
      i=winio@('%`lv[full_row_select,single_selection,'//
     +         'grid_lines,check_boxes]&',
     +         120L,210L,info,nmax+1,isel,iview,icheck)
      i=winio@(' %bt[&Cancel]%2nl %^bt[&Swap]',cswap)
      end
      integer function cswap ()
      implicit none
      integer i,nmax
      logical lsteu
      parameter (nmax=10)
      integer icheck(nmax)
      common icheck
      data lsteu/.true./
      do i=1,nmax
         if (lsteu)  then
            icheck(i)=1
         else
            icheck(i)=0
         end if
      end do
      lsteu=.not.lsteu
      cswap=1
      end
Back to top
View user's profile Send private message
JohnHorspool



Joined: 26 Sep 2005
Posts: 270
Location: Gloucestershire UK

PostPosted: Mon May 03, 2010 9:32 pm    Post subject: Reply with quote

Every time the function cswap is called the logical variable lsteu is assigned the value of true by the data statement. Giving it the inverse value at the end of the function achieves nothing, this assigned value is immediately lost.

lsteu should be in a common statement and only aasigned an initial value at the start of the program.
Back to top
View user's profile Send private message Visit poster's website
wosl



Joined: 31 Jan 2008
Posts: 30

PostPosted: Mon May 03, 2010 10:51 pm    Post subject: Reply with quote

Yes, correct ... I changed my call back function as follows (add save statement and window_update) and tested it in debug mode. The function works as expected (changing array icheck) but nevertheless the unselect still doesn't work!!

Wosl

Code:

      integer function cswap ()
      implicit none
      include <windows.ins>
      integer i,nmax
      logical lsteu
      parameter (nmax=10)
      integer icheck(nmax)
      common icheck
      data lsteu/.true./
      save lsteu
      do i=1,nmax
         if (lsteu)  then
            icheck(i)=1
         else
            icheck(i)=0
         end if
      end do
      lsteu=.not.lsteu
      call window_update@ (icheck)
      cswap=1
      end
Back to top
View user's profile Send private message
JohnHorspool



Joined: 26 Sep 2005
Posts: 270
Location: Gloucestershire UK

PostPosted: Mon May 03, 2010 11:32 pm    Post subject: Reply with quote

You have not implemented my suggestions!

lsteu remains local to cswap and it is still assigned the value of true by the data statement every time the function is called. Thus in the block if statement it is always true and icheck is always given the value one, it can never receive the value zero.
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon May 03, 2010 11:45 pm    Post subject: Reply with quote

John,

The data statement is only implemented at the start of the program, not on every call. The DATA statement also allocates the save attribute to the variable lsteu, so the SAVE is not required.
It should only be in a COMMON if it is required elsewhere in the program, or to be checked elsewhere.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Tue May 04, 2010 8:48 am    Post subject: Reply with quote

The problem is caused by a bug in ClearWin+ which I have fixed for the next release.

The call to window_update@ is not needed in this context (when the callback function returns 1).

I suspect that there is no easy work-around for this bug.
Back to top
View user's profile Send private message AIM Address
wosl



Joined: 31 Jan 2008
Posts: 30

PostPosted: Tue May 04, 2010 6:39 pm    Post subject: Reply with quote

Thank you for the answers! Now I'll stop my debugging and will wait for the next release.

Regards
Wosl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group