BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pascal: Functions & Procedures included in body of parent-p

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Serge CSM
Guest





PostPosted: Mon Sep 08, 2003 1:52 pm    Post subject: Pascal: Functions & Procedures included in body of parent-p Reply with quote



Hi All,

May be you sugest me something:
Program annotation: TCustomHexEditor is derived from class
Grids::TCustomGrid

I don't know the definition of this method of programming because I don't
know Pascal language....
It's look like child-procedures in Parent-Procedure.

How to implement this in C++Builder?
1. To declare this child-procedures and child-function with its bodys
outside (before) Parent-Procedure? It's imposible!?!?! because that
mini-procedures use a lot of variables from Parent-Procedure.
2. To define a new (Temporary) class that implement that structure?
3. Your sugestion....

For example in Pascal that look like this:
----------------------------------------------------------------------------
procedure TCustomHexEditor.Paint;
var
DrawInfo: TGridDrawInfo;
... // a lot of declared variables that are used in child-procedures and
child-function
LIntPenWidthSave: integer;

function GetTextWidthW: Integer;
var
LrecSize: TSize;
begin
GetTextExtentPoint32W(Canvas.Handle, PWideChar(LWStrOutput),
Length(LWStrOutput), LrecSize);
... // < There's used a lot of Varables from parent
procedure TCustomHexEditor.Paint
Result := LRecSize.cx;
end;

procedure _TextOut;
var
LRct2: TRect;
begin
Brush.Color := LColBackColor;
... // < There's used a lot of Varables from parent
procedure TCustomHexEditor.Paint
end;

begin
_TextOut;
.....
blabla = GetTextWidthW;
end.
----------------------------------------------------------------------




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Sep 08, 2003 5:19 pm    Post subject: Re: Pascal: Functions & Procedures included in body of pare Reply with quote




"Serge CSM" <gunivas (AT) moldovacc (DOT) md> wrote


Quote:
How to implement this in C++Builder?

You can't. C++ doesn't support it at all. You would have to break out the
inner procedures and make normal procedures out of them, adjusting them as
needed for parameters and such. So, given the example you provided earlier,
it would be something like this:

int __fastcall GetTextWidthW(TCanvas *Canvas, const WideString
&WStrOutput)
{
SIZE LrecSize;
GetTextExtentPoint32W(Canvas->Handle, WStrOutput,
WStrOutput.Length(), &LrecSize);
return LRecSize.cx;
}

void __fastcall _TextOut(TBrush *Brush, TColor ColBackColor)
{
//...
Brush->Color = LColBackColor;
//...
}

void __fastcall TCustomHexEditor::Paint()
{
//...
_TextOut(Brush, LColBackColor);
// ...
blabla = GetTextWidthW(Canvas, LWStrOutput);
}


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Sep 09, 2003 7:15 am    Post subject: Re: Pascal: Functions & Procedures included in body of pare Reply with quote




"Peter Agricola" <spammy (AT) spammer (DOT) com> wrote


Quote:
You can also wrap all the variables in a structure local
to the calling function. Pas this structure by reference to
your subfunctions.

That would be more elegant, yes.


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/2/03



Back to top
Serge CSM
Guest





PostPosted: Tue Sep 09, 2003 11:02 am    Post subject: Re: Pascal: Functions & Procedures included in body of pare Reply with quote

I am bored!

A lot of lot of lot of variables must be sent to new-temporary class.
In this case temp-class or outer (declared before procedures) that implement
local (inner) procedures in pascal is't usable.
Structure? Too dificult, must be sent a lot of private & public variables of
basic-class to this inner procedures implemented outside (before).

Pleaseeeeeee.e.e.e.e. sugest something else. Any idea will be helpfull.

If there's not another way the only way is to repeat (included in parent
procedures) the all body-code of inner procedures.
I know "it's bad way for programing"... but I'm bored!

Serge.

P.S. I can attach (included in message) this procedure - about 16Kbt



Back to top
Peter Agricola
Guest





PostPosted: Tue Sep 09, 2003 11:22 am    Post subject: Re: Pascal: Functions & Procedures included in body of pare Reply with quote

What are you talking about?

This calling function defines a lot of local variables or it uses a lot of
class members? I think from your message the latter is the case. If you make
the subfunctions methods (member functions) from your class these
subfunctions have access to the members too and thus don't have to be passed
to with variables.
If it really are local variables, not class members, than using a structure
is the easiest way I know of.


peter




Back to top
Serge CSM
Guest





PostPosted: Tue Sep 09, 2003 11:41 am    Post subject: Re: Pascal: Functions & Procedures included in body of pare Reply with quote

YES!YES!YES!
That is!!!!!
Is't so sample. Where was my mind? I know - I must go on leave. My brain is
faded away

Quote:
This calling function defines a lot of local variables or it uses a lot of
class members?
I think from your message the latter is the case.

Both cases! Lot of local + lot of class members about 20 + 30;
I just finished the inner-procedures definition as a parent class-members
and pass the local variables of Parent-Procedure!

You have a precise mind, thank's.
Serge.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.