How do I use string as a param for CreateWindowEx function
-
Hi all, I am trying to get the string supplied as a param in this function to be displayed as window title when executed but I am gettin compiler error. here is the code which is causing compiler error
hwnd = CreateWindowEx( NULL, "AeroClass", "Aerobatics by Scody", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100, 500, 500, NULL, NULL, hInstance, NULL);
and the compiler error isc:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(132) : error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(149) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Can anyone please help me in gettin this string displayed on the window title when executed. Thanks Scody -
Hi all, I am trying to get the string supplied as a param in this function to be displayed as window title when executed but I am gettin compiler error. here is the code which is causing compiler error
hwnd = CreateWindowEx( NULL, "AeroClass", "Aerobatics by Scody", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100, 500, 500, NULL, NULL, hInstance, NULL);
and the compiler error isc:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(132) : error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(149) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Can anyone please help me in gettin this string displayed on the window title when executed. Thanks ScodyYour project settings are set to use Unicode, but you're passing single-byte strings. Either switch to the multi-byte character set or use the _T macro on your literals.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Hi all, I am trying to get the string supplied as a param in this function to be displayed as window title when executed but I am gettin compiler error. here is the code which is causing compiler error
hwnd = CreateWindowEx( NULL, "AeroClass", "Aerobatics by Scody", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100, 500, 500, NULL, NULL, hInstance, NULL);
and the compiler error isc:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(132) : error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(149) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Can anyone please help me in gettin this string displayed on the window title when executed. Thanks ScodyUse
hwnd = CreateWindowEx( NULL, _T("AeroClass"), _T("Aerobatics by Scody"),...
WhiteSky
-
Hi all, I am trying to get the string supplied as a param in this function to be displayed as window title when executed but I am gettin compiler error. here is the code which is causing compiler error
hwnd = CreateWindowEx( NULL, "AeroClass", "Aerobatics by Scody", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100, 500, 500, NULL, NULL, hInstance, NULL);
and the compiler error isc:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(132) : error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\visual studio 2005\projects\aerobatics\aerobatics\aerobatics.cpp(149) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Can anyone please help me in gettin this string displayed on the window title when executed. Thanks Scody