Skip to content

Commit eb53fb4

Browse files
committed
don't use WM_SETREDRAW on the main window because that sets the window hidden, which makes its representation on the taskbar transparent. Instead cloak the window during startup, and only hide some child windows instead.
closes #389
1 parent 7a02311 commit eb53fb4

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

ext/sktoolslib

src/BowPad.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
<ClInclude Include="..\ext\sktoolslib\AeroControls.h" />
336336
<ClInclude Include="..\ext\sktoolslib\AeroGlass.h" />
337337
<ClInclude Include="..\ext\sktoolslib\AnimationManager.h" />
338+
<ClInclude Include="..\ext\sktoolslib\AutoCloakWindow.h" />
338339
<ClInclude Include="..\ext\sktoolslib\BaseDialog.h" />
339340
<ClInclude Include="..\ext\sktoolslib\BaseWindow.h" />
340341
<ClInclude Include="..\ext\sktoolslib\ClipboardHelper.h" />
@@ -470,6 +471,7 @@
470471
<ClCompile Include="..\ext\sktoolslib\AeroControls.cpp" />
471472
<ClCompile Include="..\ext\sktoolslib\AeroGlass.cpp" />
472473
<ClCompile Include="..\ext\sktoolslib\AnimationManager.cpp" />
474+
<ClCompile Include="..\ext\sktoolslib\AutoCloakWindow.cpp" />
473475
<ClCompile Include="..\ext\sktoolslib\BaseDialog.cpp" />
474476
<ClCompile Include="..\ext\sktoolslib\BaseWindow.cpp" />
475477
<ClCompile Include="..\ext\sktoolslib\BrowseFolder.cpp" />

src/BowPad.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@
411411
<ClInclude Include="SciTextReader.h">
412412
<Filter>Header Files</Filter>
413413
</ClInclude>
414+
<ClInclude Include="..\ext\sktoolslib\AutoCloakWindow.h">
415+
<Filter>sktoolslib</Filter>
416+
</ClInclude>
414417
</ItemGroup>
415418
<ItemGroup>
416419
<ClCompile Include="stdafx.cpp">
@@ -743,6 +746,9 @@
743746
<ClCompile Include="CustomLexers\LexAHK.cxx">
744747
<Filter>Lexer</Filter>
745748
</ClCompile>
749+
<ClCompile Include="..\ext\sktoolslib\AutoCloakWindow.cpp">
750+
<Filter>sktoolslib</Filter>
751+
</ClCompile>
746752
</ItemGroup>
747753
<ItemGroup>
748754
<ResourceCompile Include="BowPad.rc">

src/MainWindow.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "DPIAware.h"
4646
#include "Monitor.h"
4747
#include "ResString.h"
48+
#include "AutoCloakWindow.h"
4849
#include "../ext/tinyexpr/tinyexpr.h"
4950

5051
#include <memory>
@@ -632,13 +633,9 @@ bool CMainWindow::RegisterAndCreateWindow()
632633
// monitor but that monitor is not connected now).
633634
if (CreateEx(WS_EX_ACCEPTFILES | WS_EX_NOINHERITLAYOUT, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, nullptr))
634635
{
636+
CAutoCloakWindow autoCloak(*this);
637+
635638
SetFileTreeWidth(static_cast<int>(CIniSettings::Instance().GetInt64(L"View", L"FileTreeWidth", 200)));
636-
// hide the tab and status bar so they won't show right away when
637-
// restoring the window: those two show a white background until properly painted.
638-
// After restoring and showing the main window, ResizeChildControls() is called
639-
// which will show those controls again.
640-
ShowWindow(m_tabBar, SW_HIDE);
641-
ShowWindow(m_statusBar, SW_HIDE);
642639
std::wstring winPosKey = L"MainWindow_" + GetMonitorSetupHash();
643640
CIniSettings::Instance().RestoreWindowPos(winPosKey.c_str(), *this, 0);
644641
UpdateWindow(*this);
@@ -1878,11 +1875,7 @@ void CMainWindow::ResizeChildWindows()
18781875
{
18791876
RECT rect;
18801877
GetClientRect(*this, &rect);
1881-
// if the main window is not visible (yet) or the UI is blocked,
1882-
// then don't resize the child controls.
1883-
// as soon as the UI is unblocked, ResizeChildWindows() is called
1884-
// again.
1885-
if (!IsRectEmpty(&rect) && IsWindowVisible(*this))
1878+
if (!IsRectEmpty(&rect) )
18861879
{
18871880
constexpr UINT flags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOCOPYBITS;
18881881
constexpr UINT noShowFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOCOPYBITS;
@@ -1900,6 +1893,8 @@ void CMainWindow::ResizeChildWindows()
19001893
const int mainWidth = rect.right - rect.left;
19011894
const int btnMargin = CDPIAware::Instance().Scale(*this, 2);
19021895

1896+
OutputDebugString((L"ResizeChildWindows: " + std::to_wstring(treeWidth) + L" " + std::to_wstring(mainWidth) + L"\n").c_str());
1897+
19031898
HDWP hDwp = BeginDeferWindowPos(7);
19041899
DeferWindowPos(hDwp, m_statusBar, nullptr, rect.left, rect.bottom - m_statusBar.GetHeight(), mainWidth, m_statusBar.GetHeight(), flags);
19051900
DeferWindowPos(hDwp, m_tabBar, nullptr, treeWidth + rect.left, rect.top + m_ribbonHeight, mainWidth - treeWidth - (3 * (tabBtnWidth + btnMargin)) - btnMargin, rect.bottom - rect.top, flags);
@@ -2321,7 +2316,7 @@ void CMainWindow::UpdateStatusBar(bool bEverything)
23212316
}
23222317
else
23232318
{
2324-
auto text = selByte ? CStringUtils::Format(rsStatusSelectionLong, numberColor, sSelByte.c_str(), numberColor, sSelLine.c_str(), (selTextMarkerCount ? 0x008000 : numberColor), sSelTextMarkerCount.c_str()) : sNoSel;
2319+
auto text = selByte ? CStringUtils::Format(rsStatusSelectionLong, numberColor, sSelByte.c_str(), numberColor, sSelLine.c_str(), (selTextMarkerCount ? 0x008000 : numberColor), sSelTextMarkerCount.c_str()) : sNoSel;
23252320
auto shortText = selByte ? CStringUtils::Format(rsStatusSelection, numberColor, sSelByte.c_str(), numberColor, sSelLine.c_str(), (selTextMarkerCount ? 0x008000 : numberColor), sSelTextMarkerCount.c_str()) : sNoSel;
23262321
m_statusBar.SetPart(STATUSBAR_SEL,
23272322
text,
@@ -4805,10 +4800,16 @@ void CMainWindow::OpenFiles(const std::vector<std::wstring>& paths)
48054800

48064801
void CMainWindow::BlockAllUIUpdates(bool block)
48074802
{
4803+
std::vector<HWND> windows = {m_fileTree, m_statusBar};
48084804
if (block)
48094805
{
48104806
if (m_blockCount == 0)
4811-
SendMessage(*this, WM_SETREDRAW, FALSE, 0);
4807+
{
4808+
// don't block the main window, because WM_SETREDRAW with FALSE actually sets the WS_VISIBLE flag to false!
4809+
// Which for a main window means that the taskbar representation gets drawn empty.
4810+
for (auto window : windows)
4811+
SendMessage(window, WM_SETREDRAW, FALSE, 0);
4812+
}
48124813
FileTreeBlockRefresh(block);
48134814
++m_blockCount;
48144815
}
@@ -4819,11 +4820,12 @@ void CMainWindow::BlockAllUIUpdates(bool block)
48194820
if (m_blockCount == 0)
48204821
{
48214822
// unblock
4822-
SendMessage(*this, WM_SETREDRAW, TRUE, 0);
4823+
for (auto window : windows)
4824+
SendMessage(window, WM_SETREDRAW, TRUE, 0);
48234825
// force a redraw
48244826
RedrawWindow(*this, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_INTERNALPAINT | RDW_ALLCHILDREN | RDW_UPDATENOW);
48254827
}
4826-
// FileTreeBlockRefresh maintains it's own count.
4828+
// FileTreeBlockRefresh maintains its own count.
48274829
FileTreeBlockRefresh(block);
48284830
if (m_blockCount == 0)
48294831
ResizeChildWindows();

0 commit comments

Comments
 (0)