mirror of
https://github.com/Rayerd/dfl.git
synced 2025-04-26 04:59:55 +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
|
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) {
|
this.dragEnter ~= (Control sender, DragEventArgs e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
};
|
};
|
||||||
|
@ -72,6 +69,7 @@ class MainForm : Form
|
||||||
{
|
{
|
||||||
_label.text = _label.text ~ fileName ~ "\n";
|
_label.text = _label.text ~ fileName ~ "\n";
|
||||||
}
|
}
|
||||||
|
this.allowDrop = false; // Example: Accept only once.
|
||||||
};
|
};
|
||||||
this.dragLeave ~= (Control sender, EventArgs e) {
|
this.dragLeave ~= (Control sender, EventArgs e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|
|
@ -1057,7 +1057,7 @@ class Control: DObject, IWindow // docmain
|
||||||
version(DFL_NO_DRAG_DROP) {} else
|
version(DFL_NO_DRAG_DROP) {} else
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
@property void allowDrop(bool byes) // setter
|
private void allowDropImplement(bool byes)
|
||||||
{
|
{
|
||||||
/+
|
/+
|
||||||
if(dyes)
|
if(dyes)
|
||||||
|
@ -1070,9 +1070,9 @@ class Control: DObject, IWindow // docmain
|
||||||
{
|
{
|
||||||
if(!droptarget)
|
if(!droptarget)
|
||||||
{
|
{
|
||||||
droptarget = new DropTarget(this);
|
|
||||||
if(isHandleCreated)
|
if(isHandleCreated)
|
||||||
{
|
{
|
||||||
|
droptarget = new DropTarget(this);
|
||||||
switch(RegisterDragDrop(hwnd, droptarget))
|
switch(RegisterDragDrop(hwnd, droptarget))
|
||||||
{
|
{
|
||||||
case S_OK:
|
case S_OK:
|
||||||
|
@ -1089,11 +1089,32 @@ class Control: DObject, IWindow // docmain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if(droptarget)
|
||||||
{
|
{
|
||||||
destroy(droptarget); // delete is deprecated.
|
destroy(droptarget); // delete is deprecated.
|
||||||
RevokeDragDrop(hwnd);
|
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
|
/// ditto
|
||||||
@property bool allowDrop() // getter
|
@property bool allowDrop() // getter
|
||||||
|
@ -1102,7 +1123,7 @@ class Control: DObject, IWindow // docmain
|
||||||
return (_exStyle() & WS_EX_ACCEPTFILES) != 0;
|
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
|
version(DFL_NO_DRAG_DROP) {} else
|
||||||
{
|
{
|
||||||
if(droptarget)
|
// Need to do "allowDrop = true/false" after created handle.
|
||||||
{
|
// When do "allowDrop = true" in MyForm.this(),
|
||||||
if(S_OK != RegisterDragDrop(hwnd, droptarget))
|
// Now is _allowDrop == true and droptarget is null.
|
||||||
{
|
// Therefore call here allowDropImplement() without change _allowDrop value.
|
||||||
droptarget = null;
|
allowDropImplement(_allowDrop);
|
||||||
throw new DflException("Unable to register drag-drop");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug
|
debug
|
||||||
|
@ -7165,6 +7183,7 @@ class Control: DObject, IWindow // docmain
|
||||||
version(DFL_NO_DRAG_DROP) {} else
|
version(DFL_NO_DRAG_DROP) {} else
|
||||||
{
|
{
|
||||||
DropTarget droptarget = null;
|
DropTarget droptarget = null;
|
||||||
|
bool _allowDrop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: WS_VISIBLE is not reliable.
|
// Note: WS_VISIBLE is not reliable.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue