Advertisement
Guest User

Untitled

a guest
Aug 14th, 2013
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #define _WIN32_WINNT 0x0601
  4. #include <windows.h>
  5.  
  6. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  7. switch (msg) {
  8. case WM_DESTROY: {
  9. PostQuitMessage(0);
  10. return 0;
  11. }
  12.  
  13. case WM_MOUSEMOVE: {
  14. std::cout << "move\n";
  15. break;
  16. }
  17. }
  18.  
  19. return DefWindowProcW(hwnd, msg, wParam, lParam);
  20. }
  21.  
  22. int main() {
  23. WNDCLASSEXW wce{};
  24.  
  25. wce.cbSize = sizeof wce;
  26. wce.style = CS_DBLCLKS;
  27. wce.lpfnWndProc = WndProc;
  28. wce.hInstance = GetModuleHandleW(nullptr);
  29. wce.hIcon = static_cast<HICON>(LoadImageW(nullptr, MAKEINTRESOURCEW(OIC_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
  30. wce.hCursor = static_cast<HCURSOR>(LoadImageW(nullptr, MAKEINTRESOURCEW(OCR_NORMAL), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
  31. wce.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
  32. wce.lpszClassName = L"Class";
  33. wce.hIconSm = static_cast<HICON>(LoadImageW(nullptr, MAKEINTRESOURCEW(OIC_WINLOGO), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
  34.  
  35. if (!RegisterClassExW(&wce)) {
  36. return 0;
  37. }
  38.  
  39. HWND hwnd = CreateWindowExW(
  40. WS_EX_LAYERED, wce.lpszClassName, L"Text", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  41. CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  42. nullptr, nullptr, nullptr, nullptr
  43. );
  44.  
  45. if (!hwnd) {
  46. return 0;
  47. }
  48.  
  49. SetLayeredWindowAttributes(hwnd, 0, 100, LWA_ALPHA);
  50.  
  51. MSG msg;
  52. while (GetMessageW(&msg, nullptr, 0, 0)) {
  53. TranslateMessage(&msg);
  54. DispatchMessageW(&msg);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement