|
Hi,I have met the same confuse like you ? have you found the solution? please give me some help,thank you very much
|
|
|
|
|
hi sir..
i am beginner of MFC.so please tell me a possible way to retrieve the applications running in the remote system...please reply me as soon as possible....
|
|
|
|
|
Do u know how to retrieve the application running on a local computer?
As u r a novice, don't go beyond very advance level, I recommend.
Come online at:-
jubinc@skype
|
|
|
|
|
hi sir...
thanks for ur advice...
but i need to implement it in my project...so please give me a suggestion to find the same..please tell me how to retrieve in the local system too..interested in knowing that also.. please reply me sir...
thanking u..
|
|
|
|
|
Check the sample ProcessViewer from Platform SDK. It does exactly what you need.
And, by the way, "please reply me as soon as possible" won't get you many replys. This time you were lucky, but next time you may get flames. Or get ignored.
Nuclear launch detected
|
|
|
|
|
When the user in my application chooses exit from the menu, hits escape, or presses the X, I want my application to cleanup memory before closing. Usually I just put the cleanup code in the OnClose message handler. From a log file the cleanup generates, the OnClose gets called multiple times and my application crashes during the cleanup, attempting to delete the same memory multiple times.
I've tried hackish solutions that include setting a flag the first time the function is called and just returning the next time, but then the window never closes. There is nothing in my cleanup that would call OnClose() again.
Any ideas on how to approach fixing this? The debugger isn't being terribly useful.
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Aaron Stubbendieck wrote: the OnClose gets called multiple times
Have you missing the call of the base class OnClose() in your handler, haven't you?
Aaron Stubbendieck wrote: crashes during the cleanup, attempting to delete the same memory multiple times.
Use the following behaviour when performing cleanup:
if ( pSomeObject )
{
delete pSomeObject;
pSomeObject = NULL;
}
At least, this avoids program crashes due to multiple delete calls.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi
Why you don't put your cleanups in your destructor function?
|
|
|
|
|
Because some objects need to be cleaned up in OnClose. I have a perfect example of that - we have a timer thread that runs from program start to program end. We have to kill and delete the thread in OnClose because the thread needs to delete an array that uses pointers to statusbar panes which have already been "cleaned up" by the app by the time the destructor is called for CMainFrame.
So you see, everybody's needs are different. Asking why a programmer needs to do something does NOT help him. If you don't know the answer, or can't otherwise contribute something useful to the thread, at least resist the urge to ask stupid questions.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
"From a log file the cleanup generates"?????
What's happening, mention clearly? How OnClose is getting called more than once?
Anyway, the other way is, Override CWinApp::ExitInstance(). Here, u can place clean up codes.
Come online at:-
jubinc@skype
|
|
|
|
|
Are you putting the OnClose handler in each view or in CMainFrame?
If it's just in CMainFrame, it will only be called once. If it's in your view class, it will be called for every instance of your view object.
If you're cleaning up poointers that are global to your app or that are instantiate in your app or mainframe class, you should handle the OnClose only in CMainFrame. If you need to cleanup pointers that are local to your view object, you need to handle OnClose in the view as well.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Sorry, forgot to mention, I'm doing this in a dialog application. So it was in the CMyDlg::OnClose().
As somebody else mentioned, I have set the pointer to NULL after deleting it, but that doesn't seem to work either:
if(pPtr!=NULL)
{
delete pPtr;
pPtr=NULL;
}
Any ideas?
modified 12-Jul-20 21:01pm.
|
|
|
|
|
One other thing, which no one has mentioned: When you delete an object, reset the pointer to NULL :
void MyApp::OnClose()
{
delete MyObj;
MyObj = NULL;
} It's perfectly legal to issue a delete against a NULL pointer. This also removes the need to check the pointer value first as well.
Software Zen: delete this;
|
|
|
|
|
A long time ago, I got in the habit of checking to make sure the pointer needed to be deleted before deleting it, and then setting it to null (even in the destructor of the container class). The old ways are the best ways.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Yeah, I know. I was in the same habit from my 'C' days. The 'delete NULL ' thing only works in C++ AFAIK. In C, calling free(NULL); had unpredictable results, depending upon the run-time library implementor. I would imagine it's part of the standard, now.
Software Zen: delete this;
|
|
|
|
|
Hi,
How to change the dialog's caption at run time, I tried this by calling
(GetDlgItem(IDD_DIALOGiID))->SetWindowText("Test Dialog Caption") in OninitDialog method, but it is not working.
Warm Regards,
Mushq
|
|
|
|
|
Don't know y r u calling GetDlgItem(). This function is used for Child windows/controls in a Dialog.
U can directly call SetWindowText ("Test Dialog Caption") from any member of Dialog.
Come online at:-
jubinc@skype
|
|
|
|
|
use this->SetWindowText
If u can Dream... U can do it
|
|
|
|
|
Try SetWindowText("Test Dialog Caption");
|
|
|
|
|
this->SetWindowText("MYDIALOG");
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
Hi
I have been created a class called CMine in a MFC Dll project and in another MFC project I created an object if that class (I added header and lib file to the project).
I found that I must write __declspec(dllexport) before all functions in my CMine class, is there any way to avoid this, or just declaring one thing?
Thanks
|
|
|
|
|
Declaring _declspec(dllexport) in front of each and every member is not needed. Just write like this in the dll:-
class _declspec(dllexport) CTest
{
public:
void fnTest()
{
...
}
};
In .EXE:-
class _declspec(dllimport) CTest
{
public:
void fnTest()
{
...
}
};
It will surely work.
};
Come online at:-
jubinc@skype
|
|
|
|
|
|
Hadi Dayvary wrote: Yes, thank you
or you can write AFX_EXT_CLASS, in case of class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hi everybody!
Does anyone of you know any specific function to find the last modified time of a file.If anyone of you know this, i humbly request you to respond me.
Thanks in advance!
Shalumalu
|
|
|
|