同时懂Delphi和C++Builder的请进(20分)

  • 主题发起人 主题发起人 freeia
  • 开始时间 开始时间
F

freeia

Unregistered / Unconfirmed
GUEST, unregistred user!
请大家帮我把下面两句Delphi翻译成对应的C++Builder,谢谢.
property ColorHighLight: TColor index 0 read FColorHighlight write SetColors default $008396A0;
property ColorShadow: TColor index 1 read FColorShadow write SetColors default $008396A0;


如果有兴趣,都翻译一遍也不错:)
type
TFlatPanel = class(TCustomPanel)
private
FTransparent: Boolean;
FColorHighlight: TColor;
FColorShadow: TColor;
procedure SetColors (Index: Integer; Value: TColor);
procedure CMEnabledChanged (var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMTextChanged (var Message: TWmNoParams); message CM_TEXTCHANGED;
procedure SetTransparent (const Value: Boolean);
protected
procedure Paint; override;
public
constructor Create (AOwner: TComponent); override;
published
property Transparent: Boolean read FTransparent write SetTransparent default false;
property Caption;
property Font;
property Color;
property ParentColor;
property Enabled;
property Visible;
property ColorHighLight: TColor index 0 read FColorHighlight write SetColors default $008396A0;
property ColorShadow: TColor index 1 read FColorShadow write SetColors default $008396A0;

我翻译的结果目前如下:

//---------------------------------------------------------------------------

#ifndef FlatPanelH
#define FlatPanelH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <ExtCtrls.hpp>
#include <Messages.hpp>
//---------------------------------------------------------------------------
class PACKAGE TFlatPanel : public TCustomPanel
{
private:
bool FTransparent;
TColor FColorHighlight;
TColor FColorShadow;
void __fastcall SetColors(int nIndex, TColor Value);
void __fastcall CMEnabledChanged (TMessage&amp; Message);
void __fastcall CMTextChanged (TWmNoParams&amp; Message);
void __fastcall SetTransparent(const bool Value);

private:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CM_ENABLEDCHANGED, TMessage, CMEnabledChanged)
VCL_MESSAGE_HANDLER(CM_TEXTCHANGED, TWmNoParams, CMTextChanged)
END_MESSAGE_MAP(TCustomPanel)

protected:
void __fastcall Paint(void);

public:
__fastcall TFlatPanel(TComponent* Owner);

__published:
__property bool Transparent = {read=FTransparent, write=SetTransparent, default=false};
__property Caption;
__property Font;
__property Color;
__property ParentColor;
__property Enabled;
__property Visible;
__property TColor ColorHighLight = {index=0, read=FColorHighlight, write=SetColors, default=008396A0};
__property TColor ColorShadow = {index=1, read=FColorShadow, write=SetColors, default=008396A0};
但提示TWmNoParams找不到,我明明包含了Messages.hpp文件啊.

 
问题解决了,第一个进来回复的领分吧.
 
haha多谢了,不过我觉得做这样的工作没有什么意思
 
第二個有沒有?
 
我觉得把delphi代码翻译为C++Builder代码还是有用的,最起码可以在翻译的时候学习一把,把底层的东西弄清楚.
 
后退
顶部