掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Comboboxのドロップダウンリストの方向について (ID:37737)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
MSDNに例ありましたよ。 WM_CTLCOLORLISTBOXのタイミングたベターらしいです。 せっかくなのでDelphiで書き直しておきました。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TComboBoxEx = class(TComboBox) private FComboDefaultProc: TWndMethod; constructor Create(AOwner: TComponent); override; procedure ComboProc(var Message: TMessage); end; TForm1 = class(TForm) private { Private 宣言 } ComboBoxEx : TComboBoxEx; public { Public 宣言 } constructor Create(AOwner: TComponent); override; end; var Form1: TForm1; implementation {$R *.dfm} { TComboBoxEx } //http://msdn.microsoft.com/ja-jp/library/ms996411.aspx procedure TComboBoxEx.ComboProc(var Message: TMessage); var aPos:TPoint; const topMgn = 2; begin if (Message.Msg = WM_CTLCOLORLISTBOX) then begin aPos := Point(Left,Top); aPos := ClientToScreen(aPos); if DropDownCount < Items.Count then aPos.Y := aPos.Y - (DropDownCount * ItemHeight) -topMgn else aPos.Y := aPos.Y - (Items.Count * ItemHeight) -topMgn ; if aPos.Y >= 0 then SetWindowPos(Message.LParam, 0,aPos.X,aPos.Y,0,0, SWP_NOSIZE); end; FComboDefaultProc(Message); end; constructor TComboBoxEx.Create(AOwner: TComponent); begin inherited; FComboDefaultProc:=WindowProc; WindowProc := ComboProc; end; constructor TForm1.Create(AOwner: TComponent); var i:Integer; begin inherited; ComboBoxEx := TComboBoxEx.Create(self); ComboBoxEx.Parent := Self; for i := 0 to 10 do ComboBoxEx.Items.Add(IntToStr(i)); ComboBoxEx.ItemIndex := 0; end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.