Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
3.5 KiB

  1. /****************************************************************************
  2. ABOUT MICROSOFT DIALOG DLL
  3. by RobD
  4. ****************************************************************************/
  5. #define _WINDOWS
  6. #include <windows.h>
  7. #include <port1632.h>
  8. #include <basetsd.h>
  9. #include "res.h"
  10. /* Local Variables */
  11. BOOL fEGA; /* TRUE if working with EGA */
  12. BOOL fColor; /* TRUE if working with a color display */
  13. INT cUsers = 0; /* Count of users of the bitmap */
  14. HANDLE hInstDll;
  15. HDC hdcMSFT;
  16. HBITMAP hbmpMSFT;
  17. HICON hiconApp;
  18. LPSTR lpstrApp;
  19. LPSTR lpstrCredit;
  20. #define cchMax 80
  21. #define cchMaxTitle 73
  22. CHAR szAbout[cchMax] = "About ";
  23. LPSTR lpszTitle = &szAbout[6];
  24. VOID APIENTRY AboutWEP(HWND, HICON, LPSTR, LPSTR);
  25. /****** L I B M A I N ******/
  26. /* Called once to initialize data */
  27. /* Determines if display is color and remembers the hInstance for the DLL */
  28. INT APIENTRY LibMain(HANDLE hInst, ULONG ul_reason_being_called, LPVOID lpReserved)
  29. {
  30. if (fEGA = GetSystemMetrics(SM_CYSCREEN) < 351)
  31. fColor = FALSE;
  32. else
  33. {
  34. HDC hDC = GetDC(GetDesktopWindow());
  35. fColor = (GetDeviceCaps(hDC, NUMCOLORS) != 2);
  36. ReleaseDC(GetDesktopWindow(),hDC);
  37. }
  38. hInstDll = hInst;
  39. return 1;
  40. UNREFERENCED_PARAMETER(ul_reason_being_called);
  41. UNREFERENCED_PARAMETER(lpReserved);
  42. }
  43. /****** W E P ******/
  44. /* Called upon exit/last use */
  45. VOID APIENTRY WEP(INT nParm)
  46. {
  47. return;
  48. (nParm);
  49. }
  50. /*** A B O U T D L G P R O C ***/
  51. /* Main Dialog Procedure */
  52. INT_PTR APIENTRY AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  53. {
  54. switch (message)
  55. {
  56. case WM_INITDIALOG:
  57. {
  58. RECT rect;
  59. SetWindowText(hDlg, (LPSTR) szAbout);
  60. if (hiconApp != NULL)
  61. SendDlgItemMessage(hDlg, ID_ICON_APP, STM_SETICON, (LONG_PTR)hiconApp, 0);
  62. if (lpstrApp != NULL)
  63. SetDlgItemText(hDlg, ID_NAME_APP, lpstrApp);
  64. if (lpstrCredit != NULL)
  65. SetDlgItemText(hDlg, ID_NAME_CREDIT, lpstrCredit);
  66. CreateWindow("button", "",
  67. WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
  68. 10, 10, dxpMSFT, dypMSFT, hDlg, (HMENU)ID_USER_MSFT, hInstDll, NULL);
  69. GetWindowRect(hDlg,&rect);
  70. SetWindowPos(hDlg,NULL,
  71. (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) >> 1,
  72. (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 3,
  73. 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  74. return (TRUE);
  75. }
  76. case WM_COMMAND:
  77. switch(GET_WM_COMMAND_ID(wParam, lParam))
  78. {
  79. case IDOK:
  80. case IDCANCEL:
  81. {
  82. EndDialog(hDlg, TRUE);
  83. return (TRUE);
  84. }
  85. default:
  86. break;
  87. }
  88. break;
  89. case WM_DRAWITEM:
  90. {
  91. #define lpDI ((LPDRAWITEMSTRUCT) lParam)
  92. if ((lpDI->CtlID == ID_USER_MSFT) && (hdcMSFT != NULL))
  93. BitBlt(lpDI->hDC, 0, 0, dxpMSFT, dypMSFT, hdcMSFT, 0, 0, SRCCOPY);
  94. #undef lpDI
  95. }
  96. break;
  97. default:
  98. break;
  99. }
  100. return (FALSE);
  101. }
  102. /****** A B O U T W E P ******/
  103. VOID APIENTRY AboutWEP(HWND hwnd, HICON hicon, LPSTR lpTitle, LPSTR lpCredit)
  104. {
  105. hiconApp = hicon;
  106. lpstrApp = lpTitle;
  107. lpstrCredit = lpCredit;
  108. GetWindowText(hwnd, lpszTitle, cchMaxTitle);
  109. if (cUsers++ == 0)
  110. {
  111. hdcMSFT = CreateCompatibleDC(NULL);
  112. hbmpMSFT = LoadBitmap(hInstDll,
  113. fColor ? MAKEINTRESOURCE(ID_BMP_CLR) : MAKEINTRESOURCE(ID_BMP_BAW) );
  114. if ((hdcMSFT != NULL) && (hbmpMSFT != NULL))
  115. SelectObject(hdcMSFT, hbmpMSFT);
  116. }
  117. DialogBox(hInstDll,
  118. fEGA ? MAKEINTRESOURCE(ID_DLG_ABOUT_EGA) : MAKEINTRESOURCE(ID_DLG_ABOUT),
  119. hwnd, AboutDlgProc);
  120. if ((--cUsers == 0) && (hdcMSFT != NULL))
  121. {
  122. DeleteDC(hdcMSFT);
  123. DeleteObject(hbmpMSFT);
  124. }
  125. }