|
Thanks for replying.
In your sample, you are doing "items.insert(items_t::value_type(1,2)).second", which is the value of the second half of the "pair<const K, V>" format. Your sample, in essence, simply changes the value of that second half from 2, to 3.
I'm talking about the key itself,
items.insert(items_t::value_type(1).first, items_t::value_type(99).second); It doesn't matter what integer value is placed in "second" (i.e. as much as "int" can hold). "second" is not the key; "first" is.
William
Fortes in fide et opere!
|
|
|
|
|
items.insert(items_t::value_type(1,3)).second Take a closer look. map::insert(value_type) returns a pair which is not the map::value_type . Instead, the second element of the pair is a bool which indicates success or failure. In this case, I'm trying to insert a new element into the map with the same key as the first element (1 ). It fails, since the key 1 already exists in the map.
Are you referring to retrieving a reference to a map element, then modifying the key? The STL specifies that the key for an associative container should be immutable, but some implementions do not enforce this (it may be possible to change the key in such a way as to not break the strict weak ordering or multiplicity rules -- the STL itself cannot determine this).
- Mike
|
|
|
|
|
std::map can't hold more than one equivalent key+data pair. However, if you insert an equivalent key+data pair, the old key+data pair is replaced with the new one.
--
In the land of the blind, be king![^]
|
|
|
|
|
I have a COM object I'm using in an ATL project. One of the exposed COM interfaces is called IWTOnLoad. According to the COM object's documentation, a class implements the IWTOnLoad by having a method in the class called .onLoadComplete. How would I go about implementing this IWTOnLoad COM interface in an ATL project?
The graveyards are filled with indispensible men.
|
|
|
|
|
I'm assuming you're not using attributed COM-stuff (VS.NET-specific). I don't know anything about attributed COM-programming and I really don't care to know anything about it, because I think that's a bastardization. (Goodie, I got to bitch/vent a little )
Add a , public IWTonLoad in the list of inheritances (sp?) for the implementing class.
Then add a COM_INTERFACE_ENTRY(IWTonLoad) in the BEGIN_COM_MAP map.
Then you may (optionally) add the interface to the array of "supported" interfaces in the ISupportsErrorInfo::InterfaceSupportsErrorInfo(REFIID riid) method. It depends on if you implement ISupportErrorInfo and if you use the ErrorInfo features in COM.
Then you add the method using the STDMETHOD macro as all the "other methods" are declared.
Optionally, you can also add a interface IWTonLoad in the corresponding coclass in your idl-file if you want to make the interface visible in the type library.
That should be pretty much it. You're new to ATL-programming, aren't you?
--
20 eyes in my head, they're all the same![^]
|
|
|
|
|
Hi. I am having some trouble with the Web Browser 2 control. I am able to display my html file within a window in my program, but can't print it. I am using ATL only.
The Nagivate() method has no errors but afterwards the ready state is always READYSTATE_LOADING, even some time after the browser control displays the html. When I try to print with the ExecWB function, I get error "0x80040100 Trying to revoke a drop target that has not been registered". I think there may be problem with the way the object is created?
Here is my code:
<br />
#include exdisp.h
#include exdispid.h
#include mshtmcid.h
<br />
CAxWindow wndIE;<br />
RECT rc = {0,200,800,700};<br />
HWND hIEWnd = wndIE.Create(hWnd, rc, _T(""), WS_CHILD | WS_VISIBLE | WS_THICKFRAME);<br />
CComPtr<IUnknown> punkCtrl;<br />
CComQIPtr<IWebBrowser2> pBrowserApp;<br />
<br />
wndIE.CreateControlEx ( L"{8856F961-340A-11D0-A96B-00C04FD705A2}", NULL, NULL, &punkCtrl );<br />
pBrowserApp = punkCtrl;<br />
<br />
if (pBrowserApp)<br />
{<br />
CComVariant vEmpty;<br />
hr = pBrowserApp->Navigate ( CComBSTR("c:\\report.html"), &vEmpty, &vEmpty, &vEmpty, &vEmpty );<br />
READYSTATE ReadyState;<br />
hr = pBrowserApp->get_ReadyState(&ReadyState);<br />
Sleep(3000);<br />
hr = pBrowserApp->get_ReadyState(&ReadyState);<br />
<br />
hr = pBrowserApp->ExecWB((OLECMDID)IDM_PRINT, (OLECMDEXECOPT)PRINT_DONTBOTHERUSER, NULL, NULL);<br />
}<br />
Any advice or comments would be greatly appreciated.
Thanks, Joanne 
|
|
|
|
|
Update Internet Explorer up to last version. Can will help
|
|
|
|
|
I've answered my own question now, but FYI, the constant IDM_PRINT should be OLECMDID_PRINT, ie
ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, &vArg, NULL);
|
|
|
|
|
Hi,
I have a vector of classes.
I would like to write the entire vector to disk
I would like then load the entire vector back into memory.
And idea of the best way to do this?
Jeremy Pullicino
C++ Developer
Homepage
|
|
|
|
|
|
Looks like a good idea to me. I'll give that a try. Thanks for the link.
John
|
|
|
|
|
One solution is STL std::copy().
Kuphryn
|
|
|
|
|
Hi there,
please tell in detail ,what do u really mean by resource in ur project.
Although if u want to create an ACtiveX control at run time.
u can do it if u have the class id of the component selected by user.
Class CWnd * wnd =new CWnd();
and using wnd->CreateControl method and passing the Class ID of the selected ActiveX control u can create the control , and this control can be created in design mode by setting creation flag as WS_DISABLED.
u can also get its IUnknown pointer, calling GetControlIUnknown of CWnd class ,
and thru this IUnknown pointer u can get IDispatch pointer and then u can enumerate all methods and
properties of this control and even can Invoke them at run time.
u can even open the property page of this ActiveX Control using OleCreatePropertyFrame API.
Regards
Abhishek Srivastava
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Hi All,
If it doesn't support serialization,Is there any way for saving data or whatever it may be.Could you please advise me?
Thanks in Advance,Deepa.

