首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

ActiveForm在哪里添加接口,可供外面的程序调用(java,jsp),该怎么处理

2012-02-11 
ActiveForm在哪里添加接口,可供外面的程序调用(java,jsp)C/C++ codeclass TMainForm : public TActiveForm

ActiveForm在哪里添加接口,可供外面的程序调用(java,jsp)

C/C++ code
 
class TMainForm : public TActiveForm
{
__published:// IDE-managed Components
    TButton *btn1;
    TLabel *lbl1;
    TButton *btn2;
    TRzPanel *pnlLogin;
    TLabel *lblCorpID;
    TLabel *lblCorpName;
    TLabel *lblIpAdress;
    TLabel *lblPassword;
    TLabel *lblUserID;
    TImage *imgLogin;
    TEdit *edtPassword;
    TEdit *edtUserID;
    TEdit *edtCorpID;
    TEdit *edtIpAdress;
    TRzCheckBox *chkAutoLogin;
    TRzCheckBox *chkRememberMM;
    TButton *btn3;
    TButton *btn4;
    TButton *btn5;
    TButton *btn6;
    TLabel *lbl2;
    void __fastcall btn1Click(TObject *Sender);
    void __fastcall btn2Click(TObject *Sender);
    void __fastcall imgLoginClick(TObject *Sender);
    void __fastcall btn3Click(TObject *Sender);
    void __fastcall btn5Click(TObject *Sender);
    void __fastcall btn4Click(TObject *Sender);
    void __fastcall ActiveFormCreate(TObject *Sender);
    void __fastcall ActiveFormDestroy(TObject *Sender);
    void __fastcall btn6Click(TObject *Sender);
private:// User declarations
    void __fastcall InitScreen();
    void __fastcall MakeCallOutScreen();
    void __fastcall MakeCallInScreen();
    void __fastcall CallingOutScreen();
    void __fastcall CallingInScreen();
    void __fastcall SecondCallScreen();
    void __fastcall TripleCallScreen();
protected:
    virtual void __fastcall WndProc(TMessage &Msg);
public:// User declarations
    __fastcall TMainForm(HWND ParentWindow);
    __fastcall TMainForm(TComponent* AOwner): TActiveForm(AOwner) {};
};
//---------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------


