Board index » delphi » Accessing statusBar panels from a class through pointers

Accessing statusBar panels from a class through pointers

Hi everybody,

I have a class that performs some tasks like connecting to a server and
retrieving some info. I would like to inform the user about the status
of the processing. I though about defining a class property as a pointer
to some other object so that through that class property I would be
accessing the other object's properties. That way I could, for instance,
write to the text property of a StatusBar panel directly from within a
class. I don't know if this sounds crazy, but I gave it a try.

I tried doing the following:

In my class, I defined the following Type and properties:

Type PStatusPanel = ^TStatusPanel;

[..]
Type TMyClass = class
Private
        m_InfoReceiver: PStatusPanel;
Public
        property InfoReceiver: PStatusPanel read m_InfoReceiver write
m_InfoReceiver;

Then I thought to put some code like this when the class was performing
something:

if assigned(InfoReceiver) then InfoReceiver.Text := 'Some Text';

The problem is, when I make an instance of TMyClass, I cannot do the
following:

MyClass.InfoReceiver := @sbMain.Panels[0];      

where sbMain is a status Bar because I get a "variable required" error
at compile time.

Any clues ?

Thank you.

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

 

Re:Accessing statusBar panels from a class through pointers


I would just create a call back in the area the owns that status panel.
When you need to update it call the call back with the message. The call
back would set a local variable.

Then in the status panel draw area, I'd read from the local variable and
output...

Bill Nortman
http://www.geocities.com/bnortman/delphi.html

Quote
Ettore Carrara wrote:
> Hi everybody,

> I have a class that performs some tasks like connecting to a server and
> retrieving some info. I would like to inform the user about the status
> of the processing. I though about defining a class property as a pointer
> to some other object so that through that class property I would be
> accessing the other object's properties. That way I could, for instance,
> write to the text property of a StatusBar panel directly from within a
> class. I don't know if this sounds crazy, but I gave it a try.

> I tried doing the following:

> In my class, I defined the following Type and properties:

> Type PStatusPanel = ^TStatusPanel;

> [..]
> Type TMyClass = class
> Private
>    m_InfoReceiver: PStatusPanel;
> Public
>    property InfoReceiver: PStatusPanel read m_InfoReceiver write
> m_InfoReceiver;

> Then I thought to put some code like this when the class was performing
> something:

> if assigned(InfoReceiver) then InfoReceiver.Text := 'Some Text';

> The problem is, when I make an instance of TMyClass, I cannot do the
> following:

> MyClass.InfoReceiver := @sbMain.Panels[0];

> where sbMain is a status Bar because I get a "variable required" error
> at compile time.

> Any clues ?

> Thank you.

Other Threads