Two (2) questions that I need advise on at the same time.
I have been trying to put text to a screen buffer and then to bitblt the screen buffer to the screen. It works, but I would like some advice on it.
How I place the text to the screen buffer is my question.
Am I doing this correct?
(1) Is DrawText what I should be using?
And
I tried to get the handle of the front buffer from its HDC,
to use it here instead of the handle of the main window, which I use here:
RECT rc;
GetClientRect(Handle_of_MainWindow, &rc);
but all attempts have failed.
(2) How do I get the handle of the front buffer if all that I have its HDC, which has not worked for me?
What I have tried:
I have the following where I draw text to a previous buffer then bitblt from a buffer to the screen. It works, I think.
I am not certain if I am doing this correct. Would you please look at it and advise me?
void Draw_From_FRONT_BUFFER_001_To_MainWindow()
{
Processing_A_Buffer_Update = 1;
HDC_of_MainWindow = GetDC( Handle_of_MainWindow ) ;
PAINTSTRUCT ps;
RECT rc;
GetClientRect(Handle_of_MainWindow, &rc);
SetBkMode( HDC_of_FRONT_BUFFER_001, TRANSPARENT );
SetTextColor(HDC_of_FRONT_BUFFER_001, RGB(255, 0, 0));
DrawText(HDC_of_FRONT_BUFFER_001, L"Red Text on Transparent Background!", -1, &rc, DT_CENTER|DT_VCENTER|DT_WORDBREAK);
BitBlt
(
HDC_of_MainWindow,
0,
0,
FRONT_BUFFER_001_WIDTH,
FRONT_BUFFER_001_HEIGHT,
HDC_of_FRONT_BUFFER_001,
0,
0,
SRCCOPY
);
ReleaseDC( Handle_of_MainWindow, HDC_of_MainWindow ) ;
Processing_A_Buffer_Update = 0;
}
I tried to use the handle of the FRONT_BUFFER_001 so that I could write text to that buffer in case I had used a different width or height than for the MainWindow but that did not work. Here is my attempt that did not work. No text shows up.
HWND Handle_of_FrontBuffer001 = WindowFromDC(HDC_of_FRONT_BUFFER_001);
RECT rc;
GetClientRect(Handle_of_FrontBuffer001, &rc);
That is why I am using the handle of the main window like this
RECT rc;
GetClientRect(Handle_of_MainWindow, &rc);
Please advise.
Thank you.