Board index » cppbuilder » Convert Delphi to BCB

Convert Delphi to BCB

How do you convert this to BCB?
      FillRect(ClientRect);

--
UK Time:

------------------------------------------------------
To Know The Road Ahead, Ask Those Who Had Returned.

Michael

 

Re:Convert Delphi to BCB


Hi Mike

This is perfectly legal BCB code

Gert

Re:Convert Delphi to BCB


Really? hmmm.....
here's my another piece of the overall missing codes :

void __fastcall TLabelPlus::Paint()
{
   TRect* Rect;

   if ( !Transparent )
   {
      Canvas->Brush->Color = Color;
      Canvas->Brush->Style = bsSolid;
      Canvas->FillRect(ClientRect);
   }

   Canvas->Brush->Style = bsClear;
   Rect = &ClientRect;
   DoWriteText(&ClientRect, (DT_EXPANDTABS | DT_WORDBREAK) |
Alignments[Alignment]);

Quote
}

//---------------------------------------------------------------------------
void __fastcall TLabelPlus::DoWriteText(TRect* Rect, WORD Flags)
{
   TRect* R;
   TColor ColorUp;       // warna bayangan bagian kiri-atas
   TColor ColorDown;     // warna bayangan bagian kanan-bawah

   if ( !ShowAccelChar )
   {
      Flags = Flags | DT_NOPREFIX;
   }

   Canvas->Font = Font;
   Canvas->Font->Color = FColor_High; //clBtnHighlight;

   if ( FTextStyle == txLowered )     // efek 3D kedalam
   {
      R = Rect;
      OffsetRect(R, 1, 1);        // teks digeser ke kanan-bawah 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);
   }
   else if ( FTextStyle == txRaised )   // efek 3D keluar
   {
      R = Rect;
      OffsetRect(R, -1, -1);      // teks digeser ke kiri-atas 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);
   }
   else if ( FTextStyle == txShadowed ) // efek bayangan
   {
      R = Rect;
      OffsetRect(R, 2, 2);        // teks digeser ke kanan-bawah 2 pixel
      Canvas->Font->Color = FColor_Low;
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);
   }
   else if ( FTextStyle == txOutlined )  // efek outline
   {
      Canvas->Font->Color = FColor_Outline;
      R = Rect;
      OffsetRect(R, -1, -1);  // teks digeser ke kiri-atas 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);

      R = Rect;
      OffsetRect(R, 1, 1);    // teks digeser ke kanan-bawah 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);

      R = Rect;
      OffsetRect(R, 1, -1);  // teks digeser ke kanan-atas 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);

      R = Rect;
      OffsetRect(R, -1, 1);  // teks digeser ke kiri-bawah 1 pixel
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);
   }
   else if ( FTextStyle == (txLowered_Enhance || txRaised_Enhance ||
                            txLowered_Emboss  || txRaised_Emboss) )
   {
      if ( FTextStyle == (txLowered_Enhance || txLowered_Emboss) )
      {
         ColorUp   = FColor_Low;
         ColorDown = FColor_High; //clBtnHighlight;
      }
      else
      {
         ColorUp   = FColor_High; //clBtnHighlight;
         ColorDown = FColor_Low;
      }

      R = Rect;
      OffsetRect(R, 1, 1);    // teks digeser ke kanan-bawah 1 pixel
      Canvas->Font->Color = ColorDown;
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);

      R = Rect;
      OffsetRect(R, -1, -1);  // teks digeser ke kiri-atas 1 pixel
      Canvas->Font->Color = ColorUp;
      DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R, Flags);
   }

   if ( FTextStyle == (txRaised_Emboss || txLowered_Emboss) )
   {
      ParentColor = True;           // samakan warna dasar dengan induknya
      Canvas->Font->Color = Color;  // gunakan warna dasar untuk teks
   }
   else
   {
      Canvas->Font->Color = Font->Color;
   }

   if ( !Enabled )
   {
      Canvas->Font->Color = clGrayText;
   }

   DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), Rect, Flags);

Quote
}

It seems broken, can u tell me why?

Thanks

Quote
Gert Been wrote:

> Hi Mike

> This is perfectly legal BCB code

> Gert

--
UK Time:

------------------------------------------------------
To Know The Road Ahead, Ask Those Who Had Returned.

Michael

Re:Convert Delphi to BCB


Quote
"Mike" <m...@uk.xyratex.com> wrote in message

news:3C060A44.F70A729B@uk.xyratex.com...

Quote
>    TRect* Rect;
<snip>
>    Rect = &ClientRect;

