|
Thanks. I agree.
But how to change it?
I first new a obj_map_list_type type CList pointer,
give its values,
but how to save this pointer's pointed content to the map?
The map's SetAt function really not smart. :-p
Thanks again.
obj_map_list = new obj_map_list_type;
obj_map_list->AddTail("AAAAAAA");
obj_map_list->AddTail("BBBBBB");
obj_map.SetAt("ABC", obj_map_list);
|
|
|
|
|
Since you are using CStringToObMap, you store pointers in the map, not the objects themselves. To retrieve it again, you need to retrieve the pointer:
CStringList* pList = new CStringList();
// Add stuff to pList...
mapMyMap.SetAt( "Blah", pList );
// Retrieve it
CStringList* pList;
CString sKey;
for ( POSITION pos = mapMyMap.GetStartPosition() ; pos != NULL ; )
{
mapMyMap.GetNextAssoc( pos, sKey, (CObject*&)pList );
// Now access the list through pList
}
The difference here is that we are casting a pointer to the string list to a pointer to a CObject pointer (which is legal since CStringList is derived from CObject), rather than a CStringList object to a CObject pointer, which is never legal.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Many thanks for nice explanation.
It works.
Have a nice day!~
|
|
|
|
|
As Dave said, you need to remember what's a pointer. Change this:
POSITION pos, kk2;
obj_map_list_type obj;
CString key;
to this:
POSITION pos, kk2;
obj_map_list_type* obj;
CString key;
and this:
kk2=obj.GetHeadPosition();
int_jj=obj.GetCount();
while (kk2!=NULL)
{
key=obj.GetNext(kk2);
}
to this:
kk2=obj->GetHeadPosition();
int_jj=obj->GetCount();
while (kk2!=NULL)
{
key=obj->GetNext(kk2);
}
You should also check out std::list<> and std::map<> , which allow type checking and are a whole lot less messy than the archaic CMap and CList .
---
Not one of them, IMO, should be called beer. Maybe malt flavored mineral water.
- Jörgen Sigvardsson on Bud, Coors and Miller
|
|
|
|
|
Thanks a lot for your demo code.
Have a nice day!~
|
|
|
|
|
Please can any one help, how to add closed caption text to Video using Overlay Mixer. In Win XP we can do it using VMR interface. but i want it in 2000. can any one help.
Thank You
Prudhvi
|
|
|
|
|
Hi everyone.
I've read a lot of articles on this Page an I suppose this is the best C++ site on the NET. Thanx for this nice community. Nevertheless I am new in this Messageboard, so greetings to everyone and I hope that this conversation will be as nice as all other stuff on this page.
Now my Question!
My current project follows my idea to encode a nice platformindependent (Windows and Unix) "Reverb-Engine". I know, there is a lot of finished reverb-code on the net, but I try to make my own for practice.
I tried the winmm.lib to make my Waveoutput play. It works poperly and Big thanks to Pierre Canthelou for his clean Engine. Your concept of "three-bufferning" was a big deal. I spent a lot of time to make it work with double buffering, but those clicks made me dizzy. Thanks a lot. Three buffers. Just one index away from my goal.
But now about my question; Pierre Canthelou and me use the delivered winmm.lib to make the Wave-output work. I am coding since win98 and this lib is working without problems except this one: I am able to select a wave-device and the sound is always playing, but if I select my second soundcard the sound comes from my first device. After a long time of debuging I discovered, that my sounddevice is always my primary soundcard that is selected within the "sound-tool" placed in the control-panel of Windows. That means: Only my WAVEMAPPER-Soundcard plays my sound. With this problem in head I was searching for a while on the net about whats going on (I use Win XP at this time) and discovered this:
winmm is slow (I never made the benchmark by myself!). There are more powerful engines (for example direct sound from Microsofts DirectX)
I try to develop platform independent software (for practice at all) and I would like to connect to the sound driver directly. Is there any page or information on the net that delivers information about connecting (low level) to windows-drivers.
I know it is not neccesary, but I am freak about trying everything out.
If you can help me I would be happy about your answer.
Greetings
Jacek Wisniowski
|
|
|
|
|
Hey,
I'm trying to close Kazaa using an IE toolbar. Kazaa has a system tray icon so it cannot be shut down using WM_CLOSE, it just minimizes to the tray. Someone suggested that I use TerminateProcess but I am having trouble.
To terminate the process you have to find the ExitCode, this is the code to find the ExitCode:
<br />
BOOL GetExitCodeProcess( <br />
HANDLE hProcess, <br />
LPDWORD lpExitCode<br />
);<br />
but to actually terminate the process the code is:
<br />
BOOL TerminateProcess(<br />
HANDLE hProcess, <br />
DWORD uExitCode<br />
);
When I try to execute the program I get the error:
cannot convert from 'unsigned long *' to 'int'
I am not sure how to convert the pointer to an int, can anyone help me?? Thanks.
|
|
|
|
|
You only need to call TerminateProcess() to kill a process. GetExitCodeProcess() is used if you want to find out a process's exit code *after* it has finished.
But to answer your original question, you are probably doing this:
DWORD exitCode ;
BOOL rc = GetExitCodeProcess( hProcess , exitCode ) ;
when you need to do this:
DWORD exitCode ;
BOOL rc = GetExitCodeProcess( hProcess , &exitCode ) ;
If GetExitCodeProcess() succeeds, it will have placed the appropriate value in 'exitCode' for you.
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.2 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
I tried this:
DWORD exitCode;<br />
BOOL getcode = GetExitCodeProcess(winKazaa, &exitCode);<br />
BOOL terminate = TerminateProcess(winKazaa, exitCode);
but it didn't work. Is there something I'm still doing wrong?
|
|
|
|
|
Sigh...
Ignore my previous post. I should really read the question properly before answering these things
I just tried compiling your sample and it worked fine!
The compiler error suggests that the problem is with winKazaa, not exitCode (assuming it is a HANDLE). You may be pulling in a header file that defines one of the functions you're calling with a different parameter list (!)
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.2 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi there. Is there a quick answer to this following question:
What's the difference between automation compliant COM and ActiveX component.
Thanks
norm
|
|
|
|
|
Nothing!
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
"Nothing" as in "No difference"?
I just want to reconfirm this. Thanks
|
|
|
|
|
ActiveX is just a fancy name for COM.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
This problem has been driving me nuts for several days and I'm hoping a fresh mind out there can shed some light on this problem for me.
I've written an MFC application that can be installed as an NT service. Naturally, an NT service isn't terminated when the user logs out, however I do want to do a few things within the app when the user logs out or shuts down the computer. I'm able to determine when the user is logging out and perform the appropriate functionality by acting on the WM_QUERYENDSESSION and WM_ENDSESSION Windows messages.
Here's the problem. When the user logs out, everything is fine. They log back in and my service is still running as it should be. When they log back out or attempt to shutdown, it would appear that my application aborts the log off / shutdown. However, I'm always returning true to the WM_QUERYENDSESSION message. If I remove my handling of the WM_QUERYENDSESSION message, the same still happens.
It gets even weirder when I discovered that my application doesn't even receive the WM_QUERYENDSESSION message the second time I try logging out, but it DOES receive the WM_ENDSESSION message (with wParam = 0).
If I close my application, Windows is fine shutting down. If I restart my application, it works fine once before repeating the above.
Can someone save the remainder of my hair before I finish pulling it out?!
|
|
|
|
|
Help with TransparentBlt()
I'm working from the CP example "Oscilliscope/StripChart Control" by Mark C. Malburg (http://www.codeproject.com/miscctrl/oscope.asp).
What I'm trying to adapt it to do is have several plots on the same chart PLUS the ability to turn off/on any one of the plots.
I am trying to use CDC::TransparentBlt(), but the compiler does not recognize this function. I looked at the AfxWin.h declaration for CDC and it is not there -- ...\microsoft visual studio\vc98\mfc\include\afxwin.h (VC++ 6.0)
I'm running VC++ 6.0, Win2000, Service pack ???
What do I have to do in order to get this to work?
Thanks (in advance for any help)
Johnny
|
|
|
|
|
May be this is just me, but I always thought that TransparentBlt is a member of ATL CDC ( atlgdi.h ?), but not MFC CDC (afxwin.h) at least at 6.0 level.
Either way whats wrong with using ::TransparentBlt(dc->GetSafeDC(),....);
|
|
|
|
|
Hiya I am writing a window sockets program. I can find loads of examples of setting the IP address and then displaying that, but I can not find out how to display the IP Address once I have got the computer name..I have this so far:
char szHostName[200];
struct hostent *host;
gethostname( szHostName,strlen( szHostName ));
host = gethostbyname( szHostName );
// now display the IP Address of the host??
I have seen the inet_addr function, but don't know how to use it..
|
|
|
|
|
Example:
in_addr *addr = (in_addr*)*host->h_addr_list;<br />
<br />
CString s;<br />
s.Format("%d.%d.%d.%d", addr->s_b1, addr->s_b2, addr->s_b3, addr->s_b4);
Regards,
BB
|
|
|
|
|
Hiya, thanks for that and tried it but it says that s_b1 is not a member of in_addr. Which it isn't.
I put it in exactly as suggusted. But S_un is the member of in_addr .i.e
addr->S_un
What can I do to fix this??
Thanks again,
grahamoj
|
|
|
|
|
OK, I mispelled this. I guess you may use:
s.Format("%d.%d.%d.%d", addr->S_un.S_un_b.s_b1, addr->S_un.S_un_b.s_b2, addr->S_un.S_un_b.s_b3, addr->S_un.S_un_b.s_b4);
Regards,
BB
|
|
|
|
|
Hi ... you may try this code snippet ....
the result should be something like 123.456.789.123 ...
hope it will help you
struct hostent * pHost = gethostbyname(szHostName);
if(pHost != NULL)
{
for(int i = 0; (pHost->h_addr_list[i]!= NULL); i++ )
{
CString csIP = "";
for(int j = 0; j < pHost->h_length; j++ )
{
if( j > 0 ) csIP += ".";
CString addr = "";
addr.Format("%u", (unsigned int)((unsigned char*)pHost->h_addr_list[i])[j]);
csIP += addr;
}
AfxMessageBox( csIP );
}
}
|
|
|
|
|
use inet_ntoa fucntion:
char szIP[16];
struct hostent *host = gethostbyname( szHostName );
struct in_addr *InAddr = (struct in_addr*)host->h_addr_list[0];
strcpy(szIP,inet_ntoa(*InAddr));
|
|
|
|
|
Anyone ever done this? Specifically, I have a crapload (well, five of the little beasties anyway) of 122x32 LCD panels that use the SED1520 controller, and I wanna play with them, maybe monitor case/cpu/gpu temperatures.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|