|
I used the #include <map> and I got 14 WARNINGS to many to enumarate it here
but <map> is for map only right? or is it the same file that I shall include if I used multimap?
here's my code after I changed it to <map>:
#include <string>
#include <iostream>
#include <map>
using namespace std;
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
int main()
{
multimap<const char*, int, ltstr> m;
m.insert(pair<const char* const, int>("a", 1));
m.insert(pair<const char* const, int>("c", 2));
m.insert(pair<const char* const, int>("b", 3));
m.insert(pair<const char* const, int>("b", 4));
m.insert(pair<const char* const, int>("a", 5));
m.insert(pair<const char* const, int>("b", 6));
cout << "Number of elements with key a: " << m.count("a") << endl;
cout << "Number of elements with key b: " << m.count("b") << endl;
cout << "Number of elements with key c: " << m.count("c") << endl;
cout << "Elements in m: " << endl;
for (multimap<const char*, int, ltstr>::iterator it = m.begin();
it != m.end();
++it)
cout << " [" << (*it).first << ", " << (*it).second << "]" << endl;
}
Thanks/Regards
Sidney
|
|
|
|
|
There is a known issue with VC6 sucking that means you will get warnings unless you #pragma them away. The problem is VC, not STL.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
A bug? humm... MS is bad did you try running the simple code which used multipam? I need the multimap to work co'z the cannot accomodate my data criteria... can you try running it?
Thanks/Regards
Sidney
|
|
|
|
|
I didn't notice before - using namespace std is BAD. Put using decalrations only for the bits of the namespace you need.
Apart from that the code runs fine except it has exactly the warning I anticipated seeing.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Christian Thank you very much!! now the multimap works great The warnings are all gone hehehehe! I used an STL.h that I got from a friend. Thank you very much everyone!!!
Thanks/Regards
Sidney
|
|
|
|
|
I was wondering..do you have to call RemoveAll on the destructor of your CStringArray or CMaps and other collections or do the destructors take care of everything automatically.
I have always maintained this practice since I took an MFC course a couple of years back, but I wasn't 100% sure if this is actually necessary? If it is, then why? shouldn't the destructors take care of everything?
|
|
|
|
|
the destructors will call RemoveAll (or equivalent).
-c
Cheap oil. It's worth it!
|
|
|
|
|
I have an SDI MFC application, and I use OnPaint() to draw something to my view. Since my view is updated very frequently, (less than 1 second), I am thinking of using memory DC to reduce the flickering. I tried this:
{
CPaintDC dc(this);
CDC memDc;
memDc.CreateCompatibleDC(&dc);
dc.BitBlt(0,
0,
displayWidth,
displayHeight,
&memDc,
0,
0,
SRCCOPY);
memDc.DeleteDC();
}
but there is nothing on the display. The MSDN document said that I should select a bitmap to my memDc. I did so with a dummy blank bitmap resource I created using resource editor. After I select it to the memDc, there will only be the dummy bitmap displayed on my screen. How could I get my drawing displayed?
|
|
|
|
|
you need to create a compatible bitmap and select it into the memDc before you draw to memDc.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Thank you for your fast help. Now I got my drawing dislayed on the monitor, but the background is totally black. And it flickers even worse. what could be wrong?
|
|
|
|
|
let me try OnEraseBkGround.
|
|
|
|
|
Got it. After overwrite the OnEraseBkgnd(), no flicker anymore. Happy..
|
|
|
|
|
I still couldn't figure out why the background color turns to be black instead of the default one. could you give me some clue?
|
|
|
|
|
Call FillSolidRect(...) with the memory object.
One good thing about getting older, you don't lose the ages you've been!
|
|
|
|
|
|
|
Hi everybody,
On windows xp netstat -o command can show the process id of an open tcp port.
Can i do the same thing on windows nt/9x using an API ?
Thank you,
Orcun Colak
|
|
|
|
|
Hi.
I have discovered a problem with multithreading processes in my program. Here is an example.
- program starts
- CMyProgramApp::InitInstance() calls RestoreState() in CMainFrame()
- RestoreState() restores the windows positions via registry
- RestoreState() restores data (int, char, binary, etc) from registry to variables in CMyProgramDoc()
- RestoreState() calls a function in CMyProgramDoc() which begins a worker thread
- worker thread does some calculation
Problem: For some reason, I have found that if the calculation is big i.e. it takes a long time, the thread never gets closed and deleted.
The worker thread PostMessage main frame a message indicating that it is done. However, sometimes main frame never received the message!
-----
UINT WorkerThreadFunc(LPVOID pParam)
{
...
pWnd->PostMessage(WM_USER_WORKERTHREAD_CLOSED, 0, 0);
return 0;
-----
There is a handler in main frame to handle the message that class a function in doc to close the worker thread; however, I found that if the worker thread takes a long time to finish a calculation, main frame never receive or ignores the PostMessage.
The only problem I can think of right now is I am starting the worker thread too early. In other words, I should start the worker thread after the program has started and all window positions have been restored.
Do you see any other flaws? Please post.
Thanks,
Kuphryn
|
|
|
|
|
Okay.
Damn. The problem was not anything except bad debugging. I made a small mistake that caused a program loop inside the worker thread. The worker thread never PostMessage! It there is a loop that never exits.
The solution was to reset one of the variables I used inside the while look.
The breakpoint feature in Visual C++ is extremely useful!.
Special thanks to IndirectX of GameDev for breaking up the subject about breakpoint.
Kuphryn
|
|
|
|
|
OK, i need to make a dll that will add an entry to the windows explorer context menu, i had a look at this article on codeproject but found that I could not make sense of the code, that i need and know is in there. Cananyone help me out?
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I think Microsoft has invented A.I. My computer has a mind of its own!"
|
|
|
|
|
look around a bit on this site... there are a ton of articles on shell extensions.
-c
Cheap oil. It's worth it!
|
|
|
|
|
I have tutorials [part 1 and part 2] on this subject. Maybe a tutorial format will be easier for you to digest.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork-100.10414 AcidHelm
|
|
|
|
|
I saw your tutorials soon after I made this thread. IT was just right for me, understood it ( 'cos its made for idiots )
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I think Microsoft has invented A.I. My computer has a mind of its own!"
|
|
|
|
|
Michael Dunn wrote:
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
you know, i dont think you should be advertising your own software (shareware i might add) on codeproject, unless its one of those big banners, am i right?
==================================================
Homepage: www.onyeyiri.co.uk
Email: theeclypse@hotmail.com
"I think Microsoft has invented A.I. My computer has a mind of its own!"
|
|
|
|
|
No, it's acceptable here to pimp your own stuff in your signature. Else I wouldn't be doing it.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork-100.10414 AcidHelm
|
|
|
|