Restrict TComboBox dropdown lazarus / 31-LCL ---------------------------------------------------------------------- Blaazen · 2014-09-02 21:12 Hi, any idea how to restrict TComboBox dropdown - other than Enabled:=False? I'm working on TCheckComboBox. It is readonly, Style=csOwnerDrawFixed. See screenshot. I need that - let's say - left half of the component will toggle the state while right half will dropdown list. It is probably not problem with Windows (it has always "Edit") but GTK2 and Qt4 always dropdown (on left-mouse down). Currently, I hooked on WMLButtonDown(); which is triggered before dropdown but I cannot find way to restrict dropdown. I tried for example: Code: [Select]ControlState:=ControlState-[csLButtonDown, csClicked];I guess it is not easy since it is native component. Thanks. ---------------------------------------------------------------------- engkin · 2014-09-03 01:05 Based on reading the source code (and only reading): GTK2: Code: [Select]class procedure TGtk2WSCustomComboBox.SetDroppedDown( ...   case ADroppedDown of     True : gtk_combo_box_popup(Combo);     False: gtk_combo_box_popdown(Combo);   end; end; In GTK2, gtk_combo_box_pop[up/down]  are called only in:   TGtk2WSCustomComboBox.SetDroppedDown which is called directly/indirectly through:   TCustomComboBox     procedure KeyDown - using property DroppedDown     property DroppedDown     procedure SetDroppedDown - setter of property DroppedDown I assume if you override SetDroppedDown and pass the call to it when you want or neglect the call when you don't need it to go through seems to be ok, maybe? ---------------------------------------------------------------------- Never · 2014-09-03 06:21 This might give you an idea http://embarcadero.newsgroups.archived.at/public.delphi.vcl.components .using/200910/0910223332.html or maybe a coditional call to Abort in ondropdown event? ---------------------------------------------------------------------- Blaazen · 2014-09-03 11:47 I tried message-methods approach and overriding SetDroppedDown as well but no luck. ---------------------------------------------------------------------- Never · 2014-09-03 13:11 This Code: [Select]procedure TForm1.ComboBox1DropDown(Sender: TObject); begin   Abort; end; blocks the list to drop down Also this one Code: [Select]procedure TForm1.ComboBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin   ComboBox1.Style:=csSimple; end; procedure TForm1.ComboBox1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin   ComboBox1.Style:=csOwnerDrawFixed end; but needs screen to stop update until  mouse up ---------------------------------------------------------------------- Blaazen · 2014-09-03 13:44 Yes but only in Windows. It has no effect in Qt and it blocks GTK2 so I have to execute: killall -9 gdb ---------------------------------------------------------------------- Blaazen · 2014-09-03 14:20 I will solve it with TTimer with a very small interval (~5 ms). It seems to be the only way. ---------------------------------------------------------------------- Never · 2014-09-03 16:30 i think i found something Code: [Select]procedure TForm1.ComboBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin    ComboBox1.DroppedDown:=false; end; does the job easy and clean ---------------------------------------------------------------------- Blaazen · 2014-09-03 16:40 It doesn't work on Qt4 and GTK2 too. ---------------------------------------------------------------------- Never · 2014-09-03 17:05 just read this [ http://qt-project.org/forums/viewthread/3150  ] for qt is it possible ? to change the width, height and border style of the dropdown area and reset it back again ? ---------------------------------------------------------------------- zeljko · 2014-09-04 08:16 Quote from: Blaazen on September 02, 2014, 11:12:54 pmCurrently, I hooked on WMLButtonDown(); which is triggered before dropdown but I cannot find way to restrict dropdown. Just set Msg.Result to 1 in WMLButtonDown(), then it should result with TRUE in WS and that should work. ---------------------------------------------------------------------- Blaazen · 2014-09-04 08:30 Thanks, but it doesn't work too. And I wasn't right, DropDown is triggered before WMLButtonDown. ---------------------------------------------------------------------- Blaazen · 2014-09-04 09:19 Finally, I hooked on DrawItem();, there's a negligible flickering but it's better solution than TTimer. ---------------------------------------------------------------------- zeljko · 2014-09-04 12:01 Quote from: Blaazen on September 04, 2014, 10:30:39 amThanks, but it doesn't work too. And I wasn't right, DropDown is triggered before WMLButtonDown. hm....strange. My wild guess is that it should trigger in order mousedown,dropdown,mouseup (if mouseup need to be triggered). How it looks in delphi ? ---------------------------------------------------------------------- Blaazen · 2014-09-04 13:22 Quick test in Delphi7: DropDown is before MouseDown too, so in this regard is Lazarus compatible. ---------------------------------------------------------------------- zeljko · 2014-09-04 16:35 Quote from: Blaazen on September 04, 2014, 03:22:54 pmQuick test in Delphi7: DropDown is before MouseDown too, so in this regard is Lazarus compatible. Pretty bad logic,since mouse button IS pressed before any action can start, so basically mouse down happens before dropdown. ---------------------------------------------------------------------- Never · 2014-09-04 19:39 Looks like that this is the reason everything else is not working also a strange order firing the event