Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE drag & drop and checkbox
Message
From
13/08/2018 13:06:53
 
 
To
13/08/2018 05:48:06
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01661524
Message ID:
01661548
Views:
85
>>Wondering if anyone else has seen this. I'm working on my Drag and drop session for Southwest Fox and I just spent an hour or more down a rabbit hole.
>>
>>Just to demo how the various PEMs interact, I set up a checkbox as a drop target and added code so that if you dropped text on it, its caption would change. (Yeah, not all that relevant in real life, but a slick demo.) When I got it working, I found that the form would no longer close. Instead I got the error "File cannot be closed because outstanding references exist."
>>
>>I've tested using the form or a command button as the drop target and it works fine without the problem.
>>
>>Here's the set-up:
>>
>>1) Textbox has code in MouseDown that boils down to:
>>
>>
>>This.OLEDrag(.T.)
>>
>>
>>(That is, there's other code, but it's not relevant to this problem. I'm creating some generic classes to make it easier to create these demos.)
>>
>>2) Checkbox is set up as follows:
>>
>> Caption: Drop here
>> OLEDropMode: 1-Enabled
>>
>> DragOver contains:
>>
>>
>>IF oDataObject.GetFormat(1)
>>	This.OLEDropHasData = 1
>>	This.OLEDropEffects = 1
>>ENDIF 
>>
>>
>> DragDrop contains:
>>
>>
>>IF This.OLEDropHasData = 1
>>	LOCAL cTextData
>>	cTextData = oDataObject.GetData(1)
>>	IF NOT EMPTY(m.cTextData)
>>		This.Caption = m.cTextData
>>	ENDIF 
>>ENDIF 
>>
>>
>>To demo, I run the form, type something into the textbox, then highlight the text and drag it. When I drag over the checkbox, I see a copy icon, as expected. When I drop, the checkbox caption changes to the highlighted text. All great.
>>
>>Then, I try to close the form. I have a Close button on the form; does nothing. Ditto for the window's native close button. If I use the Design Mode button on the Standard toolbar, I get the error message I cited above. Closing the form requires CLEAR ALL.
>>
>>If I put the same code in the Form's OLEDragOver and OLEDragDrop methods, and set OLEDropMode to 1 for the form, no problem; the form caption changes and the form can close. Ditto if I add a command button and configure it the same way.
>>
>>Oh, one more thing. If I comment out the line that sets OLEDropHasData, it no longer changes the caption, but the form closes.
>>
>>So, anybody seen it before? Anybody able to replicate so I know I'm not nuts.
>>
>>Tamar
>
>Tested so far: not working behavior replicated on check boxes and radio buttons; working behavior observed on labels, text boxes, and edit boxes. Changing OLEDropHasData back to its default state does not seem to make any effect.
>
>Side note: I'm experimenting with prg based class. Editing the class source code and releasing the objects from memory at the IDE prompt successfully closes the form (no need to CLEAR ALL).

Thanks, all. Good to know it wasn't just me. I'll make sure I get the details into the paper.

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform