Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. windows.h / MessageBox

windows.h / MessageBox

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++helptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doneirik
    wrote on last edited by
    #1

    hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik

    V M 2 Replies Last reply
    0
    • D doneirik

      hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik

      V Offline
      V Offline
      vikramlinux
      wrote on last edited by
      #2

      Please write following details: 1) Which type of application u haev created ? (MFC/SDK) 2) what error studio flashes?

      1 Reply Last reply
      0
      • D doneirik

        hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        The Windows headers declare two versions of most APIs that take string parameters or buffers which contain strings. These typically end in either W, for a version taking Unicode (word-oriented) strings, or A, for a version taking ANSI (byte-oriented) strings. Windows 9x, in the main, only supplies the ANSI versions; Windows NT and successors (2000, XP, 2003) supply both versions. So there are actually two functions in the API: MessageBoxA and MessageBoxW. For convenience the headers define a macro which, depending on whether UNICODE is defined, maps to the W or A version of the API. This allows Unicode and ANSI versions of the software to be compiled from the same sources just by defining or not defining UNICODE. So MessageBox is a macro defined to either MessageBoxW or MessageBoxA - the former if UNICODE is defined and the latter if not. The C++ macro processor is dumb. It doesn't understand that you're trying to call the Windows Forms MessageBox class's Show method. It just replaces the text with either MessageBoxW or MessageBoxA. This will give a compile error because there's no class with that name. I think the best thing for you to do is to isolate the .NET code in one set of source files, and the unmanaged code in another set. In the unmanaged set, include windows.h; in the managed files, don't. If it's in your precompiled header file, remove it. Stability. What an interesting concept. -- Chris Maunder

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups