Überblick
Beispiele
Schnappschüsse
Vergleiche
Anwendungen
Herunterladen
Documentation
Basar
Status & Fahrplan
Häufig gestellte Fragen
Autoren & Lizenz
Forum
Ultimate++ finanziell unterstützen
Diese Seite durchsuchen
Sprache
Deutsch













SourceForge.net Logo

OleCalc

 

Simple example of ActiveX control

 

 

calc_idl.h

 

 

 

/* this ALWAYS GENERATED file contains the definitions for the interfaces */

 

 

/* File created by MIDL compiler version 6.00.0366 */

/* at Thu Jan 24 22:57:13 2008

*/

/* Compiler settings for C:\Upp.uvs\examples.uc\OleCalc\calc.idl:

   Oicf, W1, Zp8, env=Win32 (32b run)

   protocol : dce , ms_ext, c_ext, robust

   error checks: allocation ref bounds_check enum stub_data

   VC __declspec() decoration level:

        __declspec(uuid()), __declspec(selectany), __declspec(novtable)

        DECLSPEC_UUID(), MIDL_INTERFACE()

*/

//@@MIDL_FILE_HEADING(  )

 

#pragma warning( disable: 4049 )  /* more than 64k source lines */

 

 

/* verify that the <rpcndr.h> version is high enough to compile this file*/

#ifndef __REQUIRED_RPCNDR_H_VERSION__

#define __REQUIRED_RPCNDR_H_VERSION__ 475

#endif

 

#include "rpc.h"

#include "rpcndr.h"

 

#ifndef __RPCNDR_H_VERSION__

#error this stub requires an updated version of <rpcndr.h>

#endif // __RPCNDR_H_VERSION__

 

#ifndef COM_NO_WINDOWS_H

#include "windows.h"

#include "ole2.h"

#endif /*COM_NO_WINDOWS_H*/

 

#ifndef __calc_idl_h__

#define __calc_idl_h__

 

#if defined(_MSC_VER) && (_MSC_VER >= 1020)

#pragma once

#endif

 

/* Forward Declarations */

 

#ifndef __ICalculator_FWD_DEFINED__

#define __ICalculator_FWD_DEFINED__

typedef interface ICalculator ICalculator;

#endif     /* __ICalculator_FWD_DEFINED__ */

 

 

#ifndef __Calculator_FWD_DEFINED__

#define __Calculator_FWD_DEFINED__

 

#ifdef __cplusplus

typedef class Calculator Calculator;

#else

typedef struct Calculator Calculator;

#endif /* __cplusplus */

 

#endif     /* __Calculator_FWD_DEFINED__ */

 

 

/* header files for imported files */

#include "oaidl.h"

#include "oleidl.h"

 

#ifdef __cplusplus

extern "C"{

#endif

 

void * __RPC_USER MIDL_user_allocate(size_t);

void __RPC_USER MIDL_user_free( void * );

 

#ifndef __ICalculator_INTERFACE_DEFINED__

#define __ICalculator_INTERFACE_DEFINED__

 

/* interface ICalculator */

/* [helpstring][dual][uuid][object] */

 

 

EXTERN_C const IID IID_ICalculator;

 

#if defined(__cplusplus) && !defined(CINTERFACE)

 

   MIDL_INTERFACE("2CFA5DB2-A740-11d3-981C-000000000000")

   ICalculator : public IDispatch

   {

   public:

       virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Input(

           /* [retval][out] */ BSTR *_value) = 0;

 

       virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Input(

           /* [in] */ BSTR _value) = 0;

 

       virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Calculate( void) = 0;

 

       virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Output(

           /* [retval][out] */ BSTR *value) = 0;

 

   };

 

#else     /* C style interface */

 

   typedef struct ICalculatorVtbl

   {

       BEGIN_INTERFACE

 

       HRESULT ( STDMETHODCALLTYPE *QueryInterface )(

           ICalculator * This,

           /* [in] */ REFIID riid,

           /* [iid_is][out] */ void **ppvObject);

 

       ULONG ( STDMETHODCALLTYPE *AddRef )(

           ICalculator * This);

 

       ULONG ( STDMETHODCALLTYPE *Release )(

           ICalculator * This);

 

       HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(

           ICalculator * This,

           /* [out] */ UINT *pctinfo);

 

       HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(

           ICalculator * This,

           /* [in] */ UINT iTInfo,

           /* [in] */ LCID lcid,

           /* [out] */ ITypeInfo **ppTInfo);

 

       HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(

           ICalculator * This,

           /* [in] */ REFIID riid,

           /* [size_is][in] */ LPOLESTR *rgszNames,

           /* [in] */ UINT cNames,

           /* [in] */ LCID lcid,

           /* [size_is][out] */ DISPID *rgDispId);

 

       /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(

           ICalculator * This,

           /* [in] */ DISPID dispIdMember,

           /* [in] */ REFIID riid,

           /* [in] */ LCID lcid,

           /* [in] */ WORD wFlags,

           /* [out][in] */ DISPPARAMS *pDispParams,

           /* [out] */ VARIANT *pVarResult,

           /* [out] */ EXCEPINFO *pExcepInfo,

           /* [out] */ UINT *puArgErr);

 

       /* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Input )(

           ICalculator * This,

           /* [retval][out] */ BSTR *_value);

 

       /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Input )(

           ICalculator * This,

           /* [in] */ BSTR _value);

 

       /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *Calculate )(

           ICalculator * This);

 

       /* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE *get_Output )(

           ICalculator * This,

           /* [retval][out] */ BSTR *value);

 

       END_INTERFACE

   } ICalculatorVtbl;

 

   interface ICalculator

   {

       CONST_VTBL struct ICalculatorVtbl *lpVtbl;

   };

 

 

 

