Leaked source code of windows server 2003
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.

116 lines
3.6 KiB

  1. /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
  2. **
  3. ** FILE: BUTTON.CPP
  4. ** DATE: 5/12/98
  5. ** PROJ: NT5
  6. ** PROG: BLJ
  7. ** COMMENTS:
  8. **
  9. ** DESCRIPTION: Window class custom buttons
  10. **
  11. ** HISTORY:
  12. ** DATE WHO WHAT
  13. ** ---- --- ----
  14. ** 5/12/98 a-brycej Wrote it.
  15. **
  16. **
  17. ** Copyright (C) Microsoft 1998. All Rights Reserved.
  18. **
  19. **~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
  20. #include "resrc1.h"
  21. #include "cplsvr1.h"
  22. extern HINSTANCE ghInst;
  23. extern CDIGameCntrlPropSheet_X *pdiCpl;
  24. // Colour of text for buttons!
  25. #define TEXT_COLOUR RGB(202,202,202)
  26. HICON hIconArray[2];
  27. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. //
  29. // FUNCTION : ButtonWndProc
  30. // REMARKS : The callback function for the CustomButton Window.
  31. //
  32. // PARAMS : The usual callback funcs for message handling
  33. //
  34. // RETURNS : LRESULT - Depends on the message
  35. // CALLS :
  36. // NOTES :
  37. //
  38. LRESULT CALLBACK ButtonWndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  39. {
  40. switch( iMsg )
  41. {
  42. case WM_PAINT:
  43. {
  44. PAINTSTRUCT *pps = new (PAINTSTRUCT);
  45. assert (pps);
  46. HDC hDC = BeginPaint(hWnd, pps);
  47. // Draw the appropriate icon
  48. DrawIconEx(hDC, 0, 0, hIconArray[GetWindowLong(hWnd, GWLP_USERDATA)], 0, 0, 0, NULL, DI_NORMAL);
  49. // Prepare the DC for the text
  50. SetBkMode (hDC, TRANSPARENT);
  51. SetTextColor(hDC, TEXT_COLOUR);
  52. // Enforce the proper size!
  53. pps->rcPaint.top = pps->rcPaint.left = 0;
  54. pps->rcPaint.bottom = 33;
  55. pps->rcPaint.right = 30;
  56. #define MAX_BUTTON_DIGITS 3
  57. TCHAR tsz[MAX_BUTTON_DIGITS+1]; //Maximum button number can be 999, more than enough.
  58. // Draw the Number
  59. DrawText (hDC, (LPCTSTR)tsz, GetWindowText(hWnd, tsz, MAX_BUTTON_DIGITS+1), &pps->rcPaint, DT_VCENTER|DT_CENTER|DT_NOPREFIX|DT_SINGLELINE|DT_NOCLIP);
  60. SetBkMode(hDC, OPAQUE);
  61. EndPaint (hWnd, pps);
  62. #undef MAX_BUTTON_DIGITS
  63. if( pps ) {
  64. delete (pps);
  65. }
  66. }
  67. return(FALSE);
  68. default:
  69. return(DefWindowProc(hWnd, iMsg,wParam, lParam));
  70. }
  71. return(FALSE);
  72. }
  73. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. //
  75. // FUNCTION : RegisterCustomButtonClass
  76. // REMARKS : Registers the Custom Button control window.
  77. //
  78. // PARAMS : hInstance - Used for the call to RegisterClassEx
  79. //
  80. // RETURNS : TRUE - if successfully registered
  81. // FALSE - failed to register
  82. // CALLS : RegisterClassEx
  83. // NOTES :
  84. //
  85. extern ATOM RegisterCustomButtonClass()
  86. {
  87. WNDCLASSEX CustCtrlClass;
  88. ZeroMemory(&CustCtrlClass, sizeof(WNDCLASSEX));
  89. CustCtrlClass.cbSize = sizeof(WNDCLASSEX);
  90. CustCtrlClass.style = CS_CLASSDC;
  91. CustCtrlClass.lpfnWndProc = ButtonWndProc;
  92. CustCtrlClass.hInstance = ghInst;
  93. CustCtrlClass.lpszClassName = TEXT("TESTBUTTON");
  94. return(RegisterClassEx( &CustCtrlClass ));
  95. }