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

Windows 10 SDKのメッセージクラッカーを使えるようにする #1742

Merged
merged 2 commits into from
Oct 13, 2021

Conversation

sanomari
Copy link
Contributor

@sanomari sanomari commented Oct 11, 2021

PR の目的

メッセージクラッカーを使えるようにして開発効率を上げます。

カテゴリ

  • リファクタリング

PR の背景

Windows APIでプログラムをしたい人のためにメッセージクラッカーというものがあります。

https://www.keicode.com/windows/win02.php

そのままでは使えなかったので使えるようにするための修正とセットで導入提案する次第です。

PR のメリット

既定のメッセージクラッカーを流用できるようになるので、開発効率が上がります。

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

プログラミングの自由度(?)が下がります。

仕様・動作説明

サクラエディタの仕様・機能に影響を与える変更じゃないです。

メッセージクラッカーのヘッダーファイル(windowsx.h)に定義されているマクロ関数と名前が衝突する関数をリネームします。

ただし、名前が衝突した関数 DeleteFont は複数のフォントハンドルを解放する関数でした。

PR の影響範囲

メッセージクラッカーのヘッダーファイル(windowsx.h)に定義されているマクロ関数と同名の関数を定義できなくなります。

テスト内容

テスト1

手順

関連 issue, PR

参考資料

Windows10 SDKに定義されているプロトタイプを流用できるようにして開発効率を上げる。
サクラエディタはWinUIもATLもMFCも使わないのでメッセージハンドラ関数を完全に独自定義していた。
完全独自だとメッセージ仕様からwParamとlParamの扱い方を個別に判断する必要があって無駄。
変更前: CViewFont::DeleteFont();
変更後: CViewFont::DeleteFonts( void );

SDKのマクロとの衝突を回避するため。

変更前: CViewFont::CreateFont(const LOGFONT* plf);
変更後: CViewFont::CreateFonts( const LOGFONT* plf );

Deleteと名称を揃えるため。
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    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.3955 completed (commit e81ca7e705 by @sanomari)

Copy link
Contributor

@berryzplus berryzplus left a comment

Choose a reason for hiding this comment

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

問題ないと思います。

@@ -66,8 +66,8 @@ class CViewFont{
}

private:
void CreateFont(const LOGFONT *plf);
void DeleteFont();
void CreateFonts( const LOGFONT *plf );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void CreateFonts( const LOGFONT *plf );
void CreateFonts( const LOGFONT &lf );

という指摘はしないほうが良さそうです。
PRの問題ではなくてCViewFontクラスの設計的な問題だから。

@beru beru added the refactoring リファクタリング 【ChangeLog除外】 label Oct 11, 2021
@berryzplus
Copy link
Contributor

ん?メッセージトラッカー?

@sanomari sanomari merged commit 7858990 into sakura-editor:master Oct 13, 2021
@sanomari sanomari deleted the feature/use_windowsx_h branch October 13, 2021 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring リファクタリング 【ChangeLog除外】
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants