InvalidateRect() + DrawText()
Ok, so i've been trying to have a rectangle that fills with new text each time a button is pressed. I've got it all working except for it deleting the previous text before writing any new text, so I was wondering if anybody could help.
I think it was Niara who suggested this method to me before, so thank you for that. The helps appreciated.
Code:
HDC dev = GetDC(hwnd);
GetClientRect(hwnd, &rec1);
///rec2 is a rectangle derived from the size of the parent window
rec2.left = rec1.left+50;
rec2.right = rec1.right - 50;
rec2.top = rec1.top + 25;
rec2.bottom = rec1.bottom - 90;
SetBkMode(dev, TRANSPARENT);
InvalidateRect(hwnd, &rec2, 0);
FillRect(dev, &rec2, NULL);
poem_func();
HDC dev2 = GetDC(hwnd);
DrawText(dev2, poem.c_str(), poem.length(), &rec2, DT_CENTER);
EDIT:: oh i forgot to say, this compiles and runs ok, but it does not clear the rectangle/text. When i set the fourth parameter of InvalidateRect to 0, it clears it but then it will not display the text
Hmm just another thought, do I need to create and destroy a handle to a device context each time I press the button?