mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Made DPI dynamic to fix errors where running on Win7 failed
This commit is contained in:
parent
c0b73cdd6f
commit
cde78bc8c5
2 changed files with 18 additions and 1 deletions
|
@ -1016,12 +1016,22 @@ static int WinBFReportHook( int reportType, char *message, int *returnValue )
|
|||
|
||||
extern HINSTANCE gDLLInstance;
|
||||
|
||||
typedef UINT(NTAPI *GetDpiForWindow_t)(HWND);
|
||||
static GetDpiForWindow_t gGetDpiForWindow = NULL;
|
||||
static HMODULE gUserDll = NULL;
|
||||
|
||||
WinBFApp::WinBFApp()
|
||||
{
|
||||
#ifndef BF_MINGW
|
||||
//_CrtSetReportHook(WinBFReportHook);
|
||||
#endif
|
||||
|
||||
if (gUserDll == NULL)
|
||||
{
|
||||
gUserDll = ::LoadLibraryA("user32.dll");
|
||||
gGetDpiForWindow = (GetDpiForWindow_t)::GetProcAddress(gUserDll, "GetDpiForWindow");
|
||||
}
|
||||
|
||||
mRunning = false;
|
||||
mRenderDevice = NULL;
|
||||
|
||||
|
@ -1341,6 +1351,13 @@ bool WinBFWindow::IsMouseCaptured()
|
|||
return (mHWnd != NULL) && (GetCapture() == mHWnd);
|
||||
}
|
||||
|
||||
int WinBFWindow::GetDPI()
|
||||
{
|
||||
if (gGetDpiForWindow != NULL)
|
||||
return (int)gGetDpiForWindow(mHWnd);
|
||||
return 96; // Default DPI
|
||||
}
|
||||
|
||||
uint32 WinBFApp::GetClipboardFormat(const StringImpl& format)
|
||||
{
|
||||
if (format == "text")
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
virtual void SetAlpha(float alpha, uint32 destAlphaSrcMask, bool isMouseVisible) override;
|
||||
virtual void CaptureMouse() override;
|
||||
virtual bool IsMouseCaptured() override;
|
||||
virtual int GetDPI() { return ::GetDpiForWindow(mHWnd); }
|
||||
virtual int GetDPI() override; // { return ::GetDpiForWindow(mHWnd); }
|
||||
|
||||
virtual BFMenu* AddMenuItem(BFMenu* parent, int insertIdx, const char* text, const char* hotKey, BFSysBitmap* bitmap, bool enabled, int checkState, bool radioCheck) override;
|
||||
virtual void ModifyMenuItem(BFMenu* item, const char* text, const char* hotKey, BFSysBitmap* bitmap, bool enabled, int checkState, bool radioCheck) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue