Good evening. Here's my current code snippet:
#include <Windows.h>
#include <gdiplus.h>
#pragma comment(lib, "Gdiplus.lib")
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wPARAM, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) {
static const char ClassName[] = "YangaImageBrowser";
WNDCLASSEX wc;
MSG msg;
HWND hwnd;
Gdiplus::GdiplusStartupInput gdiStartup;
ULONG_PTR gdiToken;
Gdiplus::GdiplusStartup(&gdiToken, &gdiStartup, NULL);
wc.cbClsExtra = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
Line28 wc.lpszClassName = ClassName;
wc.lpszMenuName = NULL;
Gdiplus::GdiplusShutdown(gdiToken);
return msg.wParam;
}
And here is my description of the error: (in Polish)
Błąd (aktywny) E0513 nie można przypisać wartości typu "const char *" do jednostki typu "LPCWSTR" Nasza Przeglądarka Zdjęć C:\Users\ACER\Desktop\ImageBrowser\Nasza Przeglądarka Zdjęć\Main.cpp 28
Any idea?
Have a nice weekend.
It is not possible to assign a const char value to a unit of type LPCWSTR (C++, how can this be solved?)
Forum rules
The Off-Topic area is a general community discussion and chat area with special rules of engagement.
Enter, read and post at your own risk. You have been warned!
While our staff will try to guide the herd into sensible directions, this board is a mostly unrestricted zone where almost anything can be discussed, including matters not directly related to the project, technology or similar adjacent topics.
We do, however, require that you:
Please do exercise some common sense. How you act here will inevitably influence how you are treated elsewhere.
The Off-Topic area is a general community discussion and chat area with special rules of engagement.
Enter, read and post at your own risk. You have been warned!
While our staff will try to guide the herd into sensible directions, this board is a mostly unrestricted zone where almost anything can be discussed, including matters not directly related to the project, technology or similar adjacent topics.
We do, however, require that you:
- Do not post anything pornographic.
- Do not post hate speech in the traditional sense of the term.
- Do not post content that is illegal (including links to protected software, cracks, etc.)
- Do not post commercial advertisements, SEO links or SPAM posts.
Please do exercise some common sense. How you act here will inevitably influence how you are treated elsewhere.
-
- Lunatic
- Posts: 305
- Joined: 2018-08-14, 15:08
-
- Pale Moon guru
- Posts: 37640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: It is not possible to assign a const char value to a unit of type LPCWSTR (C++, how can this be solved?)
You want to remove the "const" there because WNDCLASSEX doesn't allow const assignments (since the classname is mutable and you're passing a pointer to a const in your case which is immutable).
Not really sure why you didn't look up the Microsoft documentation for WNDCLASSEX because it's all in there, including requirements to register nonstandard classes.
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 424
- Joined: 2019-03-16, 13:26
- Location: Qld, Aus.
Re: It is not possible to assign a const char value to a unit of type LPCWSTR (C++, how can this be solved?)
That's not right. It would seem UNICODE is defined somewhere, since it wants a wide string, not narrow. Remove the define or use static const wchar_t ClassName[] = L"YangaImageBrowser";.
-
- Lunatic
- Posts: 305
- Joined: 2018-08-14, 15:08