|
brianwelsch wrote:
Maybe a clear head on Monday will make it obvious to me.
Yes, it often helps.
brianwelsch wrote:
Enjoy the weekend!!
Thanks, you too .
Pavel
Sonork 100.15206
|
|
|
|
|
In a create function of a modeless dlg I have an Images class object (my custom class) which puts a pointer into the member set variable:
image.pZoomSet.insert(this);
Now I have several modeless dlgs spawned, each with a unique image object (which has a <set> member called ZoomSet):
BOOL CZoom::Create(UINT nID, CWnd *pWnd, CString& trioIndex, CImages& image)
I close these 'Czoom' class modeless dlgs like this m_pImage = &image )
void CZoom::OnClose()
{
std::set<CZoom*>::iterator it = m_pImage->pZoomSet.find(this);
m_pImage->pZoomSet.erase(it);
}
If I have say four of these zooms up , three will close (no visible pattern), the fourth wil crash
at the find(this), but sometimes its not even the fourth one - might be the second one - that crashes when I close it. How do I debug this? I cant "see" into the iterators etc
|
|
|
|
|
What you explain so far seems OK. Are you messing around with image somewhere else? I've I understood it right this object is unique --CZoom s only hold a pointer to it in order to acces it in OnClose .If so, where is the object stored?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
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
|
|
|
|