-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
36 lines (31 loc) · 1.28 KB
/
Copy pathdllmain.cpp
File metadata and controls
36 lines (31 loc) · 1.28 KB
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
#include "pch.h"
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
BOOL SetTransparent(HWND hwnd, COLORREF colorKey) {
LONG_PTR exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle | WS_EX_LAYERED);
return SetLayeredWindowAttributes(hwnd, colorKey, 0, LWA_COLORKEY);
}
extern "C" __declspec(dllexport) double MakeColorTransparent(const char* hwndString, double r, double g, double b) {
HWND hwnd = reinterpret_cast<HWND>(std::stoull(hwndString, nullptr, 16));
if (!IsWindow(hwnd)) {
MessageBoxA(NULL, "Invalid HWND", "Error", MB_ICONERROR);
return 0.0;
}
COLORREF colorKey = RGB((int)r, (int)g, (int)b);
return (double)SetTransparent(hwnd, colorKey);
}
//TODO: Fix these functions
/*BOOL WRAPPER_RemoveTransparency(HWND hwnd) {
LONG_PTR exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle & ~WS_EX_LAYERED);
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
return FALSE;
}
extern "C" __declspec(dllexport) double RemoveTransparency(const char* hwndString) {
HWND hwnd = reinterpret_cast<HWND>(std::stoull(hwndString, nullptr, 16));
WRAPPER_RemoveTransparency(hwnd);
return 0.0;
}*/