Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

passing the current control to a component

5 views
Skip to first unread message

Sean Farrow

unread,
May 13, 2008, 8:30:56 AM5/13/08
to
Hi:
I need to pass the current control the user is siting on to the component
created in the controls class. Basically I am modifying the TCheckList box
for accessibility, I need the new class that derives the IAccessible
implementatios's create procedure to look like:
TCheckLostAccessible.create(CheckList: TChecklistbox);
How do I obtain the CheckLostBox from tit's own class would hte handle
poperty be good enough or is there some other way.
Sean.


Remy Lebeau (TeamB)

unread,
May 13, 2008, 2:22:11 PM5/13/08
to

"Sean Farrow" <sean....@seanfarrow.co.uk> wrote in message
news:4829...@newsgroups.borland.com...

> I need to pass the current control the user is siting on to
> the component created in the controls class.

I don't understand what you are referring to. Please clearify.

> Basically I am modifying the TCheckList box for accessibility,
> I need the new class that derives the IAccessible implementatios's
> create procedure to look like:
> TCheckLostAccessible.create(CheckList: TChecklistbox);

Why not derive TCheckListAccessible directly from TCheckListBox, instead of
trying to attach it to a separate object?

type
TCheckListAccessible = class(TCheckListBox, IAccessible)
...
end;

That way, IAccessible has direct access to the TCheckListBox and its
members. You coudl then use TCheckListAccessible instead of a normal
TCheckListBox in your UI.

> How do I obtain the CheckLostBox from tit's own class

Since you are already passing the TCheckListBox pointer to your
TCheckListAccessible constructor, why not just store it as a member of the
class? Then you don't have to go hunting around for it at all, ie:

type
TCheckListAccessible = class(IAccessible)
private
FListBox: TCheckListBox;
...
public
constructor Create(ACheckList: TCheckListBox);
end;

constructor TCheckListAccessible.Create(ACheckList: TCheckListBox);
begin
inherited Create;
FListBox := ACheckList;
end;

Better would be to derive TCheckListAccessible from TComponent so you can
hook up the TCheckListBox to the TCheckListAccessible at design time, ie:

type
TCheckListAccessible = class(TComponent, IAccessible)
private
FListBox: TCheckListBox;
procedure SetListBox(Value: TCheckListBox);
...
protected
procedure Notification(AComponent: TComponent: Operation:
TOperation); override;
...
published
property ListBox: TCheckListBox read FListBox write SetListBox;
end;

procedure TCheckListAccessible.SetListBox(Value: TCheckListBox);
begin
if FListBox <> Value then
begin
if FListBox <> nil then FListBox.RemoveFreeNotification(Self);
FListBox := Value;
if FListBox <> nil then FListBox.FreeNotification(Self);
end;
end;


procedure TCheckListAccessible.Notification(AComponent: TComponent:
Operation: TOperation);
begin
inherited;
if (FListBox = AComponent) and (Operation = opRemove) then
FListBox := nil;
end;


Gambit


Sean Farrow

unread,
May 13, 2008, 2:58:09 PM5/13/08
to
Hi:
The first option will work of passing TCheckListBoxes pointer to
TCheckListAccessible in the create constructor. What property of the
TCheckListBox do I pass to TCheckListAccessible? self.
Sean. p...@no.spam.com> wrote in message
news:4829dc74$1...@newsgroups.borland.com...
0 new messages