mirror of
https://github.com/Rayerd/dfl.git
synced 2025-04-25 20:49:58 +03:00
FIX: Don't call Control.allowDrop in MyForm.this().
This commit is contained in:
parent
3774206908
commit
a9524bc196
2 changed files with 34 additions and 17 deletions
|
@ -36,10 +36,7 @@ class MainForm : Form
|
|||
}
|
||||
else
|
||||
{
|
||||
this.load ~= (Control sender, EventArgs e) {
|
||||
// TODO: Currently it must be set after the handle is created.
|
||||
this.allowDrop = true;
|
||||
};
|
||||
this.allowDrop = true;
|
||||
this.dragEnter ~= (Control sender, DragEventArgs e) {
|
||||
// Do nothing
|
||||
};
|
||||
|
@ -72,6 +69,7 @@ class MainForm : Form
|
|||
{
|
||||
_label.text = _label.text ~ fileName ~ "\n";
|
||||
}
|
||||
this.allowDrop = false; // Example: Accept only once.
|
||||
};
|
||||
this.dragLeave ~= (Control sender, EventArgs e) {
|
||||
// Do nothing
|
||||
|
|
|
@ -1057,7 +1057,7 @@ class Control: DObject, IWindow // docmain
|
|||
version(DFL_NO_DRAG_DROP) {} else
|
||||
{
|
||||
///
|
||||
@property void allowDrop(bool byes) // setter
|
||||
private void allowDropImplement(bool byes)
|
||||
{
|
||||
/+
|
||||
if(dyes)
|
||||
|
@ -1070,9 +1070,9 @@ class Control: DObject, IWindow // docmain
|
|||
{
|
||||
if(!droptarget)
|
||||
{
|
||||
droptarget = new DropTarget(this);
|
||||
if(isHandleCreated)
|
||||
{
|
||||
droptarget = new DropTarget(this);
|
||||
switch(RegisterDragDrop(hwnd, droptarget))
|
||||
{
|
||||
case S_OK:
|
||||
|
@ -1090,11 +1090,32 @@ class Control: DObject, IWindow // docmain
|
|||
}
|
||||
else
|
||||
{
|
||||
destroy(droptarget); // delete is deprecated.
|
||||
RevokeDragDrop(hwnd);
|
||||
if(droptarget)
|
||||
{
|
||||
destroy(droptarget); // delete is deprecated.
|
||||
droptarget = null;
|
||||
switch(RevokeDragDrop(hwnd))
|
||||
{
|
||||
case S_OK:
|
||||
break;
|
||||
case DRAGDROP_E_NOTREGISTERED:
|
||||
case DRAGDROP_E_INVALIDHWND:
|
||||
case E_OUTOFMEMORY:
|
||||
throw new DflException("Unable to revoke drag-drop");
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@property void allowDrop(bool byes) // setter
|
||||
{
|
||||
_allowDrop = byes;
|
||||
allowDropImplement(_allowDrop);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
@property bool allowDrop() // getter
|
||||
{
|
||||
|
@ -1102,7 +1123,7 @@ class Control: DObject, IWindow // docmain
|
|||
return (_exStyle() & WS_EX_ACCEPTFILES) != 0;
|
||||
+/
|
||||
|
||||
return droptarget !is null;
|
||||
return _allowDrop;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4575,14 +4596,11 @@ class Control: DObject, IWindow // docmain
|
|||
|
||||
version(DFL_NO_DRAG_DROP) {} else
|
||||
{
|
||||
if(droptarget)
|
||||
{
|
||||
if(S_OK != RegisterDragDrop(hwnd, droptarget))
|
||||
{
|
||||
droptarget = null;
|
||||
throw new DflException("Unable to register drag-drop");
|
||||
}
|
||||
}
|
||||
// Need to do "allowDrop = true/false" after created handle.
|
||||
// When do "allowDrop = true" in MyForm.this(),
|
||||
// Now is _allowDrop == true and droptarget is null.
|
||||
// Therefore call here allowDropImplement() without change _allowDrop value.
|
||||
allowDropImplement(_allowDrop);
|
||||
}
|
||||
|
||||
debug
|
||||
|
@ -7165,6 +7183,7 @@ class Control: DObject, IWindow // docmain
|
|||
version(DFL_NO_DRAG_DROP) {} else
|
||||
{
|
||||
DropTarget droptarget = null;
|
||||
bool _allowDrop = false;
|
||||
}
|
||||
|
||||
// Note: WS_VISIBLE is not reliable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue