Silverfrost Forums

Welcome to our forums

Listview+Button hangs

14 Jul 2011 6:56 #8562

The following application hangs when you click into one of the cells (starting the cell edit mode) and then directly click on the Cancel button. There is no reaction to this button click, debugging this turns out that the callback of the listview is called (end edit) but rather than the callback of the Cancel button the listview callback is executed again (with begin edit mode). This was reported for a Win7 system, verified on an XP 32bit installation, the test application was reduced out of a larger application on Win7/64bit.

winapp
program listbox
   implicit none
   integer, dimension(15)            :: selection
   character (len=18), dimension(16) ::lvdata
   integer                           :: view, i
   
   external cancel, callback
   
   selection = 0 
   view = 1 

   lvdata(1) = '|Head1|Head2|Head3'
   do i=2,16
     lvdata(i) = '|DataX|DataY|DataZ'
   enddo

   i = winio@ ('%^lv[edit_cells]&', 380,100, lvdata, 16, selection, view, callback)
   i = winio@ ('%ff%nl%cn%^8bt[Cancel]', cancel)
end program listbox

integer function cancel()
   implicit none 
   cancel=0
end function cancel

integer function callback()
   implicit none 
   callback = 2
end function callback
14 Jul 2011 11:28 #8566

You need

   integer cancel, callback 

in your program.

14 Jul 2011 2:52 #8568

Doesn't change a single bit regarding the hangup (==still doesn't call the cancel routine if the cell was being edited).

14 Jul 2011 4:02 (Edited: 14 Jul 2011 7:16) #8571

Paul,

Although the callback functions must be INTEGER*4, FTN95 works fine with the function names being defined only as EXTERNAL. I've often puzzled over this.

Eddie

14 Jul 2011 5:45 #8572

I assumed that 'hangs' meant an abnormal failure like an exception being raised or an unexpected termination.

If you are editing a cell then you could use a click somewhere else to end the edit. If you click over the Cancel button then you may need two clicks, one to end the edit and one to get the effect of the Cancel callback which is to close down the application (because of the zero return value).

If a callback function has the wrong return type then it may work but my guess is that the result will be unsafe.

15 Jul 2011 6:22 #8579

If you click over the Cancel button then you may need two clicks

That would be pretty bad but even that does NOT work.

If a callback function has the wrong return type then it may work but my guess is that the result will be unsafe.

The test example was stripped down as far as possible and the declaration you're pointing at was not required. But as noted for the reproducability of this bug it behaves the same with the declaration.

15 Jul 2011 8:47 #8580

OK. I can see the problem now and will aim to fix it.

15 Jul 2011 8:51 #8581

I tried your example and then modified it to give some more info. My program does not work for me either. After selecting some cells in the List_View, the CANCEL button no longer works ? I'm not sure why. You may need to provide a response to each of the call-back reasons My example might help identify the problem.

You may need a menu to provide access to the modified data ?

winapp 
program listbox 
   implicit none 
   character (len=27), dimension(16) :: lvdata 
   integer                           :: i 
!
   integer, dimension(16)            :: selection 
   integer callback_count, view
   common /zz/ callback_count, view, selection
!    
   integer  cancel, callback 
   external cancel, callback 
!
   callback_count = 0
   selection = 0 
   view = 1 
!
   lvdata(1) = '|Head1_80|Head2_80|Head3_80' 
   do i=2,15 
     lvdata(i) = '|DataX|DataY|DataZ' 
   enddo 
   lvdata(16) = ' ' 
!
   i = winio@ ('%^lv[edit_cells]&', 380,150, lvdata, 16, selection, view, callback) 
   i = winio@ ('%ff%nl%cn%^8bt[Cancel]', cancel) 
!
end program listbox 

integer function cancel() 
   implicit none 
   cancel=0 
end function cancel 

integer function callback() 
   implicit none 
!
   integer, dimension(16)            :: selection 
   integer callback_count, view
   common /zz/ callback_count, view, selection
!
   CHARACTER CLEARWIN_STRING@*30, ANSWER*30
   external  CLEARWIN_STRING@
!
   answer = CLEARWIN_STRING@ ('CALLBACK_REASON')
!
   callback_count = callback_count + 1   
   callback = 2 
   write (*,fmt='(a,20i2)') 'Sel = ',selection
   write (*,*) 'Callback entered :',answer,callback_count, view
!
end function callback
15 Jul 2011 12:30 #8582

OK. I can see the problem now and will aim to fix it.

Thank you!

You may need to provide a response to each of the call-back reasons

The callbacks are begin edit and end edit, no idea what response you'd create for them to magically get the cancel button to work...

17 Jul 2011 12:38 #8587

I am finding that CALLBACK is interupting a previous interrupt to CALLBACK, before the first is completed.

Should these interrupts be occuring so quickly ? Can the second interrupt be delayed until the first has completed ? Quicker exit from interrupts that require no response may help, but I think the problem would still remain.

I was not able to store changes to the cells so do you need more than a single %lv to get this to work properly with [edit_cells] ?

Just some ideas I thought may help. I'm sorry that I don't have the solution.

John

2 Aug 2011 8:06 #8681

I have started work on this problem but can nolonger get it to fail. Here is my test program which for me consistently requires just one click on Cancel. Can you retest this for me and supply a version that exhibits the problem.

winapp 
program listbox 
   implicit none 
   integer, dimension(15)            :: selection 
   character (len=18), dimension(16) ::lvdata 
   integer                           :: view, i 
   external cancel, callback 
   integer cancel, callback 
   selection = 0 
   view = 1 
   lvdata(1) = '|Head1|Head2|Head3' 
   do i=2,16 
     lvdata(i) = '|DataX|DataY|DataZ' 
   enddo 
   i = winio@ ('%^lv[edit_cells]&', 380,100, lvdata, 16, selection, view, callback) 
   i = winio@ ('%ff%nl%cn%^8bt[Cancel]', cancel) 
end program listbox 

integer function cancel()
integer k
save k
data k/0/
   k = k+1 
   print*, 'Cancel' ,k
   cancel=1 
end function cancel 

integer function callback() 
include <windows.ins>
character*80 reason
integer kk
save kk
data kk/0/
 kk = kk+1 
 reason = clearwin_string@('callback_reason');   
 print*, reason, kk
 callback = 2 
end function callback
3 Aug 2011 6:32 #8694

Here is my test program which for me consistently requires just one click on Cancel.

Fails on my system. First click on >Cancel< triggers an end edit+begin edit if the list view is in edit mode.

3 Aug 2011 11:32 #8707

I have now managed to fix this bug for the next release of salflibc.dll.

3 Aug 2011 12:27 #8710

Nice, thanks!

Please login to reply.