From 49f29c72ee687c4f107142d6eadc527fb97e9146 Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Mon, 4 May 2020 23:32:22 +0900 Subject: [PATCH] =?UTF-8?q?#1246=20=E3=81=AE=20revert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/view/CCaret.cpp | 4 +--- sakura_core/window/CMainStatusBar.cpp | 23 +++++++---------------- sakura_core/window/CMainStatusBar.h | 5 +---- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/sakura_core/view/CCaret.cpp b/sakura_core/view/CCaret.cpp index 6f381f6295..bf501ea97b 100644 --- a/sakura_core/view/CCaret.cpp +++ b/sakura_core/view/CCaret.cpp @@ -832,7 +832,7 @@ void CCaret::ShowCaretPosInfo() } auto& statusBar = m_pEditDoc->m_pcEditWnd->m_cStatusBar; - ::SendMessage(statusBar.GetStatusHwnd(), WM_SETREDRAW, (WPARAM)FALSE, 0); + if( m_bClearStatus ){ statusBar.SetStatusText( 0, SBT_NOBORDERS, L"" ); } @@ -846,8 +846,6 @@ void CCaret::ShowCaretPosInfo() statusBar.SetStatusText( 4, 0, pszCodeName ); statusBar.SetStatusText( 5, SBT_OWNERDRAW, L"" ); statusBar.SetStatusText( 6, 0, szText_6 ); - ::SendMessage(statusBar.GetStatusHwnd(), WM_SETREDRAW, (WPARAM)TRUE, 0); - ::RedrawWindow(statusBar.GetStatusHwnd(), NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } } diff --git a/sakura_core/window/CMainStatusBar.cpp b/sakura_core/window/CMainStatusBar.cpp index 6fc1aaffd9..eb879dec3d 100644 --- a/sakura_core/window/CMainStatusBar.cpp +++ b/sakura_core/window/CMainStatusBar.cpp @@ -95,7 +95,7 @@ void CMainStatusBar::DestroyStatusBar() void CMainStatusBar::SendStatusMessage2( const WCHAR* msg ) { if( NULL != m_hwndStatusBar ){ - SetStatusText(0, SBT_NOBORDERS, msg, SIZE_MAX, false); + SetStatusText(0, SBT_NOBORDERS, msg); } } @@ -107,14 +107,15 @@ void CMainStatusBar::SendStatusMessage2( const WCHAR* msg ) @param pszText [in] 表示テキスト @param textLen [in] 表示テキストの文字数 */ -void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen /* = SIZE_MAX */, bool bSendMessage /* = true */) +void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen /* = SIZE_MAX */) { if( !m_hwndStatusBar ){ assert(m_hwndStatusBar != NULL); return; } - // SB_SETTEXT メッセージを発行するかどうかを判定するラムダ式 - bool bNeedsToDraw = [&]() -> bool { + // StatusBar_SetText 関数を呼びだすかどうかを判定するラムダ式 + // (StatusBar_SetText は SB_SETTEXT メッセージを SendMessage で送信する) + [&]() -> bool { // オーナードローの場合は SB_SETTEXT メッセージを無条件に発行するように判定 // 本来表示に変化が無い場合には呼び出さない方が表示のちらつきが減るので好ましいが // 判定が難しいので諦める @@ -149,22 +150,12 @@ void CMainStatusBar::SetStatusText(int nIndex, int nOption, const WCHAR* pszText return true; } if( prevTextLen > 0 ){ - StatusBar_GetText( m_hwndStatusBar, nIndex, prev ); + ::StatusBar_GetText( m_hwndStatusBar, nIndex, prev ); // 設定済みの文字列と設定する文字列を比較して異なる場合は、SB_SETTEXT メッセージを発行 return (wcscmp(prev, pszText) != 0); } else{ return true; } - }(); - if (bNeedsToDraw) { - if (bSendMessage) { - ::SendMessageW( m_hwndStatusBar, SB_SETTEXT, nIndex | nOption, (LPARAM)pszText ); - }else { - std::unique_ptr p(new wchar_t[textLen+1]); - std::copy(pszText, pszText+textLen+1, p.get()); - ::PostMessageW( m_hwndStatusBar, SB_SETTEXT, nIndex | nOption, (LPARAM)p.get() ); - m_postponeBuffers[nIndex] = std::move(p); - } - }; + }() ? StatusBar_SetText( m_hwndStatusBar, nIndex | nOption, pszText ) : 0; } diff --git a/sakura_core/window/CMainStatusBar.h b/sakura_core/window/CMainStatusBar.h index 0e6a75ac6d..143b144f43 100644 --- a/sakura_core/window/CMainStatusBar.h +++ b/sakura_core/window/CMainStatusBar.h @@ -25,8 +25,6 @@ #pragma once #include "doc/CDocListener.h" -#include -#include class CEditWnd; @@ -54,10 +52,9 @@ class CMainStatusBar : public CDocListenerEx{ HWND GetProgressHwnd() const{ return m_hwndProgressBar; } //設定 - void SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen = SIZE_MAX, bool bSendMessage = true); + void SetStatusText(int nIndex, int nOption, const WCHAR* pszText, size_t textLen = SIZE_MAX); private: CEditWnd* m_pOwner; HWND m_hwndStatusBar; HWND m_hwndProgressBar; - std::array, 7> m_postponeBuffers; };