Recent

Author Topic: Trouble when creating custom TComboBox component  (Read 3112 times)

darkdata

  • New Member
  • *
  • Posts: 13
Trouble when creating custom TComboBox component
« on: March 26, 2015, 05:19:49 pm »
Hi all,

I'm having trouble creating a TCustomComboBox component. I'm overriding Dropdown but it seems like the event never gets fired?

Code: [Select]
  TTDComboBox = class(TCustomComboBox)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure DropDown; override;
Code: [Select]
procedure TTDComboBox.DropDown;
var
  i: Integer;
begin
//just a test
//SendMessage(Self.Handle, CB_SETDROPPEDWIDTH, ItemWidth, 0);
Self.Perform(CB_SETDROPPEDWIDTH, 100, 0);

What am I doing wrong here?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Trouble when creating custom TComboBox component
« Reply #1 on: March 26, 2015, 06:36:58 pm »
Perform() executes LCL code only. I presume you want so actually send the message to actual Windows control. Use Windows.SendMessage for that.

darkdata

  • New Member
  • *
  • Posts: 13
Re: Trouble when creating custom TComboBox component
« Reply #2 on: March 26, 2015, 08:16:40 pm »
I tried both. The SendMessage/Self.Perform pieces work fine with OnDropDown event of a TComboBox.

Here's a link to something similar I'm trying to achieve: http://www.delphicorner.f9.co.uk/articles/comps11.htm

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Trouble when creating custom TComboBox component
« Reply #3 on: March 26, 2015, 08:31:45 pm »
are you saying it works with TComboBox but not working with TCustomComboBox?
Are there other changes made? because it works with for TCustomComboBox as well.

darkdata

  • New Member
  • *
  • Posts: 13
Re: Trouble when creating custom TComboBox component
« Reply #4 on: March 26, 2015, 08:53:04 pm »
Could you try making a TCustomComboBox package/component? That's where I seem to have the trouble.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Trouble when creating custom TComboBox component
« Reply #5 on: March 26, 2015, 09:32:10 pm »
i presume you didn't use SendMesssage after all.

Anyways. here's the package and a project that's using the package. Works as expected (on windows)

As soon as package is installed and Lazarus is rebuilt you'll see "dark data" tab where the dropdown resides.
« Last Edit: March 26, 2015, 09:38:52 pm by skalogryz »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Trouble when creating custom TComboBox component
« Reply #6 on: March 26, 2015, 09:39:07 pm »
I've just attached the package zip file. Not sure why didn't load the last time.

darkdata

  • New Member
  • *
  • Posts: 13
Re: Trouble when creating custom TComboBox component
« Reply #7 on: March 26, 2015, 09:45:27 pm »
Ok yours works. You can see that I did try to use SendMessage above though in my original post. When I created a component I did not get the extra file for the registration of the component like yours has. I'll have to dig to figure out how I missed this. Thanks.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Trouble when creating custom TComboBox component
« Reply #8 on: March 26, 2015, 09:54:48 pm »
When I created a component I did not get the extra file for the registration of the component like yours has.
I didn't get it too. I created one myself.

 

TinyPortal © 2005-2018