Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

キャレット位置の文字情報をステータスバーに設定する際の再描画をまとめた変更で UpdateWindow の呼び出しが必要なのに漏れていたのを修正 #1642

Merged
merged 1 commit into from Apr 23, 2021

Conversation

beru
Copy link
Contributor

@beru beru commented Apr 23, 2021

PR の目的

#1637 で報告があったステータスバーの表示が正しく更新されない不具合を修正するのが目的です。

カテゴリ

  • 不具合修正

PR の背景

#1637 で報告があったとおり、自分が過去に行った #1601 の変更後に問題が発生するようになったので、その不具合を修正する必要があります。

PR のメリット

不具合が修正されます。

PR のデメリット (トレードオフとかあれば)

きちんとウィンドウの描画を行うようになるのでCPU使用率が増加します。

とはいえ再描画をまとめる対策を入れないよりかはCPU使用率が低くなるという認識です。

仕様・動作説明

なぜ UpdateWindow の呼び出しを追加する必要があるかというと、SB_SETTEXT メッセージを送ってステータスバーの部分のテキスト表示を更新する処理の前後に

::SendMessage(hWnd, WM_SETREDRAW, FALSE, 0);

::SendMessage(hWnd, WM_SETREDRAW, TRUE, 0);

の呼び出しを入れるとステータスバーのウィンドウに対して WM_PAINT メッセージが送られない場合があり、その際に表示が更新されないからです。

UpdateWindow 関数の呼び出しを明示的に行う事で更新領域が存在するステータスバーのウィンドウに対して WM_PAINT メッセージがきちんと送られるようになりウィンドウの表示内容がきちんと更新されます。

PR の影響範囲

ステータスバーの描画処理

テスト内容

テスト1

  • 何かファイルを開く
  • 別の文字コードでファイルを開きなおしてステータスバーの表示が更新される事を確認する
  • カーソルキーを動かした際にステータスバーの表示が更新される事を確認する

関連 issue, PR

#1637, #1601

参考資料

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-updatewindow

https://docs.microsoft.com/en-us/windows/win32/controls/sb-settext

https://docs.microsoft.com/en-us/windows/win32/gdi/wm-setredraw

@beru beru added the 🐛bug🦋 ■バグ修正(Something isn't working) label Apr 23, 2021
@sonarcloud
Copy link

sonarcloud bot commented Apr 23, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@AppVeyorBot
Copy link

Build sakura 1.0.3702 completed (commit f1b86dab3a by @beru)

@beru
Copy link
Contributor Author

beru commented Apr 23, 2021

レビューありがとうございます。Mergeします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug🦋 ■バグ修正(Something isn't working)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants