1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
use crate::{
windows::core::implement,
windows::{
core,
Win32::{
System::{
Ole::{
IDropSource,
IDropSource_Impl,
DROPEFFECT,
},
SystemServices::{
MODIFIERKEYS_FLAGS,
MK_LBUTTON,
},
},
Foundation::{
BOOL,
S_OK,
DRAGDROP_S_DROP,
DRAGDROP_S_USEDEFAULTCURSORS,
},
},
},
};
#[implement(IDropSource)]
pub struct DropSource { }
/*
implement_com!{
for_struct: DropSource,
identity: IDropSource,
wrapper_struct: DropSource_Com,
interface_count: 1,
interfaces: {
0: IDropSource
}
}*/
// IDropSource implementation for DropSource, which validates a drop on left mouse button up
impl IDropSource_Impl for DropSource {
fn QueryContinueDrag(&self, _: BOOL, grfkeystate: MODIFIERKEYS_FLAGS) -> core::HRESULT {
// if the left mousebutton is not pressed anymore, drop that item
if (grfkeystate & MK_LBUTTON) == MODIFIERKEYS_FLAGS(0) {
DRAGDROP_S_DROP
}
else {
S_OK
}
}
fn GiveFeedback(&self, _: DROPEFFECT) -> core::HRESULT {
DRAGDROP_S_USEDEFAULTCURSORS
}
}