TComboBox.DropDownCountがクラシックスタイル環境で有効にならない
対象となるIDE製品
- Delphi 2007 ~ XE5
問題
以下の2つの条件を満たした時、TComboBox.DropDownCountが有効になりません。
- Windows Vista以降で、クラシックスタイルに設定
- Delphiのランタイムテーマが有効
例えば、TComboBoxのDropDownCount=8に設定している場合、
上記の2つの条件を満たしたとき、図2のような画面表示になり、TComboBox.DropDownCountが有効になりません。
解決
この問題を解決するには、以下のユニットファイルを修正し、自身のプロジェクトへ組み込んでください。
2007~ XEの場合:
修正するファイル名(StdCtrls.pas)
TCustomCombo.CreateWnd
//(修正前)
if CheckWin32Version(5, 1) and ThemeServices.ThemesEnabled then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(DropDownCount), 0);
//(修正後)
if CheckWin32Version(5, 1) and ThemeServices.ThemesAvailable then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(DropDownCount), 0);
TCustomCombo.SetDropDownCount
//(修正前)
if HandleAllocated and CheckWin32Version(5, 1) and ThemeServices.ThemesEnabled then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(FDropDownCount), 0);
//(修正後)
if HandleAllocated and CheckWin32Version(5, 1) and ThemeServices.ThemesAvailable then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(FDropDownCount), 0);
XE2~XE5の場合:
修正するファイル名(Vcl.StdCtrls.pas)
TCustomCombo.CreateWnd
//(修正前)
if CheckWin32Version(5, 1) and StyleServices.Enabled then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(DropDownCount), 0);
//(修正後)
if CheckWin32Version(5, 1) and StyleServices.Available then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(DropDownCount), 0);
TCustomCombo.SetDropDownCount
//(修正前)
if HandleAllocated and CheckWin32Version(5, 1) and StyleServices.Enabled then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(FDropDownCount), 0);
//(修正後)
if HandleAllocated and CheckWin32Version(5, 1) and StyleServices.Available then
SendMessage(Handle, CB_SETMINVISIBLE, WPARAM(FDropDownCount), 0);