Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
beru wants to merge3 commits intosakura-editor:master
base:master
Choose a base branch
Loading
fromberu:use_darkmodelib
Draft

Conversation

@beru
Copy link
Contributor

PR対象

  • アプリ(サクラエディタ本体)

カテゴリ

  • 追加

PR の背景

#594 (comment)

仕様・動作説明

PR の影響範囲

テスト内容

関連 issue, PR

参考資料

https://github.com/ozone10/darkmodelib

@beruberu added the enhancement■機能追加 labelAug 30, 2025
#include"version.h"
#include"util/std_macro.h"
#include"env/DLLSHAREDATA.h"
#include"DarkModeSubclass.h"
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

このスレではDarkMode対応を行うにあたって壁に突き当たった点を記載します。

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

タイプ別設定のキーワードヘルプの辞書ファイル一覧のリストビューの背景色が明色になっていてDarkModeらしくない。

image

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

image

この挙動は Win32DarkmodelibGUIDemo でも同様で、リストビューのウィンドウが無効化されている場合にListView_SetBkColor で設定した色 (link) が使われない。

この問題を解決するにはオーナードローを行うしか無さそう。

notepad-plus-plus/notepad-plus-plus#13933 でも同様の問題が報告されている。

Copy link
ContributorAuthor

@beruberuAug 31, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

93b9bdfCMenuDrawer::DrawItem を更新してメニューアイテムがDarkModeっぽく描画されるようにしてみたけれど、メニューの外枠の枠線の色がDarkModeっぽくない。

image

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

image

https://learn.microsoft.com/en-us/answers/questions/649537/how-to-change-color-or-remove-pop-menu-border-in-m のCastorix31さんのコメントによるとメニューのウィンドウがWS_EX_DLGMODALFRAME 拡張スタイル付きなのが原因なようでSetWindowLongGWL_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);

Copy link
ContributorAuthor

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 のコードが参考になりそう。

Copy link
ContributorAuthor

@beruberuSep 1, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

メニュー項目のオーナードロー(link)を行わないようにしたらメニューの枠線がちゃんとDark Modeっぽく表示される事に気づきました。

image

メニューのアイコン描画をオーナードローで自前で行うのではなくて標準の方法で行うように変える必要があります。

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

WinMergeの新しい版 (Version 2.16.50.5 + jp-5 X64) だとメニューの枠の色が以前と比べて良くなってました。

image

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

共通設定のタブバーのプロパティシートで「タブバーを表示する」のチェックが付いていないと色々なコントロールが無効化状態に設定されますが、プロパティシートを切り替えて表示する際にラベルの表示が変になります。

image

プロパティシートが表示された後に「タブバーを表示する」のチェックを付けて外すと表示は問題無いです。

imageimage

Dark Mode対応の為にCPropCommon::DlgProccase WM_INITDIALOGDarkMode::setDarkWndSafe を呼び出す事でサブクラス化されてWM_CTLCOLORSTATIC メッセージが処理されてDarkMode::onCtlColorDlgStaticText の戻り値でブラシを返して背景色を変えてますが、これが関係しているようです。OS側(user32.dll)の実装の不具合なのかわかりませんがタイミングによってはきちんと思ったように処理されないようです。

@beruberuforce-pushed theuse_darkmodelib branch 9 times, most recently from5359d59 to238a2deCompareOctober 28, 2025 13:02
@beruberuforce-pushed theuse_darkmodelib branch 4 times, most recently fromea5a039 tob2d5699CompareNovember 3, 2025 10:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

enhancement■機能追加

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@beru

[8]ページ先頭

©2009-2025 Movatter.jp