|
say i have a data that i should be able to lookup using EITHER a int key or a string key..i repeat EITHER..
what kind of container should i be using
|
|
|
|
|
Boost.multi_index[^] should do the job.
Otherwise, you'll need to have a container for the data and separate containers for the mappings (that's what multi_index does internally, I believe).
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Hi,
I'm using CRebarCtrl to hold my commandbar, the menu's though appear as toolbar button but with the menu text, when you click nothing happens!
I used CComand bar class from the the OfficeXP Menu article http://www.codeproject.com/wtl/menuxp_wtl.asp#xx135189xx[^]
Since my app isn't based on CMainFrame, i didn't have a a standard menu, so i created CMenu on the fly and attached it to CCommandBarCtrl does this have anything to do with it.
|
|
|
|
|
hello everybody!
i habe an urgent problem!
there are 2 components i developed in Visual Studio 6 with ATL.
i used the standard wizard to create the DLL´s.
Short explaination of the 2 components:
1. Modul: Search: this dll makes a search against a data-file. it has got interface can used by the most common program languages.
2. Modul: SearchOverXML(using MSXML 4 SP2): this dll receive the parameters used for Modul 1 from a Client, receive a Object, which contains the Result from Modul 1 and the Modul 2 will write the Result-Data in a specific XML-Structur to the Client.
and now my problem. if i call Modul 2 10000 times from a client, the memory is rising and rising and if memory is out the application crashes.
i cleanup all references to MSXML and if i want to call the Release-Method on the Modul 1 Object (i forgot it at first) the Client crashes and the Memory-Leak is still there.
if i call modul 1 only, i have got no problem!
so, i dont know what to do know. maybe the implementation of Modul 2 is wrong. Has somebody a Code Example how to call a ATL Server from a other ATL Server?
thanks for help
best regards
andreas
|
|
|
|
|
I am using a SpinButton control to let the user select a value. If the user selects a new value then I want a listctrl to immediately repaint itself to show a response to this value change. The repainting only occurs when I scroll down the list control. I am using C++ on Visual Studio 2003 .NET.
My question is how do I force the list control to repaint itself, so that I don't have to scroll up or down to get a repaint? I have tried sending messages to the list ctrl and even invalidating the client area of the list ctrl.
I am the handsome one in the crowd.
|
|
|
|
|
|
I want to transfer a large data buffer, maybe 10k. Who can tell me how to realize my idea?
|
|
|
|
|
|
thanks a lot, please tell me , if I have a data buffer like "BYTE* p = myData;// there are many 0 values in buffer", I know buffer 's length, how to transfer the data use BSTR?
|
|
|
|
|
Don't treat the BSTR as a null-terminated string!
Use SysAllocStringByteLen to allocate the space.
Cast the BSTR to BYTE* and use SysStringByteLen to get the byte count.
Free the string as normal with SysFreeString .
MSDN does say that a SAFEARRAY with element type VT_UI1 is preferred, in order that you don't get translations on 16/32-bit borders...but a) who uses 16-bit OLE now?, and b) BSTR is a lot easier in C++
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
It seems as if the method does not work. Following my code :
1:declare interface------
dispinterface _IMyEvents
{
properties:
methods:
[id(1), helpstring("method Test")] HRESULT Test([in]DWORD dwLen, [in] BSTR pData);
};
2:method implement-------
HRESULT Fire_Test(ULONG dwLen, BSTR pData)
{
CComVariant varResult;
T* pT = static_cast<t*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[2];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<iunknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<idispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[1] = (int)dwLen;
pvars[0] = pData;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
3:call method in Server Object------
{
char a[10] = _T("abcdef");
a[8] = 'x';
BSTR bstr = SysAllocStringByteLen(a, 10);
Fire_Test(10, bstr);
}
4:called in Client -------
long CEventNotifySink::OnTest(DWORD dwLen, BSTR pData)
{
UINT len = SysStringByteLen (pData); // result: len!=10
BYTE * p = (BYTE*)pData; // pData refs wrong address
SysFreeString(pData);
return 0;
}
where is wrong?
|
|
|
|
|
The problem is CComVariant - that uses SysAllocString to copy the BSTR. The signature of SysAllocString is BSTR SysAllocString(const OLECHAR * sz); - it assumes that the input BSTR is null-terminated.
If you create your VARIANT manually, you shouldn't have a problem:
VARIANT v;
V_VT(v) = VT_BSTR;
V_BSTR(v) = pData;
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
not only length, the "pData" refer wrong address, data is wrong.
|
|
|
|
|
Creating the CComVariant *copied* the BSTR - i.e. created a new one. It will therefore have a different address from the original.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I trace my my code and find that, in ATL,
COleDispatchImpl::Invoke(...) method calls CallMemberFunc(...),
and CallMemberFunc() method calls PushStackArgs(...),
there is such a sentence----"pArgTemp->bstrVal = AfxBSTR2ABSTR(pArg->bstrVal);" in PushStackArgs(...) method, After this call happened, my buffer data lost .
how to resolve the problem?
|
|
|
|
|
Hmmmm - COleDispatchImpl is part of MFC, not ATL...
Anyway - I've built a sample COM object (with connection point) using ATL and a harness executable (built using ATL to implement the connection point interface). This passes a BSTR as the event parameter and it seems to work fine...
I've got this code to fire the event:
STDMETHODIMP CPooh::Trigger()
{
BSTR bs;
BYTE a[10] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x0, 0x1, 0x2, 0x3, 0x4 };
bs = ::SysAllocStringByteLen((const char*)a, 10);
Fire_Pooh(bs);
return S_OK;
}
and this code catching the event:
void __stdcall OnPooh(BSTR bs)
{
size_t s = ::SysStringByteLen(bs);
BYTE* data = (BYTE*)bs;
}
I'm getting s set to 10, and data containing the 10 bytes set in the Trigger method.
As I said - I'm using ATL code all the way and it works fine...
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
thank you, Stuart Dootson. I wrote client with MFC, there must be something wrong in my code. Later I wrote a new client with ATL, everything works fine.
|
|
|
|
|
samfromcn wrote:
something wrong in my code
I'd bet that it's in the MFC code - that's why I use ATL for COM code
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Hi, is there an "easy" way to save the state of an object to a file without using MFC or COM objects?
im working on a WTL project that needs to save and read a special form of "document" to file, (kind of like MFC´s Serialize()), but even tho i have the code to do it in binary mode, i would prefer to do it on XML.
The documents are quite large, and consists of other objects containing several arrays of CStrings (WTL:CString that is), and primitives like ints, floats, etc.
Is there a Non-MFC, Non-COM related XML parser i could use?
thanks!
The only stupid question is that one wich is never asked
|
|
|
|
|
I understand you not using MFC ( what XML parser uses MFC anyhow ? ), but why not COM ? Do you want to avoid a dependancy ? I'll admit that I was annoyed recently to find that my video jukebox program needs IE5 for MSXML because I used openXML in a single database query.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
thanks for your answers, to be honest, i dont wanna include COM simply because i dont know how to use it (blushes). I dont know about interfaces and that stuff.
But lets say that the only thing off-limits would be MFC (COM is OK), which parser you guys reccomend?
|
|
|
|
|
How about using a serialization library? Boost::Serialization supports text, binary and xml as output targets, and is pretty simple to use.
TinyXml Is a nice small library that has picked up a fair ammount of popularity.
Xerces To my way of thinking was pretty bloated, but if you need your output to support almost everything in the XML standard (especially different encoding schemes) this is the way to go.
|
|
|
|
|
boost looks VERY interesting, i think ill go with it.
Thanks!
|
|
|
|
|
Hi,
Office 2003 provides smart tag functionality to outlook if Word 2003 is the default email editor. Oulook uses InternetExplorer_Server
class window to show the messages composed using MS-Word or HTML
format and this window is capable of displaying smart tags. Messages
composed in Plain Text or Rich Edit are displayed in RichEdit20W
class window and this window cannot show smart tag information.
My problem is to provide smart tag kind of functionality to this
RichEdit20W class window. Is there any way to get the handle of
email viewer window of outlook?
One more behaviour I've observed that the smart tag information is
embeded into the message at the time of composing the message and
not at the time of viewing it. My requirement is to recognize smart
tags at the time of viewing the mails. I can choose any editor for
composing the message and any editor for viewing the message. I want
the smart tag functionality be available in every case.
Please help me if you have any idea in this regard.
- Rajeev
|
|
|
|