tags:

views:

33

answers:

1

got this code from a website that helped me in creating buttons and stuff. the buttons work but for some reason im getting an compiler error with the creating a static.

cannot convert from 'const wchar_t [5]' to 'char'

cannot convert parameter 3 from 'char' to 'LPCWSTR'

is there a simply way to fix this? i tried casting lyrics into another variable and making it just a char.

  static char *lyrics = TEXT("Dood");



switch (message)
{

case WM_CREATE:
{
       CreateWindow(TEXT("button"), TEXT("Beep"),    
                 WS_VISIBLE | WS_CHILD ,
                 20, 300, 80, 25,        
                 hWnd, (HMENU) 1, NULL, NULL);    

    CreateWindow(TEXT("button"), TEXT("Quit"),    
                 WS_VISIBLE | WS_CHILD ,
                 120, 300, 80, 25,        
                 hWnd, (HMENU) 2, NULL, NULL);    

     CreateWindow(TEXT("STATIC"), lyrics, 
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 20, 300, 230,
                hWnd, (HMENU) 1, NULL, NULL);
+2  A: 

Try this instead:

static TCHAR *lyrics = TEXT("Dood"); 

With the compiler settings you appear to have, TCHAR will be converted to wchar_t.

Mark Ransom
awsome! thank you very much. this win32 stuff is very confusing to me.
TimothyTech
Note that you're not actually casting anything. You're just now using the correct types.
Noah Roberts
Also worth note, variable types T will resolve based on project settings of 'Unicode Vs Multi Byte Character Set(MBCS)' as will the win32 functions which are wrapped in macros - ie CreateWindow macro is either CreateWindowA or CreateWindowW and TCHAR is either char or wchar_t.
Greg Domjan