This won't work.  ClientRect is a property, you can't take the memory
address of it.   You don't need the pointer anyway, just assign the value
directly:

    TRect Rect = ClientRect;

Quote
>    DoWriteText(&ClientRect, (DT_EXPANDTABS | DT_WORDBREAK) |
> Alignments[Alignment]);
> }

> void __fastcall TLabelPlus::DoWriteText(TRect* Rect, WORD Flags)

Again, you don't need pointers for the TRect.  You can use a reference,
though, if you're worried about the overhead of passing a structure by
value, but that's minimal.

Quote
>        OffsetRect(R, 1, 1);        // teks digeser ke kanan-bawah 1 pixel
>        DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R,

Flags);

You're trying to pass a TRect* where a RECT* is expected.  That won't work
unless you cast it.  If you do away with the TRect* pointers, you can pass
it like this instead:

    TRect Rect;
    OffsetRect((RECT*)&Rect, 1, 1);        // teks digeser ke kanan-bawah 1
pixel
    DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(),
(RECT*)&Rect, Flags);

Gambit

Re:Convert Delphi to BCB


But how do i pass in ClientRect into this function? the 1st param

      OffsetRect(...);      

Quote
Remy Lebeau wrote:

> "Mike" <m...@uk.xyratex.com> wrote in message
> news:3C060A44.F70A729B@uk.xyratex.com...

> >    TRect* Rect;
> <snip>
> >    Rect = &ClientRect;

> This won't work.  ClientRect is a property, you can't take the memory
> address of it.   You don't need the pointer anyway, just assign the value
> directly:

>     TRect Rect = ClientRect;

> >    DoWriteText(&ClientRect, (DT_EXPANDTABS | DT_WORDBREAK) |
> > Alignments[Alignment]);
> > }

> > void __fastcall TLabelPlus::DoWriteText(TRect* Rect, WORD Flags)

> Again, you don't need pointers for the TRect.  You can use a reference,
> though, if you're worried about the overhead of passing a structure by
> value, but that's minimal.

> >        OffsetRect(R, 1, 1);        // teks digeser ke kanan-bawah 1 pixel
> >        DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R,
> Flags);

> You're trying to pass a TRect* where a RECT* is expected.  That won't work
> unless you cast it.  If you do away with the TRect* pointers, you can pass
> it like this instead:

>     TRect Rect;
>     OffsetRect((RECT*)&Rect, 1, 1);        // teks digeser ke kanan-bawah 1
> pixel
>     DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(),
> (RECT*)&Rect, Flags);

> Gambit

--
UK Time:

------------------------------------------------------
To Know The Road Ahead, Ask Those Who Had Returned.

Michael

Re:Convert Delphi to BCB


plz ignore my post.... :) i didn't read your reply properly.

Many thanks!

Quote
Mike wrote:

> But how do i pass in ClientRect into this function? the 1st param

>       OffsetRect(...);

> Remy Lebeau wrote:

> > "Mike" <m...@uk.xyratex.com> wrote in message
> > news:3C060A44.F70A729B@uk.xyratex.com...

> > >    TRect* Rect;
> > <snip>
> > >    Rect = &ClientRect;

> > This won't work.  ClientRect is a property, you can't take the memory
> > address of it.   You don't need the pointer anyway, just assign the value
> > directly:

> >     TRect Rect = ClientRect;

> > >    DoWriteText(&ClientRect, (DT_EXPANDTABS | DT_WORDBREAK) |
> > > Alignments[Alignment]);
> > > }

> > > void __fastcall TLabelPlus::DoWriteText(TRect* Rect, WORD Flags)

> > Again, you don't need pointers for the TRect.  You can use a reference,
> > though, if you're worried about the overhead of passing a structure by
> > value, but that's minimal.

> > >        OffsetRect(R, 1, 1);        // teks digeser ke kanan-bawah 1 pixel
> > >        DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(), R,
> > Flags);

> > You're trying to pass a TRect* where a RECT* is expected.  That won't work
> > unless you cast it.  If you do away with the TRect* pointers, you can pass
> > it like this instead:

> >     TRect Rect;
> >     OffsetRect((RECT*)&Rect, 1, 1);        // teks digeser ke kanan-bawah 1
> > pixel
> >     DrawText(Canvas->Handle, Caption.c_str(), Caption.Length(),
> > (RECT*)&Rect, Flags);

> > Gambit

> --
> UK Time:

> ------------------------------------------------------
> To Know The Road Ahead, Ask Those Who Had Returned.

> Michael

--
UK Time:

------------------------------------------------------
To Know The Road Ahead, Ask Those Who Had Returned.

Michael

Other Threads