Advertisement
Guest User

Null WIndow

a guest
Apr 28th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3.  
  4. LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  5.  
  6. // WinMain: The Application Entry Point
  7. int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR nCmdLine, int nCmdShow)
  8. {
  9.  // Register the window class
  10.  const wchar_t CLASS_NAME[] = L"WindowClass";
  11.  WNDCLASS wc = { };
  12.  wc.lpfnWndProc = WindowProc;
  13.  wc.lpszClassName = CLASS_NAME;
  14.  wc.hInstance = hInstance;
  15.  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  16.  RegisterClass(&wc);
  17.  // Create the window
  18.  HWND hwnd = CreateWindowEx(
  19.   0,
  20.   CLASS_NAME,
  21.   L"EYELINE",
  22.   WS_OVERLAPPEDWINDOW,
  23.   CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
  24.   NULL,NULL,hInstance,NULL);
  25.  if(hwnd == 0)
  26.   return 0;
  27.  // Show the window
  28.  ShowWindow(hwnd, nCmdShow);
  29.  nCmdShow = 1;
  30.  ShowCursor(FALSE);
  31.  BOOL WINAPI BringWindowToTop(_In_ HWND hWnd);
  32.  LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
  33.  lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU | WS_EX_TOPMOST | SWP_NOMOVE | SWP_NOSIZE);
  34.  SetWindowLong(hwnd, GWL_STYLE, lStyle);
  35.  SetWindowPos(hwnd, HWND_TOPMOST, 0,0,1920,1080, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
  36.  SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
  37.  
  38.  // The Message loop
  39.  MSG msg = { };
  40.  while(GetMessage(&msg,NULL,0,0))
  41.  {
  42.   TranslateMessage(&msg);
  43.   DispatchMessage(&msg);
  44.  }
  45.  return 0;
  46. }
  47. // Window Procedure function
  48. LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  49. {
  50.  switch(uMsg)
  51.  {
  52.  case WM_DESTROY:PostQuitMessage(0); return 0;
  53.  case WM_PAINT:
  54.   {
  55.    PAINTSTRUCT ps;
  56.    HDC hdc = BeginPaint(hwnd,&ps);
  57.    FillRect(hdc,&ps.rcPaint,(HBRUSH)(COLOR_WINDOW+5));
  58.    EndPaint(hwnd,&ps);
  59.   }return 0;
  60.  case WM_CLOSE:
  61.   {
  62.    if(MessageBox(hwnd,L"Do you want to exit?",L"EXIT",MB_OKCANCEL)==IDOK)
  63.     DestroyWindow(hwnd);
  64.   }return 0;
  65.  }
  66.  return DefWindowProc(hwnd,uMsg,wParam,lParam); // Default Message Handling
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement