This tutorial is giving an example on how to process the window activation messages:
Start with the project you created in Low-Level DigitalPaint: Drawing Text.
static L_VOID OnActivate(HWND hWnd,pPAINTHANDLE pPaint,pBITMAPHANDLE pBitmap,HPALETTE hPalette,L_INT nZoom,L_INT nHScroll,L_INT nVScroll){PAINTXFORM XForm ;HDC hdcCompatibility ;RECT rcDCRect ;//set the painting toolkit datahdcCompatibility = GetDC ( hWnd ) ;L_PntSetMetrics ( pPaint, hdcCompatibility, pBitmap, hPalette ) ;ReleaseDC ( hWnd, hdcCompatibility ) ;XForm.nZoom = nZoom ;XForm.nXOffset = nHScroll ;XForm.nYOffset = nVScroll ;L_PntSetTransformation ( pPaint, &XForm ) ;GetClientRect ( hWnd, &rcDCRect ) ;L_PntSetDCExtents ( pPaint, &rcDCRect ) ;}
case WM_ACTIVATE:if ( WA_INACTIVE != LOWORD ( wParam ) ){HDC hDC = GetDC(hWnd);HPALETTE hPalette = L_CreatePaintPalette(hDC, &hBitmap);OnActivate ( hWnd, pPaint, &hBitmap, hPalette, nZoomFactor, nHScroll, nVScroll ) ;if(hPalette)DeleteObject(hPalette);ReleaseDC(hWnd, hDC);return 0 ;}