|
Why you dont use of CFormView instead CView on the CForView you can make your control or insert of Toolbox to Form.
|
|
|
|
|
Hi there. I created an application that on ending it displays:
Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
Now, from my research it said that the successful exit code should be 0. Has anyone had their programs exit with Code 2? Just want to ask so that I would have some clue on where to start finding the cause of this, if this does affect the application in the first place.
thank you!
|
|
|
|
|
It's up to the application to return whatever value is appropriate for
the application.
It's long been conventional to use 0 as a success return value (since it worked
well with DOS batch files, I suppose).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes that was what I was thinking of since in most of the applications I have made, it rarely returns a 0. But I've noticed though that on an application it always returns the same exit code. This maybe a wild goosechase with the exit codes. MSDN doesn't seem to have a proper documentation for them or maybe I'm not poking in the right places. If you do have links about them please give it to me. Anyway, thank you for your help! Gave me confidence on my knowledge about exit codes.
|
|
|
|
|
Llasus wrote: But I've noticed though that on an application it always returns the same exit code.
Is it your application or 3rd party?
If it's yours, you should have control over what's returned
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Nope, I've created them. How do I control the value it returns?
|
|
|
|
|
It depends on what type of application and whether or not it uses the CRT
and/or MFC or other libraries.
Could be main(), WinMain(), CWinApp::ExitInstance(), the exit code in a
WM_QUIT message, etc. Somewhere, the app is exiting
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I see, I'll continue researching on MSDN docs about exit codes and see how it changes depending on my application. If you have links about exit codes though please give it to me. Again, thank you very much for your help!!!
|
|
|
|
|
These are probably the most common places a return value is returned from...
main: Program Startup[^] (Applies to all C/C++ apps)
WinMain Function[^] (Applies to Win32 apps)
CWinApp::ExitInstance[^] (Applies to MFC apps)
CWinApp::Run[^] (Applies to MFC apps - if you've overriden Run(), the returned value can override ExitInstance() return value)
PostQuitMessage Function[^] (Applies to all Windows applications)
Note that many of these propogate up the list depending on the type of application.
For example, in an MFC app, MFC has its own WinMain() and it's all handled by the
CRT main() so you only have to worry about the return value from ExitInstance() or in
rare circumstances, Run().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark. Thanks for your continuous help. I did some experiment and it actually worked by returning exit code 0. Though what I did may not be the right step. Since I don't really edit the ExitInstance() (as I have never used it before) I tried to check on my OnClose() function. By switching the original CDialog::OnClose() with PostQuitMessage(0), it actually returned the proper exit code of 0. But it may not be right since I forced it to return 0. Could you please check on this one?
void CApplicationDlg::OnClose() <br />
{<br />
SomeClass.CleanUp();<br />
<br />
CWnd* ThisDlg;<br />
ThisDlg= GetDlgItem(IDC_LEFTPICBOX);<br />
ThisDlg->ReleaseDC(&GlobalLeftPicDC);<br />
GlobalLeftPicDC.DeleteDC();<br />
ThisDlg= GetDlgItem(IDC_RIGHTPICBOX);<br />
ThisDlg->ReleaseDC(&GlobalRightPicDC);<br />
GlobalRightPicDC.DeleteDC();<br />
<br />
CDialog::OnClose();
}
I may be somehow going away from my problem here but I just want to prove that exit codes doesn't really have an effect on my program. Again, thank you for your help!
|
|
|
|
|
Llasus wrote: Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
If it's a dialog-based application, are you dismissing the dialog via OK or Cancel?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, I actually removed those two buttons that come as default when creating a new dialog.
|
|
|
|
|
How does the dismissal of the dialog by OK or Cancel relate to the Exit Code 2?
|
|
|
|
|
It relates to it 100%. Try it and see.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes you are right! Exit code of 0 is done when the OK or Cancel button is pushed. And Exit code 2 is when close button or alt-F4 is done. Thank you very much for your help!
|
|
|
|
|
I am compiling these samples from the command line. 1st and foremost, the vcvars32.bat doesn't show up where the documentation says it should, or at all for that matter. The include, bin, and lib env vars have been set, yet and still, when I run nmake, cl.exe cant find any of my include paths. Oh yea, Im using the cl.exe from the drivers developers kit since the platform sdk doesnt have a 32bit version included. Please help me.
|
|
|
|
|
shatterstar6457 wrote: the vcvars32.bat doesn't show up where the documentation says it should
Where are you expecting to find vcvars32.bat?
It's created when installing a visual C++ compiler and it sounds like you don't have
one installed.
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
..\vc\bin, isnt it installed with the installer?
|
|
|
|
|
What installer are you referring to??
shatterstar6457 wrote: Oh yea, Im using the cl.exe from the drivers developers kit since the platform sdk doesnt have a 32bit version included.
That seemed to imply you haven't installed a development environment...
Are you tring to use a compiler that came with the PSDK? I had no idea there was one included.
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
shatterstar6457 wrote: from the drivers developers kit
After reading your post 6 times I finally read that correctly
Anyway, I have no idea if the DDK installer sets up a useable vcvars32.bat
but I know the visual studio installer does.
Maybe download and install 2005 Express. You'll get a free up-to-date compiler
and the vcvars32.bat should be valid and where you expect it to be.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
Can i create two Cbrush objects in same dialog class?, i tried to do like this
<br />
void CMyChessView::OnDraw(CDC* pDC)<br />
{<br />
CBrush *white = new CBrush;<br />
CBrush *black = new CBrush;<br />
<br />
CMyChessDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
white->CreateSolidBrush(RGB(255,255,255));<br />
black->CreateSolidBrush(RGB(0,0,0));<br />
<br />
for (int i=1;i<=8;i++)<br />
for (int j=1;j<=8;j++)<br />
{<br />
pDC->Rectangle((i-1)*56,(j-1)*56,i*56,j*56);<br />
}<br />
<br />
<br />
<br />
<br />
}<br />
but onresize the window some exception errors accured? does anyone know why the errors?
-- modified at 17:02 Monday 5th November, 2007
|
|
|
|
|
Gofur Halmurat wrote: Can i create two Cbrush objects in same dialog class?
Yes. The problem is somewhere else.
What line of code causes the exception? What is the specific exception?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello, i just changed the post, could u look at the code again please?
now, the error is "Debug Assertion Failed"?
|
|
|
|
|
Gofur Halmurat wrote: now, the error is "Debug Assertion Failed"?
There's lots of places that assertions can occur -
you really need to be more specific.
The only thing I can see is you're not freeing the brushes when you're done with them.
Are you depleting all your GDI resources??
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
Yes, i am deleting all GDi resources in desctroctor
I found where the problem is, the creation of those CBrushs cannt be in OnDraw Method, because OnResize method, it will create again the bruths
thanks
|
|
|
|