Text doesn't update during WM_Paint message

Hello. Long time reader, first time poster. (Be gentle)

I am writing a screensaver and within my ScreenSaverProc I have this:
1
2
3
4
5
6
	case WM_PAINT:
		PAINTSTRUCT ps = {0};
		HDC hdcE = BeginPaint(hwnd, &ps );
		   EnumDisplayMonitors(hdcE, NULL, MyPaintEnumProc, 0);
		EndPaint(hwnd, &ps);
        return 1;


Inside my MyPaintEnumProc I have this below code. I want to display on the screen when the screensaver is active how much time has elasped. (Yes I know I am displaying ticks/ms, but I'll deal with that later) My issue that that the text doesn't update.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
BOOL CALLBACK MyPaintEnumProc(
      HMONITOR hMonitor,	// handle to display monitor
      HDC hdc,				// handle to monitor DC
      LPRECT lprcMonitor,	// monitor intersection rectangle
      LPARAM data			// data
      )
{
    RECT rc = *lprcMonitor;
    // you have the rect which has coordinates of the monitor
	int sizeX = (int) ceil( (rc.right-rc.left) *0.83);
	int sizeY = (int) ceil( (rc.bottom-rc.top) *0.83);

	Graphics graphics(hdc);

	if (gpBitmapMotivation)
		graphics.DrawImage(gpBitmapMotivation, rc.left, rc.top, sizeX, sizeY);

    if (gpBitmapAvailability)
		graphics.DrawImage(gpBitmapAvailability, rc.left, sizeY, rc.right - rc.left, rc.bottom - sizeY);

    if (gpBitmapShared)
		graphics.DrawImage(gpBitmapShared, sizeX, 0, rc.right-sizeX, sizeY);

	SolidBrush brush(Color(255, 0, 0, 255));
	FontFamily fontFamily(L"Times New Roman");
	Font font(&fontFamily, 64, FontStyleRegular, UnitPixel);
	PointF pointf(sizeX *0.8f, sizeY + (rc.bottom-sizeY)/2.0f );

	std::wstringstream ss;
	ss << L" Time: " << clock(); //++gTimeElapsed;
	std::wstring resultwStr = ss.str();

	SetBkMode(hdc, TRANSPARENT);
	graphics.DrawString(resultwStr.c_str(), -1, &font, pointf, &brush);

    return false; //temp hack to only draw on monitor1
}


Windows XP SP3
Visual Studio 2010 Ultimate

FYI: I need this SS memory footprint to be as small as possible.

Thanks!
The only way that clock is going to update is if the update region of the HDC where the clock is being printed is part of the region designated for repainting.
Otherwise it will be clipped.
So you may need to get a bit creative.
Last edited on
InvalidateRect (hwnd, NULL, TRUE);

That will repaint the window. I didn't read all of your post because I'm posting this fast (I'm busy) but this might be what you are looking for.
Topic archived. No new replies allowed.