#ifdef COBJMACROS

 

 

#define ICalculator_QueryInterface(This,riid,ppvObject)    \

   (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)

 

#define ICalculator_AddRef(This)    \

   (This)->lpVtbl -> AddRef(This)

 

#define ICalculator_Release(This)    \

   (This)->lpVtbl -> Release(This)

 

 

#define ICalculator_GetTypeInfoCount(This,pctinfo)    \

   (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)

 

#define ICalculator_GetTypeInfo(This,iTInfo,lcid,ppTInfo)    \

   (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)

 

#define ICalculator_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)    \

   (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)

 

#define ICalculator_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)    \

   (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)

 

 

#define ICalculator_get_Input(This,_value)    \

   (This)->lpVtbl -> get_Input(This,_value)

 

#define ICalculator_put_Input(This,_value)    \

   (This)->lpVtbl -> put_Input(This,_value)

 

#define ICalculator_Calculate(This)    \

   (This)->lpVtbl -> Calculate(This)

 

#define ICalculator_get_Output(This,value)    \

   (This)->lpVtbl -> get_Output(This,value)

 

#endif /* COBJMACROS */

 

 

#endif     /* C style interface */

 

 

 

/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE ICalculator_get_Input_Proxy(

   ICalculator * This,

   /* [retval][out] */ BSTR *_value);

 

 

void __RPC_STUB ICalculator_get_Input_Stub(

   IRpcStubBuffer *This,

   IRpcChannelBuffer *_pRpcChannelBuffer,

   PRPC_MESSAGE _pRpcMessage,

   DWORD *_pdwStubPhase);

 

 

/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE ICalculator_put_Input_Proxy(

   ICalculator * This,

   /* [in] */ BSTR _value);

 

 

void __RPC_STUB ICalculator_put_Input_Stub(

   IRpcStubBuffer *This,

   IRpcChannelBuffer *_pRpcChannelBuffer,

   PRPC_MESSAGE _pRpcMessage,

   DWORD *_pdwStubPhase);

 

 

/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICalculator_Calculate_Proxy(

   ICalculator * This);

 

 

void __RPC_STUB ICalculator_Calculate_Stub(

   IRpcStubBuffer *This,

   IRpcChannelBuffer *_pRpcChannelBuffer,

   PRPC_MESSAGE _pRpcMessage,

   DWORD *_pdwStubPhase);

 

 

/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE ICalculator_get_Output_Proxy(

   ICalculator * This,

   /* [retval][out] */ BSTR *value);

 

 

void __RPC_STUB ICalculator_get_Output_Stub(

   IRpcStubBuffer *This,

   IRpcChannelBuffer *_pRpcChannelBuffer,

   PRPC_MESSAGE _pRpcMessage,

   DWORD *_pdwStubPhase);

 

 

 

#endif     /* __ICalculator_INTERFACE_DEFINED__ */

 

 

 

#ifndef __Calculator_TypeLib_LIBRARY_DEFINED__

