Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 30 of 36 total
Thread Some Questions About TCheckBox
Mon, Feb 12 2018 9:12 AMPermanent Link

Frederick Chin

"Matthew Jones" wrote:

/*
Yes - you just need to define a new component and set its interfaces. The documentation has info on this - I think there may be an article on the web site too. Have a search, and ask if you can't find it. (I'm away from EWB myself at the moment so can't point you, sorry)
*/

Thanks. I'll check it out.

--
Frederick
Mon, Feb 12 2018 4:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< Is there a way to have the original TCheckbox retain the caption on the right while my modified interface apply to a derived component from TCheckbox, which I call TMyCheckBox. >>

Yes, just make sure that you:

1) Rename your control interface file to TMyCheckBox.wbi.

2) In the EWB IDE, open the TMyCheckBox.wbi control interface and make sure that the class name for the interface is set to TMyCheckBox instead of TCheckBox.

3) In your TMyCheckBox source code, make sure that you include this line:

  {$INTERFACE TMyCheckBox}

before the TMyCheckBox class declaration.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 12 2018 8:26 PMPermanent Link

Frederick Chin

Tim,

/*
1) Rename your control interface file to TMyCheckBox.wbi.
*/

I have the following three interface files for TCheckBox and they all have the captions on the left:-

tcheckboxindeterminate.wbi
tcheckboxselected.wbi
tcheckboxunselected.wbi

Should I rename them to

tmycheckboxindeterminate.wbi
tmycheckboxselected.wbi
tmycheckboxunselected.wbi

or copy the first one to

tmycheckbox.wbi?

/*
2) In the EWB IDE, open the TMyCheckBox.wbi control interface and make sure that the class name for the interface is set to TMyCheckBox instead of TCheckBox.
*/

I did this for all three plus the tmycheckbox.wbi. Interestingly, the original class names for the interface for all three wbi files were the file names themselves instead of TCheckBox. So, for tcheckboxindeterminate.wbi, the class name was tcheckboxindeterminate and so on.

/*
3) In your TMyCheckBox source code, make sure that you include this line:

  {$INTERFACE TMyCheckBox}

before the TMyCheckBox class declaration.
*/

I did this but I had to copy one of the original wbi files to tmycheckbox.wbi to compile.

After I did all the above, EWB's original TCheckBox now has the caption on the right but my TMyCheckBox also shows the caption on the right.

I have double checked the wbi files and they all show the caption on the left.

What am I missing here?

--
Frederick
Thu, Feb 15 2018 12:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< Should I rename them to >>

This.

<< I did this for all three plus the tmycheckbox.wbi. Interestingly, the original class names for the interface for all three wbi files were the file names themselves instead of TCheckBox. So, for tcheckboxindeterminate.wbi, the class name was tcheckboxindeterminate and so on. >>

Sorry, that was my mistake - I forgot that the check box control interfaces were broken up by their check box state designation.

<< I did this but I had to copy one of the original wbi files to tmycheckbox.wbi to compile. >>

This again was a mistake - make sure that you include all 3 files using the {$INTERFACE xxx} directive and should fix any issues.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 19 2018 6:13 PMPermanent Link

Frederick Chin

Tim,

/*
This.
*/

I renamed all three interfaces to TMyCheckBox???.wbi.

/*
Sorry, that was my mistake - I forgot that the check box control interfaces were broken up by their check box state designation.
*/

I changed all three interface class names to follow the names of interface file names.

/*
This again was a mistake - make sure that you include all 3 files using the {$INTERFACE xxx} directive and should fix any issues.
*/

I added all three files.

Now, the captions are still showing on the right for both TCheckBox and TMyCheckBox.

If I change the interface class names to TCheckBox??? from TMyCheckBox???, the captions will be on the left for both TCheckBox and TMyCheckBox.

--
Frederick
Tue, Feb 20 2018 4:53 AMPermanent Link

Uli Becker

Frederick,

just post your component and the interface files here.

Uli
 
Tue, Feb 20 2018 9:20 AMPermanent Link

Frederick Chin

Uli,

/*
just post your component and the interface files here.
*/

Please find attached.

--
Frederick



Attachments: interfaces.zip
Tue, Feb 20 2018 10:20 AMPermanent Link

Uli Becker

Frederick,

> Please find attached.

There are issues in both your component code AND your interfaces.

Here the correct component code (you have to override the GetInterfaceClassName procedure):

unit MyCheckBox;

interface

uses WebCore, WebUI, WebCtrls, WebBtns;

type

 {$INTERFACE TMyCheckBoxIndeterminate}
 {$INTERFACE TMyCheckBoxSelected}
 {$INTERFACE TMyCheckBoxUnselected}
 
   TMyCheckBox = class(TCheckBox)
      private
         { Private declarations }
      protected
         { Protected declarations }
         function GetInterfaceClassName: String; override;
      public
         { Public declarations }
      published
         { Published declarations }
         property PushKeys;
      end;

implementation

function TMyCheckBox.GetInterfaceClassName: String;
begin
   case SelectionState of
      ssIndeterminate:
         Result := TMyCheckBox.ClassName + INDETERMINATE_CLASS_NAME;
      ssSelected:
         Result := TMyCheckBox.ClassName + SELECTED_CLASS_NAME;
      ssUnselected:
         Result := TMyCheckBox.ClassName + UNSELECTED_CLASS_NAME;
      else
         Result := '';
      end;
end;

end.

With all 3 interfaces you have to modify the "Interface Class Name" so that it matches the new class name.
I attached 2 screenshots (wrong and correct).

Uli






Attachments: wrong.png correct.png
Tue, Feb 20 2018 6:10 PMPermanent Link

Frederick Chin

Uli,

/*
There are issues in both your component code AND your interfaces.

Here the correct component code (you have to override the GetInterfaceClassName procedure):
*/

Thanks for your help. I now have two check boxes that have different properties.

I totally had no idea that I needed to create the procedure for the changes to work. (I did know about the interface class name change but it had no effect before)

Is the procedure necessary for all interface changes or does it apply to TCheckBox because it uses 3 interface files?

--
Frederick
Wed, Feb 21 2018 3:45 AMPermanent Link

Uli Becker

Frederick,

> Is the procedure necessary for all interface changes or does it apply to TCheckBox because it uses 3 interface files?

It's *always* necessary to override this function if you want to use a
modified interface. If you skip that, TMyCheckBox will use the TCheckBox
interface(s).

BTW: it helps if you have a look at the sources of existing (custom)
components (a number of them were posted in the "Components" NG) in
order to understand the basics.

Uli

« Previous PagePage 3 of 4Next Page »
Jump to Page:  1 2 3 4
Image