CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 38

Threaded View

  1. #31
    Join Date
    Feb 2005

    Re: Trying to create a vector using a structure definition as the basis in VC++

    I found:


    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.

    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!
    Thank you for your kind response.
    Last edited by Protocol; January 27th, 2013 at 06:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)