WM_PRINTCLIENT (and related) confusion related issues

The MSDN page for WM_PRINTCLIENTand related functions confuses me a bit in several ways:

  • What value should be returned from my window procedure? The documentation does not have a Return Value section. (It is also missing from the documentation version for the stand-alone documentation of the Visual Studio 2012 page.) Raymond Chen's zero source program returns zero ; is this the preferred option?

  • The Summary and Comments section for WM_PRINTCLIENTstates that I should draw only the client area, but LPARAM lists all possible flags WM_PRINT- so should I do, ignore and unconditionally draw only the client area, or do everything requested? (My intention with this question is not to guess the documentation, I just want to execute this message correctly.)

  • I want WM_PAINTDC as a convenience / kindness in the wParam function mentioned in the documentation WM_PAINTas an option. How to interpret LPARAM in this case? Or is there a reason why I should not offer this alternative route? (Consequence: if I ignore LPARAM, should I unconditionally draw the entire client area?)

Thank.

Refresh Rephrasing Part Three:

The documentation for WM_PAINTincludes a paragraph

For some common controls, the default message processing WM_PAINT checks the wParam parameter. If wParam is not NULL, the control assumes the value is HDC and draws using this device context.

I would like to provide this behavior in my control in addition to WM_PRINTCLIENTfor completeness. Is there a reason I should NOT do this? And if that doesn't hurt, how do I interpret lParam and I have to draw the entire rect client?

+4
source share
1 answer

What value should be returned from my window procedure?

0, , . DefWindowProc().

LPARAM WM_PRINT

, / fumble WM_PRINT. , , PRF_ERASEBKGND, , PRF_CLIENT, .

LPARAM ?

, WM_PAINT lparam. , , , WM_PAINT, WM_PRINTCLIENT. :

case WM_PAINT: {
    HDC hdc = BeginPaint(hWnd, &ps);
    Draw(hdc);
    EndPaint(hWnd, &ps);
    break;
}
case WM_PRINTCLIENT: {
    HDC hdc = (HDC)wParam;
    DWORD flags = (DWORD)lParam;
    if (flags & PRF_ERASEBKGND) SendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hdc, NULL);
    if (flags & PRF_CLIENT)     Draw(hdc);
    break;
}

void Draw(HDC hdc) - .

+4

All Articles