#define __Calculator_TypeLib_LIBRARY_DEFINED__

 

/* library Calculator_TypeLib */

/* [helpstring][version][uuid] */

 

 

EXTERN_C const IID LIBID_Calculator_TypeLib;

 

EXTERN_C const CLSID CLSID_Calculator;

 

#ifdef __cplusplus

 

class DECLSPEC_UUID("2CFA5DB1-A740-11d3-981C-000000000000")

Calculator;

#endif

#endif /* __Calculator_TypeLib_LIBRARY_DEFINED__ */

 

/* Additional Prototypes for ALL interfaces */

 

unsigned long             __RPC_USER  BSTR_UserSize(     unsigned long *, unsigned long            , BSTR * );

unsigned char * __RPC_USER  BSTR_UserMarshal(  unsigned long *, unsigned char *, BSTR * );

unsigned char * __RPC_USER  BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * );

void                      __RPC_USER  BSTR_UserFree(     unsigned long *, BSTR * );

 

/* end of Additional Prototypes */

 

#ifdef __cplusplus

}

#endif

 

#endif

 

 

 

calc.cpp

 

#include <Ole/Ctrl/OleCtrl.h>

#include <CtrlLib/CtrlLib.h>

#include <Esc/Esc.h>

 

#include "calc_idl.h"

 

using namespace Upp;

 

#define LAYOUTFILE "calc.lay"

#include <CtrlCore/lay.h>

 

class Calculator : public WithCalculatorLayout<OcxRunnableControl>, public DispatchInterface<ICalculator> {

    void Eval();

 

public:

    virtual void Paint(UPP::Draw& w);

 

    STDMETHOD(get_Input)(BSTR *result);

    STDMETHOD(put_Input)(BSTR input);

    STDMETHOD(Calculate)();

    STDMETHOD(get_Output)(BSTR *result);

 

    typedef Calculator CLASSNAME;

    Calculator();

};

 

OCX_OBJECT(Calculator)

 

void Calculator::Paint(UPP::Draw& w)

{

    w.DrawRect(GetSize(), SColorFace());

}

 

Calculator::Calculator()

{

    CtrlLayout(*this);

    ok.Ok() <<= THISBACK(Eval);

    ok.Tip("Evaluate given expression");

    NoWantFocus();

}

 

void Calculator::Eval()

{

    ArrayMap<String, EscValue> global;

    value <<= Evaluate((String)~expr, global).ToString();

}

 

HRESULT Calculator::get_Input(BSTR *result)

{

    ReturnString(result, ~expr);

    return S_OK;

}

 

HRESULT Calculator::put_Input(BSTR input)

{

    expr <<= BSTRToString(input);

    return S_OK;

}

 

HRESULT Calculator::Calculate()

{

    Eval();

    return S_OK;

}

 

HRESULT Calculator::get_Output(BSTR *result)

{

    ReturnString(result, ~value);

    return S_OK;

}

 

OCX_APP_MAIN

{

    SetLanguage(LNG_CZECH);

    SetDefaultCharset(CHARSET_WIN1250);

}

 

 

 

calc_idl.cpp

 

 

 

/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

 

/* link this file in with the server and any clients */

 

 

/* File created by MIDL compiler version 6.00.0361 */

/* at Thu Jan 24 22:09:58 2008

*/

/* Compiler settings for d:\examples\OleCalc\calc.idl:

   Oicf, W1, Zp8, env=Win32 (32b run)

   protocol : dce , ms_ext, c_ext, robust

   error checks: allocation ref bounds_check enum stub_data

   VC __declspec() decoration level:

        __declspec(uuid()), __declspec(selectany), __declspec(novtable)

        DECLSPEC_UUID(), MIDL_INTERFACE()

*/

//@@MIDL_FILE_HEADING(  )

 

#if !defined(_M_IA64) && !defined(_M_AMD64)

 

 

#pragma warning( disable: 4049 )  /* more than 64k source lines */

 

 

#ifdef __cplusplus

extern "C"{

#endif

 

 

#include <rpc.h>

#include <rpcndr.h>

 

#ifdef _MIDL_USE_GUIDDEF_

 

#ifndef INITGUID

#define INITGUID

#include <guiddef.h>

#undef INITGUID

#else

#include <guiddef.h>

#endif

 

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \

       DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)

 

#else // !_MIDL_USE_GUIDDEF_

 

#ifndef __IID_DEFINED__

#define __IID_DEFINED__

 

typedef struct _IID

{

   unsigned long x;

   unsigned short s1;

   unsigned short s2;

   unsigned char  c[8];

} IID;

 

#endif // __IID_DEFINED__

 

#ifndef CLSID_DEFINED

#define CLSID_DEFINED

typedef IID CLSID;

#endif // CLSID_DEFINED

 

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \

       const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}

 

#endif !_MIDL_USE_GUIDDEF_

 

MIDL_DEFINE_GUID(IID, IID_ICalculator,0x2CFA5DB2,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

 

MIDL_DEFINE_GUID(IID, LIBID_Calculator_TypeLib,0x2CFA5DB0,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

 

MIDL_DEFINE_GUID(CLSID, CLSID_Calculator,0x2CFA5DB1,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

#undef MIDL_DEFINE_GUID

 

#ifdef __cplusplus

}

#endif

 

 

 

#endif /* !defined(_M_IA64) && !defined(_M_AMD64)*/

 

 

 

/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

 

/* link this file in with the server and any clients */

 

 

/* File created by MIDL compiler version 6.00.0361 */

/* at Thu Jan 24 22:09:58 2008

*/

/* Compiler settings for d:\examples\OleCalc\calc.idl:

   Oicf, W1, Zp8, env=Win64 (32b run,appending)

   protocol : dce , ms_ext, c_ext, robust

   error checks: allocation ref bounds_check enum stub_data

   VC __declspec() decoration level:

        __declspec(uuid()), __declspec(selectany), __declspec(novtable)

        DECLSPEC_UUID(), MIDL_INTERFACE()

*/

//@@MIDL_FILE_HEADING(  )

 

#if defined(_M_IA64) || defined(_M_AMD64)

 

 

#pragma warning( disable: 4049 )  /* more than 64k source lines */

 

 

#ifdef __cplusplus

extern "C"{

#endif

 

 

#include <rpc.h>

#include <rpcndr.h>

 

#ifdef _MIDL_USE_GUIDDEF_

 

#ifndef INITGUID

#define INITGUID

#include <guiddef.h>

#undef INITGUID

#else

#include <guiddef.h>

#endif

 

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \

       DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)

 

#else // !_MIDL_USE_GUIDDEF_

 

#ifndef __IID_DEFINED__

#define __IID_DEFINED__

 

typedef struct _IID

{

   unsigned long x;

   unsigned short s1;

   unsigned short s2;

   unsigned char  c[8];

} IID;

 

#endif // __IID_DEFINED__

 

#ifndef CLSID_DEFINED

#define CLSID_DEFINED

typedef IID CLSID;

#endif // CLSID_DEFINED

 

#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \

       const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}

 

#endif !_MIDL_USE_GUIDDEF_

 

MIDL_DEFINE_GUID(IID, IID_ICalculator,0x2CFA5DB2,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

 

MIDL_DEFINE_GUID(IID, LIBID_Calculator_TypeLib,0x2CFA5DB0,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

 

MIDL_DEFINE_GUID(CLSID, CLSID_Calculator,0x2CFA5DB1,0xA740,0x11d3,0x98,0x1C,0x00,0x00,0x00,0x00,0x00,0x00);

 

#undef MIDL_DEFINE_GUID

 

#ifdef __cplusplus

}

#endif

 

 

 

#endif /* defined(_M_IA64) || defined(_M_AMD64)*/

 

 

 

calc.lay

 

LAYOUT(CalculatorLayout, 376, 56)

    ITEM(Label, dv___0, SetLabel(t_("Expression")).LeftPosZ(4, 56).TopPosZ(4, 19))

    ITEM(EditField, expr, HSizePosZ(64, 4).TopPosZ(4, 19))

    ITEM(Label, dv___2, SetLabel(t_("Value:")).LeftPosZ(112, 56).TopPosZ(28, 16))

    ITEM(EditField, value, HSizePosZ(168, 4).TopPosZ(26, 19))

    ITEM(Button, ok, SetLabel(t_("Evaluate")).LeftPosZ(4, 80).TopPosZ(28, 22))

END_LAYOUT

 

 

 

 

Diese Seite gibt es auch in english, català, čeština, español, euskara, français, română, русский, 中文(简体) und 中文(繁體). Willst du mitmachen?