Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define _WIN32_WINNT 0x0601
- #include <windows.h>
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch (msg) {
- case WM_DESTROY: {
- PostQuitMessage(0);
- return 0;
- }
- case WM_MOUSEMOVE: {
- std::cout << "move\n";
- break;
- }
- }
- return DefWindowProcW(hwnd, msg, wParam, lParam);
- }
- int main() {
- WNDCLASSEXW wce{};
- wce.cbSize = sizeof wce;
- wce.style = CS_DBLCLKS;
- wce.lpfnWndProc = WndProc;
- wce.hInstance = GetModuleHandleW(nullptr);
- wce.hIcon = static_cast<HICON>(LoadImageW(nullptr, MAKEINTRESOURCEW(OIC_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
- wce.hCursor = static_cast<HCURSOR>(LoadImageW(nullptr, MAKEINTRESOURCEW(OCR_NORMAL), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
- wce.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
- wce.lpszClassName = L"Class";
- wce.hIconSm = static_cast<HICON>(LoadImageW(nullptr, MAKEINTRESOURCEW(OIC_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
- if (!RegisterClassExW(&wce)) {
- return 0;
- }
- HWND hwnd = CreateWindowExW(
- WS_EX_LAYERED, wce.lpszClassName, L"Text", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- nullptr, nullptr, nullptr, nullptr
- );
- if (!hwnd) {
- return 0;
- }
- SetLayeredWindowAttributes(hwnd, 0, 100, LWA_ALPHA);
- MSG msg;
- while (GetMessageW(&msg, nullptr, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessageW(&msg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement