🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Rusty Wed, 26 Mar 2003 16:14
Converting Object Pascal to C++
#17413
Author: Rusty
Date: Wed, 26 Mar 2003 16:14
47 lines
2136 bytes
Greetings:

I was wondering if there was a good reference on the web that discusses how
to convert Object Pascal to C++.  While I'm at it, is the following
coversion correct:

Object Pacal version:
procedure TCustomColorBox.SetStyle(AStyle: TColorBoxStyle);
begin
  if AStyle <> Style then
  begin
    FStyle := AStyle;
    Enabled := ([cbStandardColors, cbExtendedColors, cbSystemColors,
cbCustomColor] * FStyle) <> [];
    PopulateList;
    if (Items.Count > 0) and (ItemIndex = -1) then
      ItemIndex := 0;
  end;
end;

C++ version:
void __fastcall TColorBoxAlpha::SetStyle( TColorBoxStyle AStyle )
{
     if( AStyle != Style )
     {
          FStyle = AStyle;

          TColorBoxStyle temp;
          temp << cbStandardColors
               << cbExtendedColors
               << cbSystemColors
               << cbCustomColor;

          if( false == TColorBoxStyle( temp * FStyle ).Empty( ) )
               { Enabled = true; }
          else
               { Enabled = false; }

          PopulateList( );

          if(    ( Items->Count > 0 )
              && ( ItemIndex == -1 )   )
          {
               ItemIndex = 0;
          }
     }
}
Re: Converting Object Pascal to C++
#17411
Author: Remy Lebeau (TeamB)
Date: Wed, 26 Mar 2003 19:07
14 lines
1341 bytes
"Rusty" <rustyr@redstorm.com> wrote in message
news:3e81d1ca$1@newsgroups.borland.com...

> While I'm at it, is the following coversion correct:

Close enough, although the original Pascal code was setting Enabled in one
line whereas you're using 4 lines.  You could do it in one line in the C++
code as well:

    Enabled = !TColorBoxStyle( temp * FStyle ).Empty( );


Gambit
Re: Converting Object Pascal to C++
#17396
Author: Rusty
Date: Wed, 26 Mar 2003 19:59
24 lines
1687 bytes
I actually have it that way, but I thought it would be a bit clearer the way
I posted it :)  Thanks for the tip though.

All the Best,
Rusty

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e81f83e$1@newsgroups.borland.com...
>
> "Rusty" <rustyr@redstorm.com> wrote in message
> news:3e81d1ca$1@newsgroups.borland.com...
>
> > While I'm at it, is the following coversion correct:
>
> Close enough, although the original Pascal code was setting Enabled in one
> line whereas you're using 4 lines.  You could do it in one line in the C++
> code as well:
>
>     Enabled = !TColorBoxStyle( temp * FStyle ).Empty( );
>
>
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads