|
George_George wrote: You mean a static lib file, and not import lib file, correct?
Yep, that's right. Create a static library project in VS and add the _i.c file as a source.
|
|
|
|
|
Thanks Stuart,
I like your alternative solution.
regards,
George
|
|
|
|
|
Hi,
I have a activeX ATL control embeded in an html page. The page also defines some javascript which I'd like to call from my ActiveX object. From reading several articles I realize I could to use connectionpoints to accomplish this. However, I'm stuck with a compile error:
error C2787: '_IWebPluginControlEvents' : no GUID has been associated with this object.
Is there some step i'm missing here? Any help is greatly apperciated!
I have defined a connectionpoint within my IDL file as follows:
In "WebPlugin.idl"
[
uuid(FD84D4F2-4D92-48DE-9A16-0D2F1A43DD6D),
helpstring("_IWebPluginControlEvents")
]
dispinterface _IWebPluginControlEvents
{
properties:
methods:
[id(1), helpstring("method Finished")] HRESULT Finished();
};
coclass WebPluginControl
{
[default] interface IWebPluginControl;
[default, source] dispinterface _IWebPluginControlEvents;
};
I have implemented IProvideClassInfo2Imp and added the COM_ENTRIES as follows:
WebPluginControl.h
class ATL_NO_VTABLE CWebPluginControl :
public CComObjectRootEx<ccomsinglethreadmodel>,
public IDispatchImpl,
public IPersistStreamInitImpl<cwebplugincontrol>,
public IOleControlImpl<cwebplugincontrol>,
public IOleObjectImpl<cwebplugincontrol>,
public IOleInPlaceActiveObjectImpl<cwebplugincontrol>,
public IViewObjectExImpl<cwebplugincontrol>,
public IOleInPlaceObjectWindowlessImpl<cwebplugincontrol>,
public ISupportErrorInfo,
public IPersistStorageImpl<cwebplugincontrol>,
public ISpecifyPropertyPagesImpl<cwebplugincontrol>,
public IQuickActivateImpl<cwebplugincontrol>,
public IDataObjectImpl<cwebplugincontrol>,
public IProvideClassInfo2Impl<&CLSID_WebPluginControl, &__uuidof(_IWebPluginControlEvents), &LIBID_WebPluginLib>,
public IObjectSafetyImpl<cwebplugincontrol,>,
public IConnectionPointContainerImpl<cwebplugincontrol>,
public IConnectionPointImpl<cwebplugincontrol,&__uuidof(_iwebplugincontrolevents)>,
public IPropertyNotifySinkCP<cwebplugincontrol>,
public IPersistPropertyBagImpl<cwebplugincontrol>,
public CComCoClass<cwebplugincontrol,>,
public CComControl <cwebplugincontrol>,
public CProxy_IWebPluginControlEvents<cwebplugincontrol>
BEGIN_COM_MAP(CWebPluginControl)
COM_INTERFACE_ENTRY(IWebPluginControl)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IPersistPropertyBag)
COM_INTERFACE_ENTRY_IID(IID_IObjectSafety, IObjectSafety)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CWebPluginControl)
CONNECTION_POINT_ENTRY(__uuidof(_IWebPluginControlEvents))
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
END_CONNECTION_POINT_MAP()
</cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></cwebplugincontrol></ccomsinglethreadmodel>
The proxy class (auto-generated) looks like:
#pragma once
template<class t="">
class CProxy_IWebPluginControlEvents :
public IConnectionPointImpl<t,>
{
public:
HRESULT Fire_Finished()
{
HRESULT hr = S_OK;
T * pThis = static_cast<t>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<iunknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast<idispatch>(punkConnection.p);
if (pConnection)
{
CComVariant varResult;
DISPPARAMS params = { NULL, NULL, 0, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
}
}
return hr;
}
};
</idispatch></iunknown></t></class>
I am using Visual Studio 2003 under windows XP SP2
MIDL compiler version 6.00.0361
Every ATL.dll on my system is versioned > 3 (not sure how to check the exect one visual studio is using)
|
|
|
|
|
Ok I've figured it out, I was placing code in the wrong spot inside my idl file. Specifically, the following needed to be inside the "library" tag.
[
uuid(FD84D4F2-4D92-48DE-9A16-0D2F1A43DD6D),
helpstring("_IWebPluginControlEvents")
]
dispinterface _IWebPluginControlEvents
{
properties:
methods:
[id(1), helpstring("method Finished")] HRESULT Finished();
};
|
|
|
|
|
I need a sample application for connecting to sql server database in ATL.
Thanks..
|
|
|
|
|
|
How can create I an ActiveX which can still active after close IExplorer?
|
|
|
|
|
I wrote a plugin for IE with ATL. Now my requirement is to pop up a modeless dialog in IE so that it can display some information extracted from the page of my IE explored.
When I use DoModal(), it works fine
But I need to show it modeless, so when I use (SW_SHOWNORMAL), my plug in crashed. it says error in atlwin.h 2815 line
Anyone can tell me why and do me a favor? Below is my code:
CMainDialog d;
HWND hIE;
HRESULT hr = m_pBrowser->get_HWND((long*)&hIE);
d.Create(hIE);
d.ShowWindow(SW_SHOWNORMAL);
//error code in atlwin.h
virtual ~CWindowImplRoot()
{
#ifdef _DEBUG
if(m_hWnd != NULL) // should be cleared in WindowProc
{
ATLTRACE(atlTraceWindowing, 0, _T("ERROR - Object deleted before window was destroyed\n"));
ATLASSERT(FALSE);
}
#endif //_DEBUG
}
|
|
|
|
|
Hi everyone,
Look at follow code:
UINT uFormat = DT_WORDBREAK|DT_EXTERNALLEADING;
CRect rect(10,30,200,60);
::DrawText(dc,"hi harry, how are you! there are no persons in the school fdsfdsfsd fsdfdsf",-1,rect,uFormat);
Run this code in the OnPaint(), the result is that there is no compelete string show in the region(CRect rect(10,30,200,60));
I want to add "..." into the end string display. If someone can help me, please tell me how.
Thanks.
|
|
|
|
|
Add DT_END_ELLIPSIS to your uFormat.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Hi Steve,
It's only one line for this case, I want to show string like this:
many of them virtual, to convert an object to and from other types. This conversion is mainly used by the property browser to convert...
Can you help me how show string in mutlti lines with '...'.
Thanks
|
|
|
|
|
Yeah, I don't think end ellipsis works with multiline. You might try DT_WORD_ELLIPSIS.
I saw some post about adjusting the height of the rect to make it an integral of the font size, but that seems like a pain.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
DT_WORD_ELLIPSIS also is fit in this case.
|
|
|
|
|
I wanna implement a toolbar for Windows using WTL classes like CToolBarCtrl. For the toolbar to work I saw in numerous examples that you have to create a reflection window, that is essentially a hidden parent for the toolbar so you can fetch the commands send by the toolbar.
I wonder if you could implement a reflective toolbar using the CWindowWithReflectorImpl?
I never got it to work though. The created window did not repaint itself and the toolbar was not visible. Anyone here knows how to use CWindowWithReflectorImpl?
Thanks in advance!
Happy coding,
Philipp Kursawe
|
|
|
|
|
Some coding standards at my end says that, Do not use smart types in a container?
Does anyone know reason for this?
|
|
|
|
|
Any extra things that one has to consider while using this?
|
|
|
|
|
When copying container auto_ptr will incur problems.
No problem with shared_ptr .
I'm using shared_ptr in a vector now.
system
|
|
|
|
|
Thanks for the answer.
but my other question is e.g.
what care needs to be taken if i use _bstr_t in a vector?
|
|
|
|
|
_bstr_t is like shared_ptr, it can be copied,
but there is a problem about the semantic:
For example,
1. let vecotr a contain some _bstr_t pointers,
2. copy a to b
3. get some pointer in b, and changed the object through the pointer, think what about a.
I think it is not the semantic of copy.
system
|
|
|
|
|
Here is my test code.
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
private:
fig_line(const fig_line &a_fig_line){}
fig_line & operator=(const fig_line &a_fig_line){return *this;}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
fig_line(const fig_line &a_fig_line){}
fig_line & operator=(const fig_line &a_fig_line){return *this;}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
class fig_line
{
public:
fig_line(ADO::_ConnectionPtr connection, const std::wstring &source_query);
virtual ~fig_line(void);
fig_line(){}
}
std::vecotr<fig_line> m_lines;
m_lines.resize(10);
</fig_line>
Why can't case 1 be compiled?
system
|
|
|
|
|
Your class must have a public or default copy constructor and assignment operator. std::vector requires an accessible copy constructor and assignment operator in order to do operations such as resizing.
In case #1, both are private; thus, case #1 does not compile. In case #2, both are public; thus, this case compiles. In case #3, the class uses the default copy constructor and assignment operator (which are too public); thus, it compiles likewise.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Tuesday, September 16, 2008 1:24 PM
|
|
|
|
|
Thank you. I see.
But I got another question, it seems that
void resize(
size_type _Newsize
); only needs a default constructor, and
void resize(
size_type _Newsize,
Type _Val
);
may need a copy constructor or assignment operator, however one of them is enough.
Is that so?
system
|
|
|
|
|
If you need a copy constructor, most likely you need it to do a deep copy due to dynamically allocated memory. Thus, a destructor and a copy assignment operator would be needed to prevent memory leaks.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Wednesday, September 17, 2008 9:23 AM
|
|
|
|
|
I'd like to do serialization using file stream (coz I don't want an extra lib, eg. boost),
then what are there problems? It may be the reason why boost has the serialization libray.
system
|
|
|
|
|
The difficulty has nothing to do with file streams - open them in binary mode (so they're just a stream of bytes, with no interpretation of things like CR-LFs) and you can store anything in them.
The serialisation problem making sure that all the objects you want to serialize have some suitable mechanism for doing so. It's also nice to be able to get those mechanisms in place in a reasonably non-intrusive manner.
Other implementation issues:
- If an object is referenced from multiple places, making sure you recreate that object once when reading in a serialized object graph
- If you have a collection (e.g. array or vector) of pointers to some base class, but the objects pointed at are of derived classes, you need to make sure that the derived class serialization functions are called
- You need some way of identifying the type of objects you've serialized
- Constructors - you really need a default (no parameter) constructor for all serializable classes, even if you don't really want one
The Boost.Serialization requirements[^] and
rationale[^] give more information about the issues involved.
I've created my own serialization code before (it must have been about 1998/9?). It was painful enough that I have no desire to do so again, so would use an existing library to get serialization.
|
|
|
|
|