AZO234 / NP2kai

Neko Project II kai
http://domisan.sakura.ne.jp/article/np2kai/np2kai.html
MIT License
260 stars 61 forks source link

[Win] Fixed a problem with the filter of the file open dialog #122

Closed miyamoto999 closed 3 years ago

miyamoto999 commented 4 years ago

Windows(VS2019 build)でFDDやHDDのファイル選択ダイアログでフィルターコンボボックスの表示がおかしいのを改修してみたした。

たまたま見つけて比較的簡単に直せそうだったので直してみました。

不具合

フィルターコンボボックスがこのようになっていました。

2020-10-06 (2)

原因

OPENFILENAMEW構造体のlpstrFilterに設定する値に問題があった。フィルター名とワイルドカードの区切りが'|’になっていた。区切りは'\0'が正しい。

変更点

  1. ucs2に変換後のフィルターに設定する値の'|'を'\0'に変換する処理を入れた。
  2. utf8からucs2に変換後の値を入れる配列変数が小さかったのでcallocで動的に確保するようにした。
  3. 2.でucs2に変換後の文字数が必要だったのでcodecnv_utf8toucs2()で文字数を取得できるようにした。

ということで、よろしくお願いします。

↓英訳。相変わらず翻訳ツールの力を結構借りてます💦


The display of the filter combo box in the file open dialog of FDD and HDD on Windows (VS2019 build) was fixed.

I happened to find it and it seemed relatively easy to fix, so I fixed it.

Problem

The filter combo box looked like this.

2020-10-06 (2)

Cause

There was a problem with the value set to lpstrFilter in the OPENFILENAMEW structure. The filter name and wildcards are separated by '|'. The right delimiter is '\0'.

Changes

  1. I added a process to convert '|' to '\0' in the filter string after conversion to ucs2.
  2. The array for the converted value from utf8 to ucs2 was too small, so I used calloc to allocate memory dynamically.
  3. I needed the number of characters after conversion to ucs2 in 2., so I used codecnv_utf8toucs2() to get the number of characters.So I changed codecnv_utf8toucs2() to get the number of characters.
AZO234 commented 3 years ago

Thank you! Sorry to my miss coding...

Your idea that pipe(|) to nul(\0) is very cool!! I like it.♥

I checked these dialog box. OK. fd1 fd2 fd3