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 

Drag and Drop callback behavior

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



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sun Apr 25, 2021 3:39 pm    Post subject: Drag and Drop callback behavior Reply with quote

I use Drap-and-drop in several areas, and it works great, allowing me to drag large numbers of files for processing. I "ingest" the files and add them to a list, then rebuild the list-view. No problems

I ran across this as I added a functionality. In this new application, I want to take a dropped file, add it to an internal list, then rebuild the display using the rebuilt list. I do this because it will be rare for the user to be using this feature, so be building the display window with the updated list is not a big deal.

But I can't do it. When I attempt to return a negative value for the callback, it is "ignored" (more later). The code below illustrates this. Two variables, one counting the number of "drops", the other counting the rebuilds. On every third drop, it attempts to return a -1. It does not rebuild the window, and more oddly, the window is not updated. Click the "X" to close the window, and it gets rebuilt using the proper return value!

So, attempting to return from a drag-and-drop callback with the return value to also closes the parent window fails. But a manual closing of that window returns the previous attempts callback value, and the window is rebuilt.

This occurs both in 32 and 64 bit

Code:
   winapp
        program main
        use mswin
        integer,external:: dropped_here
   integer:: i,count_rebuild,count_dropped
        common/dr/count_rebuild,count_dropped
        count_dropped = 0
        count_rebuild = 0
1000   continue
   i = winio@('%ww%ca[DropTest]&')
        i = winio@('%dr&',dropped_here)
        i = winio@('Num rebuild %`rd&',count_rebuild)
        i = winio@('Num FOund %`rd&',count_dropped)
        i = winio@(' ')
        if(i.eq.1)then
          count_rebuild = count_rebuild + 1
          go to 1000
        endif
        end
        integer function dropped_here()
   use mswin
   integer:: count_rebuild,count_dropped
        common/dr/count_rebuild,count_dropped
   character*260:: dropped_file
        dropped_file = clearwin_string@('dropped_file')
        dropped_here = 1
        count_dropped = count_dropped + 1
        if(mod(count_dropped,3).eq.0)dropped_here = -1
        return
        end
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 26, 2021 7:43 am    Post subject: Reply with quote

Bill

I am not sure what you are aiming for but this might help...

Code:
        program main
        use mswin
        integer,external:: dropped_here
        integer:: i,count_rebuild,count_dropped,ictrl
        integer(7) hwnd
        common/dr/count_rebuild,count_dropped,hwnd,ictrl
        count_dropped = 0
        count_rebuild = 0
1000    continue
        ictrl = 0
        i = winio@('%ww%ca[DropTest]&')
        i = winio@('%dr&',dropped_here)
        i = winio@('Num rebuild %`rd&',count_rebuild)
        i = winio@('Num Found %`rd&',count_dropped)
        i = winio@('%es&')
        i = winio@('%hw',hwnd)
        if(ictrl == 1) go to 1000
        end
       
        integer function dropped_here()
        use mswin
        integer:: count_rebuild,count_dropped,ictrl
        integer(7) hwnd
        common/dr/count_rebuild,count_dropped,hwnd,ictrl
        character*260:: dropped_file
        logical L
        dropped_file = clearwin_string@('dropped_file')
        dropped_here = 1
        count_dropped = count_dropped + 1
        icurrent = clearwin_info@("DROPPED_CURRENT")
        icount   = clearwin_info@("DROPPED_COUNT")
        print*, icurrent, icount, "    ", trim(dropped_file)
        if(icurrent == icount) then
          ictrl = 1
          L = DestroyWindow(hwnd)
        endif 
        end function
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Mon Apr 26, 2021 4:03 pm    Post subject: Reply with quote

Paul, thanks for the suggestion.

I implemented it into my production code. It does work as I had intended.

Perhaps the documentation could be altered to indicate that closing the parent window by returning a negative value is not available?

Again, thanks for the solution!
Bill
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 26, 2021 5:44 pm    Post subject: Reply with quote

Bill

On reflection, I need to check that DestroyWindow does everything that needs doing when closing a ClearWin+ window.

The documentation will need ammending but only in the context of a %dr callback function.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Mon Apr 26, 2021 7:13 pm    Post subject: Reply with quote

Paul, thanks for the confirmation re: documentation. Sometimes, the hardest part o keep concise, yet complete.

It is amazing that before I saw your message, I was sitting here thinking about what happens to stacks, etc. if the parent window is closed BEFORE the callback is actually complete. If there is an issue, I have an alternative method that doesn't require the closing of the parent window. It is not as intuitive as what I have working right now, but it can work well (I already use this technique elsewhere). I'll keep my ears open for what you discover.

Thanks,
Bill
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Tue Apr 27, 2021 7:19 am    Post subject: Reply with quote

Bill

Here is my revised sample. SendMessage with WM_CLOSE is better than DestroyWindow. I haven't used count_rebuild. Any processing based on the file name could be carried out within the callback function.

Code:
        program main
        integer,external::dropped_here
        integer:: i,count_rebuild,count_dropped,ictrl
        common count_dropped,ictrl
        count_dropped = 0
        count_rebuild = 0
        do
         ictrl = 0
         i = winio@('%ww%ca[DropTest]&')
         i = winio@('%dr&',dropped_here)
         i = winio@('Num rebuild %`rd&',count_rebuild)
         i = winio@('Num Found %`rd&',count_dropped)
         i = winio@(' ')
         if(ictrl == 0) exit
        end do 
        end
       
        integer function dropped_here()
        use mswin
        integer(7) hwnd
        character*260::dropped_file
        integer count_dropped,ictrl
        common count_dropped,ictrl
        dropped_file  = clearwin_string@('DROPPED_FILE')
        icurrent      = clearwin_info@("DROPPED_CURRENT")
        count_dropped = clearwin_info@("DROPPED_COUNT")
        hwnd          = clearwin_info@("CALL_BACK_WINDOW")
        print*, icurrent, "    ", trim(dropped_file)
        if(icurrent == count_dropped) then
          ictrl = 1
          i = SendMessage(hwnd,WM_CLOSE,0,0)
        endif 
        dropped_here = 2
        end function
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Apr 27, 2021 6:47 pm    Post subject: Reply with quote

Thanks, Paul, this is most helpful!!
Back to top
View user's profile Send private message Visit poster's website
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