DPI.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef __DPI_H__
  2. #define __DPI_H__
  3. #pragma once
  4. #ifndef DPI_ENUMS_DECLARED
  5. typedef enum PROCESS_DPI_AWARENESS {
  6. PROCESS_DPI_UNAWARE = 0,
  7. PROCESS_SYSTEM_DPI_AWARE = 1,
  8. PROCESS_PER_MONITOR_DPI_AWARE = 2
  9. } PROCESS_DPI_AWARENESS;
  10. typedef enum MONITOR_DPI_TYPE {
  11. MDT_EFFECTIVE_DPI = 0,
  12. MDT_ANGULAR_DPI = 1,
  13. MDT_RAW_DPI = 2,
  14. MDT_DEFAULT = MDT_EFFECTIVE_DPI
  15. } MONITOR_DPI_TYPE;
  16. #define DPI_ENUMS_DECLARED
  17. #endif // (DPI_ENUMS_DECLARED)
  18. namespace DuiLib
  19. {
  20. class UILIB_API CDPI
  21. {
  22. public:
  23. CDPI(void);
  24. public:
  25. static int GetMainMonitorDPI();
  26. static int GetDPIOfMonitor(HMONITOR hMonitor);
  27. static int GetDPIOfMonitorNearestToPoint(POINT pt);
  28. public:
  29. PROCESS_DPI_AWARENESS GetDPIAwareness();
  30. BOOL SetDPIAwareness(PROCESS_DPI_AWARENESS Awareness);
  31. UINT GetDPI();
  32. UINT GetScale();
  33. void SetScale(UINT uDPI);
  34. RECT Scale(RECT rcRect);
  35. void Scale(RECT *pRect);
  36. POINT Scale(POINT ptPoint);
  37. void Scale(POINT *pPoint);
  38. SIZE Scale(SIZE szSize);
  39. void Scale(SIZE *pSize);
  40. int Scale(int iValue);
  41. int ScaleBack(int iValue);
  42. void ScaleBack(RECT *pRect);
  43. private:
  44. int m_nScaleFactor;
  45. int m_nScaleFactorSDA;
  46. PROCESS_DPI_AWARENESS m_Awareness;
  47. };
  48. }
  49. #endif //__DPI_H__