Code:
// Snippet applicable declarations...
LPCTSTR ClsName = "Basic_Window";
TCHAR szBuffer[250];
LPSTR outBuffer;
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
// Not applicable code removed....
case WM_CREATE:
{
UINT_PTR ret;
BITMAP bm;
// Etcetera....
LoadString(GetModuleHandle(NULL), IDS_STRING, szBuffer, 0); /*sizeof(TCHAR));*/
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, szBuffer, IDS_STRING, NULL, outBuffer, NULL, NULL);
}
break;
case WM_PAINT:
{
// removed for post...
}
break;
}
return 0;
}
void DrawBebop(HDC hdc, RECT* prc)
{
// This version of the drawing integrates double-buffering
HDC hDcBuffer = CreateCompatibleDC(hdc);
HBITMAP hbmBuffer = CreateCompatibleBitmap(hdc, prc->right, prc->bottom);
HBITMAP hbmOldBuffer;
// Not applicable code removed...
//TextOut(hDcBuffer, 100, 100, "TESTING", 7); // This works....
BitBlt(hDcBuffer, (BmpPos.bx - Ofst), (BmpPos.by - Ofst), BmpPos.width, BmpPos.height, hDcMem, 0, 0, SRCAND);
SelectObject(hDcMem, g_hbmBebop);
BitBlt(hDcBuffer, (BmpPos.bx - Ofst), (BmpPos.by - Ofst), BmpPos.width, BmpPos.height, hDcMem, 0, 0, SRCPAINT);
DrawText(hDcBuffer, outBuffer, -1, prc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);// This shows nothing...
//DrawText(hDcBuffer, "Hi There!", -1, prc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); // This works...
//DrawText(hDcBuffer, ClsName, -1, prc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); // And this works...
// ^^^^
// Hmmm. Normal, interpreted as Null Terminated ("**"), strings prints no problem, as does
// a standard char array buffer. The question is, then, how do you get a STRING
// resource to format as char? FormatMessage does not seem to do the trick.
// Or I am not using it correctly. There is only
// some stuff in Japanese about it on MSDN, so
// I have no reference....
//
// Just a note, the STRING resource, that comes from a *.txt file, is NOT stored with the
// *.exe as letters, but apparently as its character (scan?) codes. Ie; non hexadecimal numbers.
// I am wondering if the conversion to characters is required in a separate function, even though
// a scant, indirect reference seems to promise that this
// is not needed when using FormatMessage() function.
//
// So, my doubt: Is the way I am embedding a STRING resource the right way (ie; as a txt file)?
// Is there another way? Is this possibly the problem?
BitBlt(hdc, 0, 0, prc->right, prc->bottom, hDcBuffer, 0, 0, SRCCOPY);
SelectObject(hDcMem, hbmOld);
DeleteDC(hDcMem);
SelectObject(hDcBuffer, hbmOldBuffer);
DeleteDC(hDcBuffer);
DeleteObject(hbmBuffer);
}
What I have already covered (please note the comments in the code, too).