Exemplo n.º 1
0
// This function takes care of *must* do tasks, like terminating screen saver
static LRESULT WINAPI SysScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {
        case WM_CREATE:
            // Mouse is not supposed to move from this position
            GetCursorPos(&pt_orig);
            break;

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        case WM_SYSCOMMAND:
            if (!fChildPreview)
            {
                switch (wParam)
                {
                    case SC_CLOSE:
                    case SC_SCREENSAVE:
                        return FALSE;
                }
            }
            break;
    }

    return ScreenSaverProc(hWnd, uMsg, wParam, lParam);
}
Exemplo n.º 2
0
static LRESULT CALLBACK RealScreenSaverProc (HWND hwnd, int iMsg, WPARAM wparam,
                       LPARAM lparam)
{
  switch (iMsg)
  {
   // If preview window is being displayed, user clicks the right mouse
   // button in preview window, or user clicks ? button beside X button in
   // caption area of Display Properties window followed by right mouse
   // button in preview window, Windows sends a WM_CONTEXTMENU message. But
   // if user clicks ? button followed by left mouse button in preview
   // window, and then moves the mouse pointer out of preview window, Windows
   // sends a WM_HELP message. In either case, message is forwarded to valid
   // parent window.

   case WM_CONTEXTMENU:
   case WM_HELP:
      if (g_scrmode == smPreview)
      {
        HWND hwndParent = GetParent (hwnd);
        if (hwndParent == NULL || !IsWindow (hwndParent))
          return 1;
        PostMessage (hwndParent, iMsg, (WPARAM) hwndParent, lparam);
        return 1;
      }

      break;

   // WM_CREATE message sent in response to CreateWindowEx() function call in
   // the doSaver() function.

   case WM_CREATE:
      // Capture the mouse¡¯s current position. This position is used in
      // DefScreenSaverProc() to determine if the mouse has moved
      // sufficiently to close the screensaver.

      GetCursorPos (&g_ptMouse);

      // If preview window is not being displayed (we are covering the
      // entire desktop with a screensaver), hide the mouse cursor.

      if (g_scrmode != smPreview)
        SetCursor (NULL);

      break;

   // WM_DESTROY message sent in response to window being destroyed, after
   // the window has been removed from the screen.

   case WM_DESTROY:
      // Terminate the screensaver. PostQuitMessage() posts a WM_QUIT
      // message to the thread¡¯s message queue and immediately returns. 

      PostQuitMessage (0);
  }

  return ScreenSaverProc (hwnd, iMsg, wparam, lparam);
}
Exemplo n.º 3
0
/* this function takes care of *must* do tasks, like terminating
   screen saver */
static LRESULT WINAPI SysScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch (msg)
  {
    case WM_CREATE:
      if (!fChildPreview)
        SetCursor(NULL);
      /* mouse is not supposed to move from this position */
      GetCursorPos(&pt_orig);
      break;
    case WM_DESTROY:
      PostQuitMessage(0);
      break;
    case WM_TIMER:
      if (closing)
        return 0;
      break;
    case WM_PAINT:
      if (closing)
        return DefWindowProc(hWnd, msg, wParam, lParam);
      break;
    case WM_SYSCOMMAND:
      if (!fChildPreview)
        switch (wParam)
        {
          case SC_CLOSE:
          case SC_SCREENSAVE:
          case SC_NEXTWINDOW:
          case SC_PREVWINDOW:
            return FALSE;
        }
      break;
    case WM_MOUSEMOVE:
    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
    case WM_NCACTIVATE:
    case WM_ACTIVATE:
    case WM_ACTIVATEAPP:
      if (closing)
        return DefWindowProc(hWnd, msg, wParam, lParam);
      break;
  }
  return ScreenSaverProc(hWnd, msg, wParam, lParam);
}