about.c
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:3k
源码类别:

VC书籍

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "globals.h"
  3. HWND about_create(HWND hWnd)
  4. {
  5.     HANDLE  hinst;
  6.     globals.about_double_smiley_jump_pos = 20;
  7.     globals.about_double_smiley_jump_speed = 0.1;
  8.     hinst = GetModuleHandle(NULL);
  9.     DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUT), NULL, (DLGPROC)about_windowproc);
  10.     return hWnd;
  11. }
  12. void SetAboutText(HWND hWnd, const UINT uiStringResource)
  13. {
  14.     HRSRC hResource;
  15.     HGLOBAL hResourceData;
  16.     hResource = FindResource(NULL, MAKEINTRESOURCE(uiStringResource), "RAW");
  17.     hResourceData = LoadResource(NULL, hResource);
  18.     SetDlgItemText(hWnd, IDC_ABOUTTEXT, (LPCTSTR)LockResource(hResourceData));
  19. }
  20. LRESULT CALLBACK about_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  21. {
  22.     switch (msg)
  23.     {
  24.     case WM_INITDIALOG:
  25.         {
  26.             char cTitle[100];
  27.             sprintf(cTitle, "About CoolPlayer %d", CP_BUILD_NUMBER);
  28.             SetWindowText(hwndDlg, cTitle);
  29.             SetTimer(hwndDlg, CPC_TIMERID_BOUNCINGICON, 20, NULL);
  30.             SetAboutText(hwndDlg, IDR_ABOUT1);
  31.             SendDlgItemMessage(hwndDlg, IDC_ABOUTRADIO, BM_SETCHECK, TRUE, 0);
  32.             SetWindowPos(hwndDlg, HWND_TOPMOST,
  33.                          0,0,0,0,
  34.                          SWP_NOMOVE | SWP_NOSIZE);
  35.             SetForegroundWindow(hwndDlg);
  36.             return TRUE;
  37.         }
  38.     case WM_TIMER:
  39.         {
  40.             int     iconposition;
  41.             iconposition =
  42.                 (int) (cos(globals.about_double_smiley_jump_pos) * 130) +
  43.                 140;
  44.             MoveWindow(GetDlgItem(hwndDlg, IDC_ABOUTICON), 9, iconposition,
  45.                        32, 32, TRUE);
  46.             globals.about_double_smiley_jump_pos =
  47.                 globals.about_double_smiley_jump_pos +
  48.                 globals.about_double_smiley_jump_speed;
  49.             if (globals.about_double_smiley_jump_pos > 5.4)
  50.                 globals.about_double_smiley_jump_pos = 0.9;
  51.             break;
  52.         }
  53.     case WM_CLOSE:
  54.         EndDialog(hwndDlg, 1);
  55.         KillTimer(hwndDlg, CPC_TIMERID_BOUNCINGICON);
  56.         return TRUE;
  57.     case WM_COMMAND:
  58.         switch (LOWORD(wParam))
  59.         {
  60.         case IDOK:
  61.             EndDialog(hwndDlg, 1);
  62.             break;
  63.         case IDC_WEBSITE:
  64.             ShellExecute(0, 0, "http://coolplayer.sourceforge.net", 0, 0, SW_SHOWDEFAULT);
  65.             break;
  66.         case IDC_KEYBOARDRADIO:
  67.             SetAboutText(hwndDlg, IDR_KEYBOARD);
  68.             break;
  69.         case IDC_ABOUTRADIO:
  70.             SetAboutText(hwndDlg, IDR_ABOUT1);
  71.             break;
  72.         case IDC_CHANGELOG:
  73.             SetAboutText(hwndDlg, IDR_CHANGES);
  74.             break;
  75.         }
  76.         break;
  77.     case WM_NOTIFY:
  78.         if (wParam == IDC_SPIN1)
  79.         {
  80.             NM_UPDOWN *header = (NM_UPDOWN *) lParam;
  81.             if (header->iDelta == 1)
  82.                 globals.about_double_smiley_jump_speed = globals.about_double_smiley_jump_speed - 0.01;
  83.             else
  84.                 globals.about_double_smiley_jump_speed = globals.about_double_smiley_jump_speed + 0.01;
  85.             if (globals.about_double_smiley_jump_speed < 0)
  86.                 globals.about_double_smiley_jump_speed = 0;
  87.         }
  88.         break;
  89.     }
  90.     return FALSE;
  91. }
  92. //
  93. //
  94. //