-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug, AdjustWindowRectExForDpi行为适配系统,DPI为0时返回失败,且修复边框大小可能返回不正确大小
- Loading branch information
1 parent
b679d0d
commit a2d7a26
Showing
4 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "pch.h" | ||
#include "Thunks/user32.hpp" | ||
|
||
namespace User32 | ||
{ | ||
TEST_CLASS(AdjustWindowRectExForDpi) | ||
{ | ||
AwaysNullGuard Guard; | ||
|
||
public: | ||
AdjustWindowRectExForDpi() | ||
{ | ||
Guard |= YY::Thunks::aways_null_try_get_AdjustWindowRectExForDpi; | ||
} | ||
|
||
TEST_METHOD(常规测试) | ||
{ | ||
struct TestItem | ||
{ | ||
DWORD fStyle; | ||
BOOL bMenu; | ||
DWORD fExStyle; | ||
UINT uDpi; | ||
}; | ||
|
||
static constexpr const TestItem kTestItems[] = | ||
{ | ||
{ WS_DLGFRAME, TRUE, 0, USER_DEFAULT_SCREEN_DPI }, | ||
{ WS_DLGFRAME, TRUE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_DLGFRAME, FALSE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_THICKFRAME, TRUE, 0, USER_DEFAULT_SCREEN_DPI }, | ||
{ WS_THICKFRAME, TRUE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_THICKFRAME, FALSE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_THICKFRAME | WS_CAPTION, TRUE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_THICKFRAME | WS_CAPTION, FALSE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_CAPTION, TRUE, 0, USER_DEFAULT_SCREEN_DPI * 1.25 }, | ||
{ WS_CAPTION, FALSE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
{ WS_OVERLAPPEDWINDOW, TRUE, 0, USER_DEFAULT_SCREEN_DPI }, | ||
{ WS_OVERLAPPEDWINDOW, TRUE, 0, USER_DEFAULT_SCREEN_DPI * 1.5 }, | ||
{ WS_OVERLAPPEDWINDOW, FALSE, 0, USER_DEFAULT_SCREEN_DPI * 2 }, | ||
}; | ||
|
||
for (auto& _Item : kTestItems) | ||
{ | ||
RECT _Current = {}; | ||
::AdjustWindowRectExForDpi(&_Current, _Item.fStyle, _Item.bMenu, _Item.fExStyle, _Item.uDpi); | ||
|
||
RECT _Target = {}; | ||
YY::Thunks::aways_null_try_get_AdjustWindowRectExForDpi = false; | ||
::AdjustWindowRectExForDpi(&_Target, _Item.fStyle, _Item.bMenu, _Item.fExStyle, _Item.uDpi); | ||
YY::Thunks::aways_null_try_get_AdjustWindowRectExForDpi = true; | ||
|
||
CStringW _szTarget; | ||
CStringW _szCurrent; | ||
Assert::AreEqual(_szTarget.GetString(), _szCurrent.GetString()); | ||
} | ||
} | ||
|
||
TEST_METHOD(畸形测试) | ||
{ | ||
RECT _Current = {}; | ||
Assert::IsFalse(::AdjustWindowRectExForDpi(&_Current, 0, 0, 0, 0)); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters