- Notifications
You must be signed in to change notification settings - Fork175
Dark Modeへの対応#2135
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Dark Modeへの対応#2135
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| #include"version.h" | ||
| #include"util/std_macro.h" | ||
| #include"env/DLLSHAREDATA.h" | ||
| #include"DarkModeSubclass.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
このスレではDarkMode対応を行うにあたって壁に突き当たった点を記載します。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
タイプ別設定のキーワードヘルプの辞書ファイル一覧のリストビューの背景色が明色になっていてDarkModeらしくない。

「キーワードヘルプ機能を使う」のチェックを入れてリストビューのウィンドウを有効化すると背景色が暗色になってDarkModeらしくなる。

この挙動は Win32DarkmodelibGUIDemo でも同様で、リストビューのウィンドウが無効化されている場合にListView_SetBkColor で設定した色 (link) が使われない。
この問題を解決するにはオーナードローを行うしか無さそう。
notepad-plus-plus/notepad-plus-plus#13933 でも同様の問題が報告されている。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
93b9bdf でCMenuDrawer::DrawItem を更新してメニューアイテムがDarkModeっぽく描画されるようにしてみたけれど、メニューの外枠の枠線の色がDarkModeっぽくない。

この問題はWinMergeでも起きている。

https://learn.microsoft.com/en-us/answers/questions/649537/how-to-change-color-or-remove-pop-menu-border-in-m のCastorix31さんのコメントによるとメニューのウィンドウがWS_EX_DLGMODALFRAME 拡張スタイル付きなのが原因なようでSetWindowLong とGWL_EXSTYLE を使ってその拡張スタイルを削れば枠線を消せるらしい。WM_INITMENUPOPUP でそれを行うと書かれているが実際にはWM_INITMENUPOPUP メッセージ処理時点ではまだウィンドウが作成されていない場合にはFindWindow をしても取れない。HWNDを取るのにタイマーやフックを使う事が出来るようだが、ここまでするならメニューを自前のウィンドウで描画しても良いのでは?という気がしてくる。。
HWND hWndPopupMenu = FindWindow(TEXT("#32768"),NULL);auto exStyle = ::GetWindowLongPtr(hWndPopupMenu, GWL_EXSTYLE);::SetWindowLongPtr(hWndPopupMenu, GWL_EXSTYLE, exStyle & ~WS_EX_DLGMODALFRAME);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
https://fenix-pc.blog.jp/archives/27561302.html のコードが参考になりそう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
メニュー項目のオーナードロー(link)を行わないようにしたらメニューの枠線がちゃんとDark Modeっぽく表示される事に気づきました。
メニューのアイコン描画をオーナードローで自前で行うのではなくて標準の方法で行うように変える必要があります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
共通設定のタブバーのプロパティシートで「タブバーを表示する」のチェックが付いていないと色々なコントロールが無効化状態に設定されますが、プロパティシートを切り替えて表示する際にラベルの表示が変になります。
プロパティシートが表示された後に「タブバーを表示する」のチェックを付けて外すと表示は問題無いです。
Dark Mode対応の為にCPropCommon::DlgProc のcase WM_INITDIALOG でDarkMode::setDarkWndSafe を呼び出す事でサブクラス化されてWM_CTLCOLORSTATIC メッセージが処理されてDarkMode::onCtlColorDlgStaticText の戻り値でブラシを返して背景色を変えてますが、これが関係しているようです。OS側(user32.dll)の実装の不具合なのかわかりませんがタイミングによってはきちんと思ったように処理されないようです。
5359d59 to238a2deCompareea5a039 tob2d5699Compare




PR対象
カテゴリ
PR の背景
#594 (comment)
仕様・動作説明
PR の影響範囲
テスト内容
関連 issue, PR
参考資料
https://github.com/ozone10/darkmodelib