Thread: Visual Studio 2005 API Question

  1. #1
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339

    Visual Studio 2005 API Question

    Hey,

    My VS2005 by default makes a call to MessageBoxW() instead of the standard MessageBox(), this means i have to use TEXT() with the 2nd and 3rd parameters. Is this the correct way/standard of using message boxes now? Or is there an option somewhere to use the old function, im a bit confused over how this works I assume its to do with unicode can anyone explain?

    Thanks
    TNT
    You Can Stop Me, But You Cant Stop Us All

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    1

    Hi

    Hello,

    I have VC++ express and noticed the same thing. One thing you could do is use typecasting, i.e. (LPCWSTR)char* something;

    Or else, you could do this use, MessageBoxA() function rather than MessageBox() function which calls MessageBoxW().

    Third thing you could do is open winuser.h from the platform SDK, and change this line,

    Code:
    #define MessageBox  MessageBoxW
    to this,
    Code:
    #define MessageBox  MessageBoxA
    Regards,
    SleeK GeeK.
    Last edited by SleeK GeeK; 02-03-2006 at 11:05 PM.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    My VS2005 by default makes a call to MessageBoxW() instead of the standard MessageBox()
    There is no such function as MessageBox(). MessageBox() is just a macro to either MessageBoxA() or MessageBoxW(). The 'A' and 'W' stand for ASCII and Wide Character. MessageBox() is defined as MessageBoxA() unless UNICODE is defined in which case it is defined as MessageBoxW(). You have UNICODE defined in your project, look in your project settings.

    Oh, and please disregard everything Sleek Geek said. If you ever resort to editing window header files to solve your programming problems, then it is time to pick up a new hobby.

  4. #4
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    sadly, I've seen highly paid consultants result to doing things like that...
    They change standard library behaviour to make something work, then leave without telling anyone.

  5. #5
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Thanks guys that makes sense.
    TNT
    You Can Stop Me, But You Cant Stop Us All

  6. #6
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    For VS2005 go to the project properties and click on Configuration Propertys and change the character set from Use Unicode Character Set to Use multi-byte character set.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Visual studio 2005 pro question
    By C+/- in forum C++ Programming
    Replies: 1
    Last Post: 07-26-2008, 02:52 PM
  4. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 05:53 PM
  5. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM