blob: 6f5f5d31ce2a9ef76c1d181fe54ad2407f6f7dc3 (
plain)
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
64
65
66
67
68
|
package moe.yuuta.aero
import aero.*
import kotlinx.cinterop.*
import platform.windows.*
fun main() {
SetProcessDPIAware()
val dlgImpl = cValue<DLGTEMPLATE> {
style = (WS_OVERLAPPEDWINDOW or
DS_CENTER or
DS_MODALFRAME).convert()
dwExtendedStyle = 0.convert()
cdit = 0.convert()
x = 0
y = 0
cx = 400
cy = 200
}
memScoped {
return@memScoped DialogBoxIndirectParamW(GetModuleHandleA(null),
dlgImpl.ptr,
null,
staticCFunction(::dlgProc) as DLGPROC,
0)
}
}
fun dlgProc(hDlg: HWND,
message: UINT,
wParam: WPARAM,
lParam: LPARAM): INT_PTR {
when (message.convert<Int>()) {
WM_INITDIALOG -> {
val hUser = GetModuleHandleW("user32.dll")
if (hUser != null) {
val setWindowCompositionAttribute = GetProcAddress(hUser, "SetWindowCompositionAttribute") as pfnSetWindowCompositionAttribute?
if (setWindowCompositionAttribute != null) {
val accent = cValue<ACCENT_POLICY> {
AccentState = ACCENT_ENABLE_BLURBEHIND
AccentFlags = 0.convert()
GradientColor = 0.convert()
AnimationId = 0.convert()
}
memScoped {
val data = cValue<WINDOWCOMPOSITIONATTRIBDATA> {
Attrib = WCA_ACCENT_POLICY
pvData = accent.ptr
cbData = accent.size.convert()
}
setWindowCompositionAttribute(hDlg, data.ptr)
}
}
}
return true.toByte().toLong()
}
WM_COMMAND -> {
EndDialog(hDlg, wParam.convert())
return true.toByte().toLong()
}
WM_CTLCOLORDLG -> {
return GetStockObject(BLACK_BRUSH).rawValue.toLong()
}
else -> {
return false.toByte().toLong()
}
}
}
|