January 27th, 2013, 05:59 PM
Re: Trying to create a vector using a structure definition as the basis in VC++
in the Visual Programming forum sponsored by Microsoft.
It appears that the errors that may be induced by writing files are already handled by message boxes produced by the Windows API.
If I'm not in the midst of a function, and don't need to break out, which is the case now that I've modified the code to make it something I can now render more useful in a computational sense, wouldn't Windows handle any errors with its own, innately programmed requirement for a message box if an error occurs while writing a file, and leave me to simply ignore the error returned where the function to write the file is originally called? (I hate to pass the problem off to Windows, but perhaps that isn't a bad thing, given that it is the OS and the OS' job is writing files.) I'll simply leave a "comment" noting this decision at the point at which the error value would be returned just after the file writing function is called.
Thank you for your kind response.
The easiest way in Microsoft Windows to output an error message in a window on the screen is to use MessageBox. The MessageBox function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.
int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
For a simple error message, uType can be MB_OK and hWnd can be NULL. Thus an example would be
MessageBox(NULL, "Body of message", "Title", MB_OK);
You'll need to include windows.h for this (if it's not already included in stdafx.h). You said that you are using managed c++. I have no experience of managed c++ and implications of using MessageBox in that context.
Have more fun!
Last edited by Protocol; January 27th, 2013 at 06:02 PM.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.