Thread: CreateWindowEx LPCWSTR error

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    CreateWindowEx LPCWSTR error

    Code:
    hInputEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Enter Code Here", 
    				WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
    				0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    Code:
    ERROR:
    1>c:\documents and settings\martin\my documents\visual studio projects\colorcode\main.cpp(39) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'

    I get this error when i try to compile it with Microsoft Visual Studio 8 2005. :-\ and a whole bunch of errors like that when i pass a text in quotes to a function expecting a LPCWSTR

    What do i do?
    My Website
    010000110010101100101011
    Add Color To Your Code!

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    It is expecting a WCHAR string. To make a literal like "EDIT" a WCHAR literal, you preface it with a L, like so: L"EDIT". That should fix that error.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    VS 2005 seems to enable unicode compilation by default. You can disable it.

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Thank you.
    My Website
    010000110010101100101011
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM