Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access an owner procedure from a TPersistent class

Posted on 2002-03-28
18
Medium Priority
?
314 Views
Last Modified: 2013-11-23
I use in my component a TPersistent class . Here, before invalidate the owner, I need to access an owner procedure ( alike Prepare ).
How can I do that ?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
18 Comments
 
LVL 1

Expert Comment

by:Alone
ID: 6903286
If your owner class and TPersistent descedant are in same unit, you can call all methods directly, because they are treated as "friendly" classes
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6904465
Are you sure ?

Prepare; // [Error] test.pas(272): Undeclared identifier: 'Prepare'
FOwner.Invalidate;

Same result for FOwner.Prepare;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6904469
And please ... don't put an answer directly . Type a comment and if I will be satisfy I will accept it as answer .
So the question will not be lock for others experts .
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:AvonWyss
ID: 6904532
If you do know what type the owner is, you can typecast so that you can access the identifiers. Is this what you need?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6904853
Can you give me a sample ?

My component ( the owner ) is a TCustomControl descendent .

From TPersistent descendent I wish to call something alike :

FOwner.Prepare;
FOwner.Invalidate;
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6909718
umm...

(FOwner as TCustomControl).Invalidate;

I don't think a TCustomControl has a Prepare method... or does it?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6910147
Prepare is my own procedure . I need to call Prepare before invalidate .

Nick

BTW, FOwner.Invalidate work too .
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6936032
No solution here :(
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6936057
Do you know the class for the owner? Let's say it is TMyCustomOwnerClass

then all you need to do is TMyCustomOwnerClass(FOwner).Prepare;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6936488
Have tried your suggestion :

TDBGrid(FOwner).Prepare; // in my case

No success :(
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940947
but TDBGrid does not have a method called Prepare! where did you declare the Prepare method? Any ideas?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940949
some codes might be useful
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6941107
I work to a DBGrid that accept images for background . In same time can be set to transparent or semi-transparent.

Before invalidate my grid, I need to PREPARE ( OWN procedure ) the background ( declared into protected area ).

But in same time , when set couple properties (TPersistent descendents) I need to Invalidate . But before this, still I need to call Prepare . So ...

How can I call from a TPersistent an owner procedure ( OWN declared ) .
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6941141
Umm... I need to know who owns Prepare :)
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6941855
Prepare is a protected procedure of my TgnDBGrid descendent from TCustomDBGrid .

So the owner is TgnDBGrid .
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6943637
then you should do

TgnDBGrid(Owner).Prepare;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6943923
Already tried :(
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 200 total points
ID: 6943940
umm... either

1. Make it public

2. Create a new class

type
  THackMyDBGrid = class(TgnDBGrid)
  public
    procedure Prepare; // change visibility
  end;

THackMyDBGrid(Owner).Prepare;



:)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question