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.

89 lines
2.2 KiB

  1. #ifndef __DLGUNITS_H_INCLUDED
  2. #define __DLGUNITS_H_INCLUDED
  3. #include <windows.h>
  4. class CDialogUnits
  5. {
  6. private:
  7. HWND m_hWnd;
  8. private:
  9. CDialogUnits(void);
  10. CDialogUnits( const CDialogUnits &other );
  11. CDialogUnits &operator=( const CDialogUnits & );
  12. public:
  13. CDialogUnits( HWND hWnd )
  14. : m_hWnd(hWnd)
  15. {
  16. }
  17. int X( INT nDialogUnits )
  18. {
  19. RECT rc;
  20. ZeroMemory( &rc, sizeof(rc) );
  21. rc.left = nDialogUnits;
  22. MapDialogRect( m_hWnd, &rc );
  23. return(rc.left);
  24. }
  25. int Y( INT nDialogUnits )
  26. {
  27. RECT rc;
  28. ZeroMemory( &rc, sizeof(rc) );
  29. rc.bottom = nDialogUnits;
  30. MapDialogRect( m_hWnd, &rc );
  31. return(rc.bottom);
  32. }
  33. POINT DialogUnitsToPixels( const POINT &ptDialogUnits )
  34. {
  35. RECT rc;
  36. ZeroMemory( &rc, sizeof(rc) );
  37. rc.left = ptDialogUnits.x;
  38. rc.top = ptDialogUnits.y;
  39. MapDialogRect( m_hWnd, &rc );
  40. POINT ptReturnValue;
  41. ptReturnValue.x = rc.left;
  42. ptReturnValue.y = rc.top;
  43. return(ptReturnValue);
  44. }
  45. SIZE DialogUnitsToPixels( const SIZE &sizeDialogUnits )
  46. {
  47. RECT rc;
  48. ZeroMemory( &rc, sizeof(rc) );
  49. rc.left = sizeDialogUnits.cx;
  50. rc.top = sizeDialogUnits.cy;
  51. MapDialogRect( m_hWnd, &rc );
  52. SIZE sizeReturnValue;
  53. sizeReturnValue.cx = rc.left;
  54. sizeReturnValue.cy = rc.top;
  55. return(sizeReturnValue);
  56. }
  57. RECT DialogUnitsToPixels( const RECT &rcDialogUnits )
  58. {
  59. RECT rc;
  60. ZeroMemory( &rc, sizeof(rc) );
  61. rc.left = rcDialogUnits.left;
  62. rc.top = rcDialogUnits.top;
  63. rc.right = rcDialogUnits.right;
  64. rc.bottom = rcDialogUnits.bottom;
  65. MapDialogRect( m_hWnd, &rc );
  66. return(rc);
  67. }
  68. SIZE StandardButtonSize(void)
  69. {
  70. SIZE sizeRes = { 50, 14 };
  71. return DialogUnitsToPixels( sizeRes );
  72. }
  73. SIZE StandardMargin(void)
  74. {
  75. SIZE sizeRes = { 7, 7 };
  76. return DialogUnitsToPixels( sizeRes );
  77. }
  78. SIZE StandardButtonMargin(void)
  79. {
  80. SIZE sizeRes = { 4, 7 };
  81. return DialogUnitsToPixels( sizeRes );
  82. }
  83. };
  84. #endif __DLGUNITS_H_INCLUDED