阅读背景:

请大家帮我把下面两句Delphi翻译成对应的C++Builder,谢谢.

来源:互联网 
property ColorHighLight: TColor index 0 read FColorHighlight write SetColors default 
property ColorHighLight: TColor index 0 read FColorHighlight write SetColors default $008396A0;
    property ColorShadow: TColor index 1 read FColorShadow write SetColors default $008396A0;

6 个解决方案

#1


如果有兴趣,都翻译一遍也不错:)
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;
    property Align;
    property Alignment;
    property Cursor;
    property Hint;
    property ParentShowHint;
    property ShowHint;
    property PopupMenu;
    property TabOrder;
    property TabStop;
   {$IFDEF DFS_DELPHI_4_UP}
    property AutoSize;
    property UseDockManager;
    property Anchors;
    property BiDiMode;
    property Constraints;
    property DragKind;
    property DragMode;
    property DragCursor;
    property ParentBiDiMode;
    property DockSite;
    property OnEndDock;
    property OnStartDock;
    property OnCanResize;
    property OnConstrainedResize;
    property OnDockDrop;
    property OnDockOver;
    property OnGetSiteInfo;
    property OnUnDock;
   {$ENDIF}
   {$IFDEF DFS_DELPHI_5_UP}
    property OnContextPopup;
   {$ENDIF}
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnResize;
    property OnStartDrag;
  end;

#2


我翻译的结果目前如下:

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

#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& Message);
    void __fastcall CMTextChanged (TWmNoParams& 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};
    __property Align;
    __property Alignment;
    __property Cursor;
    __property Hint;
    __property ParentShowHint;
    __property ShowHint;
    __property PopupMenu;
    __property TabOrder;
    __property TabStop;
    __property AutoSize;
    __property UseDockManager;
    __property Anchors;
    __property BiDiMode;
    __property Constraints;
    __property DragKind;
    __property DragMode;
    __property DragCursor;
    __property ParentBiDiMode;
    __property DockSite;
    __property OnEndDock;
    __property OnStartDock;
    __property OnCanResize;
    __property OnConstrainedResize;
    __property OnDockDrop;
    __property OnDockOver;
    __property OnGetSiteInfo;
    __property OnUnDock;
    __property OnContextPopup;
    __property OnClick;
    __property OnDblClick;
    __property OnDragDrop;
    __property OnDragOver;
    __property OnEndDrag;
    __property OnEnter;
    __property OnExit;
    __property OnMouseDown;
    __property OnMouseMove;
    __property OnMouseUp;
    __property OnResize;
    __property OnStartDrag;
    

};
//---------------------------------------------------------------------------
#endif

但提示TWmNoParams找不到,我明明包含了Messages.hpp文件啊.

#3


其中我提出的两句翻译有误,请大虾指点迷津,谢谢!

#4


default 应该是0x????吧?

#5


楼上的没有说中要害.

#6


郁闷...
问题又被我自己搞定了.

8396A0; property ColorHighLight: TColor index 0 read FC



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: