MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / Resize

Method Resize

SampleApps/WebView2APISample/Toolbar.cpp:86–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86RECT Toolbar::Resize(RECT availableBounds)
87{
88 const int clientWidth = availableBounds.right - availableBounds.left;
89 const int clientHeight = availableBounds.bottom - availableBounds.top;
90 const float dpiScale = m_appWindow? float(m_appWindow->GetDpiScale()) : 1.0f;
91 const int clientLogicalWidth = int(float(clientWidth) / dpiScale);
92 const int itemHeight = int(32 * dpiScale);
93
94 int nextOffsetX = 0;
95
96 for (Item item = Item_BackButton; item < Item_LAST; item = Item(item + 1))
97 {
98 int itemWidth = int(GetItemLogicalWidth(item, clientLogicalWidth) * dpiScale);
99 SetWindowPos(m_items[item], nullptr, nextOffsetX, 0, itemWidth, itemHeight,
100 SWP_NOZORDER | SWP_NOACTIVATE);
101 nextOffsetX += itemWidth;
102 }
103
104 return { 0, itemHeight, clientWidth, clientHeight };
105}
106
107void Toolbar::UpdateDpiAndTextScale()
108{

Callers 1

ResizeEverythingMethod · 0.80

Calls 2

ItemEnum · 0.85
GetDpiScaleMethod · 0.80

Tested by

no test coverage detected