1 #ifndef __CUISCALER_H__ 2 #define __CUISCALER_H__ 3 4 #include <CUI/CUIWindow.h> 5 6 class CUIExport CUIScaler : public TCObject 7 { 8 public: 9 CUIScaler(CUIWindow *window); 10 void setHWindow(HWND hWnd); 11 double getScaleFactor(bool recalculate = false, UINT *dpiX = NULL, 12 UINT *dpiY = NULL); 13 static double getScaleFactor(HMONITOR hMonitor); 14 static BOOL adjustWindowRectEx(HMONITOR hMonitor, LPRECT lpRect, 15 DWORD dwStyle, BOOL bMenu, DWORD dwExStyle); 16 void setDpi(UINT dpiX, UINT dpiY); scale(int points)17 int scale(int points) { return (int)(points * getScaleFactor()); } unscale(int pixels)18 int unscale(int pixels) { return (int)(pixels / getScaleFactor()); } 19 bool scaleBitmap(HBITMAP hSrc, HBITMAP& hDst, double scaleFactor = -1.0); use32bit(void)20 static bool use32bit(void) { return sm_use32bit; } imageListCreateFlags(void)21 static UINT imageListCreateFlags(void) 22 { 23 return use32bit() ? ILC_COLOR32 : ILC_COLOR24 | ILC_MASK; 24 } 25 protected: 26 virtual ~CUIScaler(void); 27 virtual void dealloc(void); 28 29 CUIWindow *m_window; 30 HWND m_hWindow; 31 HDC m_hScaleSrcDC; 32 HDC m_hScaleDstDC; 33 double m_scaleFactor; 34 UINT m_dpiX; 35 UINT m_dpiY; 36 static bool sm_use32bit; 37 }; 38 39 #endif // __CUISCALER_H__