View previous topic :: View next topic |
Author |
Message |
wosl
Joined: 31 Jan 2008 Posts: 30
|
Posted: Mon May 03, 2010 9:18 pm Post subject: Check boxes in list view control |
|
|
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 |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Mon May 03, 2010 9:32 pm Post subject: |
|
|
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 |
|
|
wosl
Joined: 31 Jan 2008 Posts: 30
|
Posted: Mon May 03, 2010 10:51 pm Post subject: |
|
|
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 |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Mon May 03, 2010 11:32 pm Post subject: |
|
|
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 |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon May 03, 2010 11:45 pm Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Tue May 04, 2010 8:48 am Post subject: |
|
|
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 |
|
|
wosl
Joined: 31 Jan 2008 Posts: 30
|
Posted: Tue May 04, 2010 6:39 pm Post subject: |
|
|
Thank you for the answers! Now I'll stop my debugging and will wait for the next release.
Regards
Wosl |
|
Back to top |
|
|
|