1

I am trying to hide the dropdown button in a third party component that derives from TComboBox.

I tried setting the style to csSimple, but this solution does not work for me... There is code in the third party component that checks for csSimple in various places. I would prefer not to change this code.

From what I can see from other posts, others have suggested using a different component, eg, a textbox, or covering the dropdown arrow with something to hide it. I want to avoid these solutions too.

Is there any other way? I was thinking maybe there is a way to do this with PostMessage/SendMessage, but I don't know what to pass as params.

Thank you

sse
  • 987
  • 1
  • 11
  • 30
  • 4
    It is probably unwise to compete against the control. – Andreas Rejbrand Nov 28 '11 at 19:57
  • I agree with Andreas. Why the need to use this custom control that doesn't work for what you need? I've looked through [MSDN Combo Box](http://msdn.microsoft.com/en-us/library/windows/desktop/bb775792(v=vs.85).aspx) and there isn't any way to hide the combo button without setting the style to simple, that I can find at least. – Jerry Gagnon Nov 28 '11 at 20:15
  • Thanks for checking MSDN. There are circumstances when working with Legacy code that necessitate these sorts of things. I may wind up writing my own component, but a simple winmsg to hide the button would be a really helpful. – sse Nov 28 '11 at 20:54
  • @sse: But what if the control brings it back the next time the cursor is placed on the control (say)? – Andreas Rejbrand Nov 28 '11 at 21:05
  • 1
    duplicate: [make ComboBox drop-down button invisible in Delphi?](http://stackoverflow.com/q/7437201/243614). If you've revealed the (3rd) party, someone might have provided an answer as in the other question. – Sertac Akyuz Nov 29 '11 at 02:13
  • 1
    @SertacAkyuz: We are using the JVCL. Two components, The first is TJvDBLookupComboEdit, which ultimately inherits from a TCustomMaskEdit (not a TCustomComboBox), they actually have a FShowButton property which we were able to tap into. The second one is TJvDBComboBox, which does inherit from a TCustomComboBox. This is the one I am having trouble with. Thank you! – sse Nov 29 '11 at 14:15

1 Answers1

0

Serge Goncharov from AlphaControls came up with a very dark (but operational) solution to this. It involves access to the top two private variables of TDBLookupControl, FDataList and FButtonWidth.

His solution works as follows:

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBCtrls, sDBLookupComboBox, StdCtrls, sCheckBox, XPMan,
  sSkinProvider, sSkinManager;

type
  TForm1 = class(TForm)
    DBLookupComboBox1: TDBLookupComboBox;
    CheckBox1: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  StoredWidth: integer;

implementation

{$R *.dfm}

type
  TAccessLookUpCombo = class(TDBLookupControl)
  public
    FDataList: TPopupDataList;
    FButtonWidth: Integer;
  end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then
    TAccessLookUpCombo(DBLookupComboBox1).FButtonWidth := StoredWidth
  else begin
    StoredWidth := TAccessLookUpCombo(DBLookupComboBox1).FButtonWidth;
    TAccessLookUpCombo(DBLookupComboBox1).FButtonWidth := 0;
  end;
  DBLookupComboBox1.Invalidate;
end;

end.

With the TAccessLookUpCombo(DBLookupComboBox1) construct, you access the parent's TDBLookupControl top values. Very ugly indeed, but it happens to work.

Rocky Luck
  • 111
  • 2
  • 7