Beispiel #1
0
/* Функция обработки изменение размера кадра.
 * АРГУМЕНТЫ:
 *   - новые размеры кадра:
 *       INT W, H;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID VG4_AnimResize( INT W, INT H )
{
  BITMAPINFOHEADER bih;

  if (!VG4_IsInit)
    return;

  if (VG4_Anim.hFrame != NULL)
    DeleteObject(VG4_Anim.hFrame);

  /* создаем изображение заданной структуры */
  bih.biSize = sizeof(BITMAPINFOHEADER);
  bih.biWidth = VG4_Anim.W = W;
  bih.biHeight = -(VG4_Anim.H = H);
  bih.biPlanes = 1;    /* всегда */
  bih.biBitCount = 32; /* xRGB */
  bih.biCompression = BI_RGB;
  bih.biSizeImage = W * H * 4;
  bih.biClrImportant = 0;
  bih.biClrUsed = 0;
  bih.biXPelsPerMeter = bih.biYPelsPerMeter = 0;

  VG4_Anim.hFrame = CreateDIBSection(NULL, (BITMAPINFO *)&bih,
    DIB_RGB_COLORS, (VOID *)&VG4_Anim.Bits, NULL, 0);

  SelectObject(VG4_Anim.hDC, VG4_Anim.hFrame);

  /* Первичное построение кадра в новом размере */
  VG4_AnimRender();
} /* End of 'VG4_AnimResize' function */
Beispiel #2
0
/* Window message handle function (CALLBACK version).
 *   - window handle:
 *       HWND hWnd;
 *   - message identifier:
 *       UINT Msg;
 *   - message first parameter ('word' param):
 *       WPARAM wParam;
 *   - message second parameter ('long' param):
 *       LPARAM lParam;
 * RETURNS:
 *   (LRESULT) message return code (depended to Msg type).
 */
LRESULT CALLBACK VG4_MyWindowFunc( HWND hWnd, UINT Msg,
                                   WPARAM wParam, LPARAM lParam )
{
    HDC hDC;
    PAINTSTRUCT ps;
    MINMAXINFO *MinMax;

    switch (Msg)
    {
    case WM_GETMINMAXINFO:
        MinMax = (MINMAXINFO *)lParam;
        MinMax->ptMaxTrackSize.y =
            GetSystemMetrics(SM_CYMAXTRACK) +
            GetSystemMetrics(SM_CYCAPTION) +
            GetSystemMetrics(SM_CYMENU) +
            GetSystemMetrics(SM_CYBORDER) * 2;
        return 0;
    case WM_CREATE:
        /* Setup timer */
        SetTimer(hWnd, 11, 2, NULL);

        VG4_AnimInit(hWnd);
        return 0;
    case WM_SIZE:
        VG4_AnimResize(LOWORD(lParam), HIWORD(lParam));

        /* Send redraw timer message */
        SendMessage(hWnd, WM_TIMER, 0, 0);
        return 0;
    case WM_MOUSEWHEEL:
        VG4_MouseWheel += (SHORT)HIWORD(wParam);
        return 0;
    case WM_ERASEBKGND:
        /* Cancel draw background */
        return 0;
    case WM_TIMER:
        VG4_AnimRender();
        /* Post repaint window message */
        InvalidateRect(hWnd, NULL, FALSE);
        return 0;
    case WM_PAINT:
        /* Redraw window frame */
        hDC = BeginPaint(hWnd, &ps);
        VG4_AnimCopyFrame(hDC);
        EndPaint(hWnd, &ps);
        return 0;
    case WM_DESTROY:
        VG4_AnimClose();
        KillTimer(hWnd, 11);
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hWnd, Msg, wParam, lParam);
} /* End of 'MyWindowFunc' function */
Beispiel #3
0
/* Функция обработки сообщения окна.
 * АРГУМЕНТЫ:
 *   - дескриптор окна:
 *       HWND hWnd;
 *   - номер сообщения:
 *       UINT Msg;
 *   - параметр сообшения ('word parameter'):
 *       WPARAM wParam;
 *   - параметр сообшения ('long parameter'):
 *       LPARAM lParam;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ:
 *   (LRESULT) - в зависимости от сообщения.
 */
LRESULT CALLBACK MainWindowFunc( HWND hWnd, UINT Msg,
                                 WPARAM wParam, LPARAM lParam )
{
  HDC hDC;
  PAINTSTRUCT ps;
  MINMAXINFO *minmax;
  static BOOL pause;

  switch (Msg)
  {
  case WM_GETMINMAXINFO:
    minmax = (MINMAXINFO *)lParam;
    minmax->ptMaxTrackSize.y = GetSystemMetrics(SM_CYMAXTRACK) +
      GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER) * 2;
    return 0;
  case WM_CREATE:
    SetTimer(hWnd, 30, 1, NULL);
    if (!VG4_AnimInit(hWnd))
      return -1;
    return 0;
  case WM_SYSKEYDOWN:
    if (wParam == VK_RETURN)                     
      return 0;
    break;
  case WM_SIZE:
    VG4_AnimResize(LOWORD(lParam), HIWORD(lParam));
  case WM_TIMER:
    VG4_AnimRender();
    VG4_AnimCopyFrame();
    return 0;
  case WM_ERASEBKGND:
    /* VG4_AnimCopyFrame(); */
    return 1;
  case WM_PAINT:
    hDC = BeginPaint(hWnd, &ps);
    EndPaint(hWnd, &ps);
    return 0;
  case WM_DESTROY:
    VG4_AnimClose();
    PostQuitMessage(0);
    KillTimer(hWnd, 30);
    return 0;
  }
  return DefWindowProc(hWnd, Msg, wParam, lParam);
} /* End of 'MainWindowFunc' function */