Low-Level DigitalPaint: Processing the Window Activation Messages

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.

  1. Add the following function before the OnOpen function definition:
    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 data 
       hdcCompatibility = 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 ) ; 
    } 
  2. Add the following line after the "break;" statement of the "case WM_PAINT:" statement:
    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 ; 
    } 
  3. Compile and run the project by selecting Build->Execute tutorial.exe from the menu.
Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.