Thread: visual C++ 2005 Express: LPSTR error

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    visual C++ 2005 Express: LPSTR error

    I get this error with this code.

    Code:

    Code:
    char szClassName[] = "CodeBlocksWindowsApp";  //Point of interest
    
    LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hThisInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR lpszArgument,
                         int nFunsterStil)
    {
        HWND hwnd;
        MSG messages;
        WNDCLASSEX wincl;
        
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;  //Error line
    Error:

    Code:
    error C2440: '=' : cannot convert from 'char [21]' to 'LPCWSTR'
    I also get an error if I make the point of interest line a LPSTR variable. In visual C++ toolkit 2003 this error does not exist, but in the visual C++ 2005 Express (release, not beta) I get that error. Is there a way to fix this error.


    ALSO I get an error if I try to do this:

    Code:
        hwnd = CreateWindowEx(
        0,                   /* Extended possibilites for variation */
        szClassName,         /* Classname */
        "Code::Blocks Template Windows App",  //ERROR LINE
        WS_OVERLAPPEDWINDOW, /* default window */
        CW_USEDEFAULT,       /* Windows decides the position */
        CW_USEDEFAULT,       /* where the window ends up on the screen */
        544,                 /* The programs width */
        375,                 /* and height in pixels */
        HWND_DESKTOP,        /* The window is a child-window to desktop */
        NULL,                /* No menu */
        hThisInstance,       /* Program Instance handler */
        NULL                     /* No Window Creation data */
        );
    I get an error (were it says ERROR LINE) saying it can't convert char[number] can not be converted to LPWCSTR. Were in all other compilers I used it worked fine.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    It appears you are trying to compile with UNICODE. Remove #define UNICODE or turn it off in the settings.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Yup that was it, thanks! Visual C++ is so hard to get used to.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM