|
you might want to verify that "it" actually represents to a valid object (test that it's not equal to mycollection.end() )
also, since the iterator is just a reference to whatever your set is holding, you can create a variable, assign it to the iterator and look at that:
myobject temp = (*it);
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
I thougtht of that, but my set is holding pointers to CZoom objects (which are CDialog derived basically). SO i really dont know how to look at this pointer..I will go and test to see if find is returning .end() though, so thanks. However, its not illegal to return end if not found,,,and it doesnt get past the find. I checked to see what (this) had and its something non-null. Thanks for the help,
ns
|
|
|
|
|
My first question is there a guide to threads somewhere on the web? Something that takes a novice user into account? (ie hand holding) I have the basics down I think. Correct me if I am wrong.
1 Add a member function static UINT WorkerThread(LPVOID lParam)
2. Add the code you want to call in the thread to the implementation of WorkerTHread(...)
3. Call AfxBeginThread(WorkerThread, yourParam);
My question, is there a way to be notified upon completion of the thred? Can you tell if the thread is still running? How do you kill a thread if it is out of control? Questions questions questions!! Thanks for your help.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
those are the basic steps for launching a thread, yep.
as for the Q... well, there are tons of ways to do it. you can use the synchronization classes that are built into windows: Events, Mutexes, etc.. or you can do it the "manual" way by sharing a flag between your thread and the owner: pass a pointer to a bool (best to mark it volatile : volatile bool b; ) into your thread proc, then have the thread set that bool when it's done; the parent thread would periodically look at the bool to see if the thread has changed it.
testing for deadlocks can be simple: have the thread periodically set some variable to a random/increasing/decreasing value. the parent can just look at this value and note if it hasn't changed in the past X seconds. if it hasn't changed, the thread might be hung.
there are a articles on this site that cover both methods in gory detail. look in the "threads" section.
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Hello,
I want to change the font of all the Frame Static controls on my dialog.
The following code will loop through all the dialog's controls and change all their fonts.
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->SetFont( &MyNewFont, FALSE );
pwndChild = pwndChild->GetNextWindow();
}
Could somebody tell me how I can identify if the window is a static frame type.
Thanks,
John
|
|
|
|
|
You can do this so:
TCHAR buf[50];
GetClassName(pwndChild->GetSafeHwnd(),buf,50);
if(strcmp(buf,"Static")==0)
{
...
}
But I don't think it's a good practice.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks Pavel,
The Static Frame control's ClassName is 'Button' so now I have to work out how to differentiate between it and other Button types.
|
|
|
|
|
I want to create a wrapper for sprintf , a function that uses variable arguments.
Mu function should look something like this:
void extra_sprintf(const char* lpText,...)
{
char buf[256];
sprintf(buf,lpText,...); // ... exact same arguments from extra_sprintf
// some extra code
}
How can I call the regular sprintf function inside my extra_sprintf function, as simple as possible?
tnx
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Check va_arg, va_start, va_end and va_list.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I can do something like:
va_list args
va_start(args,lpText)
...
va_end(args)
But then, how can I pass the list to sprintf in just one call? If I pass args, it will not work, nor with lpText
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Grote Smurf wrote:
But then, how can I pass the list to sprintf in just one call?
Use vsprintf.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
int mysprintf (char *string, const char *format,...)
{
va_list arglist;
va_start(arglist, format);
int retval = vsprintf(string,format,arglist);
return(retval);
}
Pavel
Sonork 100.15206
|
|
|
|
|
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Hi
I'm thinking to write a protection routines and I was wandering how I can get info about a particular computer as HD,CPU , SPEED,MEMORY etc.. or if somebody know a special class related.
Best regards
|
|
|
|
|
There is no MFC class which implements all the stuff. But I know Win32 API functions which can help you to get some info about disk drives:
GetLogicalDrives
GetVolumeInfo
GetDiskFreeSpace
GetDriveType
______________________
Vladimir V. Polischuk
URL: http://www.alarit.com
|
|
|
|
|
I just rcvd this in the last newsletter:
CAMEL - CPU Identifier Class
- voodoopriestess (7 Sep 2002)
A class to detect ALL the features of the CPU / CPUs in the local
system. Now at version 1.2
http://www.codeproject.com/system/camel.asp
|
|
|
|
|
Hi,
I need to put an image control (third party) into the status bar of my MFC MDI app. Any links or sample code is much appreciated.
Thanks,
ns
|
|
|
|
|
I'm using this control to show animation on statusbar. Maybe you can find some inspiration with it.
Pavel
Sonork 100.15206
|
|
|
|
|
Hi,
I'm using the method Module32Next in my application.Upon running the application an error pops up saying "The Procedure entry point Module32Next could not be located in the dynamic link library KERNEL32.dll".
I'm unable to resolve the problem.
Can anybody help me please.
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Are you runninig on NT4?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Yes I'm using NT 4.Could this problem be due to an obsolete Kernel32.dll file.I checked the dll with the dependency Viewer and found out that the method Module32Next was not in the list.If yes then how do I change my existing Kernel32.dll to the latest version.Since Windows NT uses the Kernel32.dll it won't allow to overwrite the old file with the new file straight away.How do I go about this?
Need guidance,
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Module32Next isn't available on NT4. AFAIK, there's no redistributable providing ToolHelp32 functions you could install on NT4. You'll have to use PSAPI instead.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Hi,
I need an advice from experienced programmer. CAsyncSocket is not too good documented for use in multithreading enviroment. I wrote some testing programs, so i found out that all callback functions are called in the same thread, throught message map (correct me if i'm wrong).
Here's what i need :
Implement communication functions with CAsyncSocket in separate working - non GUI thread.
1. Should I create message map for this thread ? (an how ?)
2. i need sometimes to wait for incoming data. How to implement waiting ? Is it possible to make GetMessage() loop to wait ?? how ?
I don;t understand how and where does CAsyncSocket dispatch socket notification messages and translates them to callback. How does this work ? MFC source is too big for studying.
Thank you
rrrado
|
|
|
|
|
I wouldn't use any of the socket classes that MFC has if I were you!
I would code it from scratch!
But... if you do want to use it, it's up to you!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Well, an asynchronous socket concept is thought to run in one thread context by purpose! It has some advantages (for some kind of tasks).
If you are sure that a multithreading concept fits better to your task, use a different socket class! For example our loved codeproject provides some kind of (IO completition port?) network classes... check it out: http://www.codeproject.com/internet/
btw Anderson... CAsyncSocket is not perfect implemented (missing asynchronous DNS, no reference buffering), but it's not *that* bad...
|
|
|
|