//---------------------------------------
class ATL_NO_VTABLE TMainFormImpl:
  VCLCONTROL_IMPL(TMainFormImpl, MainForm, TMainForm, IMainForm, DIID_IMainFormEvents)
  ,public IObjectSafetyImpl <TMainFormImpl,INTERFACESAFE_FOR_UNTRUSTED_CALLER>
{
  void __fastcall ActivateEvent(TObject *Sender);
  void __fastcall ClickEvent(TObject *Sender);
  void __fastcall CreateEvent(TObject *Sender);
  void __fastcall DblClickEvent(TObject *Sender);
  void __fastcall DeactivateEvent(TObject *Sender);
  void __fastcall DestroyEvent(TObject *Sender);
  void __fastcall KeyPressEvent(TObject *Sender, char &Key);
  void __fastcall PaintEvent(TObject *Sender);
  void __fastcall MouseMove();
public:

  void InitializeControl()
  {
    m_VclCtl->OnActivate = ActivateEvent;
    m_VclCtl->OnClick = ClickEvent;
    m_VclCtl->OnCreate = CreateEvent;
    m_VclCtl->OnDblClick = DblClickEvent;
    m_VclCtl->OnDeactivate = DeactivateEvent;
    m_VclCtl->OnDestroy = DestroyEvent;
    m_VclCtl->OnKeyPress = KeyPressEvent;
    m_VclCtl->OnPaint = PaintEvent;
    m_VclCtl->OnMouseMove = MouseMove;
  }
  BEGIN_CATEGORY_MAP(TMainFormImpl)


      IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
      IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  END_CATEGORY_MAP()

// The COM MAP entries declares the interfaces your object exposes (through
// QueryInterface). CComRootObjectEx::InternalQueryInterface only returns
// pointers for interfaces in the COM map. VCL controls exposed as OCXes
// have a minimum set of interfaces defined by the
// VCL_CONTROL_COM_INTERFACE_ENTRIES macro. Add other interfaces supported
// by your object with additional COM_INTERFACE_ENTRY[_xxx] macros.
//
BEGIN_COM_MAP(TMainFormImpl)
  VCL_CONTROL_COM_INTERFACE_ENTRIES(IMainForm)
  COM_INTERFACE_ENTRY(IObjectSafety)
END_COM_MAP()


// The PROPERTY map stores property descriptions, property DISPIDs,
// property page CLSIDs and IDispatch IIDs. You may use use
// IPerPropertyBrowsingImpl, IPersistPropertyBagImpl, IPersistStreamInitImpl,
// and ISpecifyPropertyPageImpl to utilize the information in you property
// map.
//
// NOTE: The BCB Wizard does *NOT* maintain your PROPERTY_MAP table. You must
//      add or remove entries manually.
//
BEGIN_PROPERTY_MAP(TMainFormImpl)
  // PROP_PAGE(CLSID_MainFormPage)
END_PROPERTY_MAP()

/* DECLARE_VCL_CONTROL_PERSISTENCE(CppClass, VclClass) is needed for VCL
* controls to persist via the VCL streaming mechanism and not the ATL mechanism.
* The macro adds static IPersistStreamInit_Load and IPersistStreamInit_Save
* methods to your implementation class, overriding the methods in IPersistStreamImpl.
* This macro must be manually undefined or removed if you port to C++Builder 4.0. */

DECLARE_VCL_CONTROL_PERSISTENCE(TMainFormImpl, TMainForm);

// The DECLARE_ACTIVEXCONTROL_REGISTRY macro declares a static 'UpdateRegistry'
// routine which registers the basic information about your control. The
// parameters expected by the macro are the ProgId & the ToolboxBitmap ID of
// your control.
//
DECLARE_ACTIVEXCONTROL_REGISTRY("TMainFormProj.MainForm", 1);

protected:
  STDMETHOD(_set_Font(IFontDisp** Value));
  STDMETHOD(AboutBox());
  STDMETHOD(get_Active(VARIANT_BOOL* Value));
  STDMETHOD(get_AlignDisabled(VARIANT_BOOL* Value));
  STDMETHOD(get_AutoScroll(VARIANT_BOOL* Value));
  STDMETHOD(get_AutoSize(VARIANT_BOOL* Value));
  STDMETHOD(get_AxBorderStyle(TxActiveFormBorderStyle* Value));
  STDMETHOD(get_BorderWidth(long* Value));
  STDMETHOD(get_Caption(BSTR* Value));
  STDMETHOD(get_Color(::OLE_COLOR* Value));
  STDMETHOD(get_DoubleBuffered(VARIANT_BOOL* Value));
  STDMETHOD(get_DropTarget(VARIANT_BOOL* Value));
  STDMETHOD(get_Enabled(VARIANT_BOOL* Value));
  STDMETHOD(get_Font(IFontDisp** Value));
  STDMETHOD(get_HelpFile(BSTR* Value));
  STDMETHOD(get_KeyPreview(VARIANT_BOOL* Value));
  STDMETHOD(get_PixelsPerInch(long* Value));
  STDMETHOD(get_PrintScale(TxPrintScale* Value));
  STDMETHOD(get_Scaled(VARIANT_BOOL* Value));
  STDMETHOD(get_Visible(VARIANT_BOOL* Value));
  STDMETHOD(get_VisibleDockClientCount(long* Value));
  STDMETHOD(set_AutoScroll(VARIANT_BOOL Value));
  STDMETHOD(set_AutoSize(VARIANT_BOOL Value));
  STDMETHOD(set_AxBorderStyle(TxActiveFormBorderStyle Value));
  STDMETHOD(set_BorderWidth(long Value));
  STDMETHOD(set_Caption(BSTR Value));
  STDMETHOD(set_Color(::OLE_COLOR Value));
  STDMETHOD(set_DoubleBuffered(VARIANT_BOOL Value));
  STDMETHOD(set_DropTarget(VARIANT_BOOL Value));
  STDMETHOD(set_Enabled(VARIANT_BOOL Value));


  STDMETHOD(set_Font(IFontDisp* Value));
  STDMETHOD(set_HelpFile(BSTR Value));
  STDMETHOD(set_KeyPreview(VARIANT_BOOL Value));
  STDMETHOD(set_PixelsPerInch(long Value));
  STDMETHOD(set_PrintScale(TxPrintScale Value));
  STDMETHOD(set_Scaled(VARIANT_BOOL Value));
  STDMETHOD(set_Visible(VARIANT_BOOL Value));
};

 
这是我创建的ActiveForm头文件,请问这里边那些是接口?如果我要加自己的接口应该加到那里?



[解决办法]
帮LZ顶下
[解决办法]
View菜单->Type Library
然后在Type Library的窗口当中添加Method
如果是需要产生一个事件(类似ButtonOnClick)则添加Event
如果是只需要反一个值,则添加一个Property

对于Method返回值只一种,HRESULT,如果想在外部程序调用的时候返回如
a = MYForm.Add(1,100)
那么就要声明三个参数,一个返回值(属性为out,retval),另两个为入参(属性为in)
其中为out的都是指针类型,跟普通过程/函数的参数差不多.仅有的不同就是一个Method最我只能有一个retval参数.
[解决办法]
类似的问题曾经解答过。

参考:
http://topic.csdn.net/u/20081009/17/5a759619-1d9f-48db-8fe3-7ed6705302cb.html

热点排行