How to convert LPWSTR to LPCSTR??

Hello

I am trying to display a bitmap picture on a static text.

here is a code.

m_static.ModifyStyle(0xF, SS_BITMAP|SS_CENTERIMAGE);

HBITMAP hBmp = ::LoadBitmapA(AfxGetInstanceHandle(), MAKEINTRESOURCE((LPCSTR)IDB_BITMAP1)); <-- error line
m_static.SetBitmap(hBmp);

BITMAP size;
::GetObjectA(hBmp, sizeof(BITMAP), &size);

m_static.MoveWindow(0, 0, size.bmWidth, size.bmHeight);
m_static.ShowWindow(SW_SHOW);

then, the error message says "You can't convert LPWSTR to LPCSTR".

I don't know what to do. I need help T_T
Change LoadBitmapA to LoadBitmap. Looks like you are compiling in UNICODE.
Correct. MAKEINTRESOURCE gives you a TCHAR, so use the TCHAR version of the function (LoadBitmap).

Also, no need to cast there, MAKEINTRESOURCE does the casting:

 
::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
It works after using LoadBitmap instead of LoadBitMapA.
What if i wanted to use LoadBitmapA?? What should I do to make it work?
Then you'd use MAKEINTRESOURCEA() instead of MAKEINTRESOURCE
Topic archived. No new replies allowed.