|
|
|
|
|
It doesn't, but there's no reason why it couldn't, although you'd need a base mechanism for fabricating objects prior to calling their serialisation method, similar to the MFC approach, unless anyone knows of a better way.
Steve S
|
|
|
|
|
Are there any STL data structure which behave like CMapPtrToPtr
thanks in advance
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
|
|
We have been having very random crashes from an application in production at a customers site. To cut a very long story short Microsoft Australia have told me that it is the result of non thread safe code in the STL shipped with VS6.
We have the following options
1) Upgrade Dinkumware STL from dinkumware site. We would then have to build a custom VC runtime dll with the NEW STL code and ship that as well. Plus the web site includes the following comment
...Please note that this implementation is still not as thread safe as it should be, because of the reference-counted implementation...
2) Upgrade to VS7 dot net. This is Microsofts recommendation.
3) Use Another STL implementation like StlPort
4) Recode system not to use STL
Anyone got any advice? had a similar experiance?
Regards
Josh
|
|
|
|
|
Josh Gray wrote:
Anyone got any advice?
I think the easiest part is option 3). Option 4) is a bit drastic and would require lots of coding (not your idea of a quick fix I imagine).
2) may be easy, but it may also be your worst nightmare. It all depends on if your code compiles and run correctly using that compiler.
Option 5) could be to augment your code with synchronization mechanisms external to the containers. Might be a lot of work though, or it might not. It really depends on your design.
Option 1) is really not an option since, as you say, it has MT issues.
--
Talk to the hand!
|
|
|
|
|
My advice is to use STLPORT and make sure that you compile and use the STLPORT the IOSTREAMS.
John
|
|
|
|
|
We have decided to go the Dot Net route.
Running a build now, only about 1000 signed / unsigned mismatch errors so far and counting!
|
|
|
|
|
Hello Everyone,
I need your sincere help in finding the suitable header file
for the wsnprintf() method. For finding the Domain Users in
Microsoft Active Directory Services(ADSI), i called the ADSI API i.e. FindUsers() to fetch the list of user objects
from a container or directory tree. For that the FindUser()
API code has used the method i.e. wsnprintf() for adding the filter.
RESULT FindUsers(IDirectorySearch *pContainerToSearch, // IDirectorySearch pointer to the container to search.
LPOLESTR szFilter, // Filter for finding specific users LPOLESTR *pszPropertiesToReturn, // Properties to return user objects found.
BOOL bIsVerbose)
This FindUsers() is the API where the definition of the ADSI API calls the wsnprintf() method like as below : DWORD
#define MAX_PATH 520
dwLength = MAX_PATH*2;
// Create search filter.
LPOLESTR pszSearchFilter = new OLECHAR[dwLength];
// Add the filter.
wsnprintf(pszSearchFilter, dwLength, L"(&(objectClass=user)(objectCategory=person)%s)",szFilter);
Please help me out in giving me the details about the header file and the .lib file to make the code compilable.
Thanks,
Derik;)
|
|
|
|
|
I've worked with Microsoft Office development , now I have next problem .
I 've created new Word XP document - E-mail message and try to set programmicaly value of suc fields as Subject,Recepient also add File Attachment . But I can't get access for this fields . I've found that this fields are included in the command bar Envelope that has type msoControlPane . How can I know that class from Microsoft Word Type library 10.0 correspond for this Pane control (_CommandBarButton,_CommandBarActiveX,... or something else) and how can I get access for fields that included in this Pane . Also how can I add extended fields as File Attachment or something else .
|
|
|
|
|
I am using a vector to hold a list of pointers that are newed in the start element handler of the Expat parser. Everything works fine until I exit the application and run my cleanup function.
The following code appears to fail or at least produces a memory leak.
Button *pButton; // pure virtual
vector<button*> vButtons; // holds list of created buttons
// from start handler
pButton = new Label( c_Label );
vButtons.push_back( pButton );
// Cleanup
if( count > 0 )
{
vector<button*>::iterator itClean;
for (itClean = vButtons.begin(); itClean != vButtons.end(); ++itClean)
{
delete *itClean; // crashes here everytime
}
vButtons.clear();
}
Any idea why this is leaking?
-Steve
|
|
|
|