Low-Level DigitalPaint: Using the DigitalPaint Common Dialogs

Start with the project you created in Low-Level DigitalPaint: Processing the Window Activation Messages.

  1. Add the following popup menu to the main menu you created in Low-Level DigitalPaint: Initializing and Freeing a Paint Handle
    • &Dialog Test
    • &Shape with ID = IDM_DIALOGTEST_SHAPE
  2. In stdafx.h add the following headers: (keep in mind, you may have to change the path to where the header files reside):
    #include "C:\LEADTOOLS22\Include\Ltpdg.h" 
  3. Add the following function before the OnOpen function definition:
    L_VOID OnShapeDlg ( HWND hWnd, pPAINTHANDLE pPaint ) 
    { 
       PAINTSHAPE shape ; 
       PAINTDLGSHAPEINFO ShapeDlgInfo ; 
       L_INT nRet ; 
       RECT rcRect; 
       HDC hdcTest; 
       hdcTest = GetDC (hWnd); 
       L_PntGetProperty ( pPaint, PAINT_GROUP_SHAPE, &shape ) ; 
       ShapeDlgInfo.dwFlags = PAINT_DLG_SHAPE_SHOWALL ; 
       ShapeDlgInfo.pszTitle = TEXT("Shape Properties"); 
       ShapeDlgInfo.nBackgroundStyle = shape.nBackgroundStyle ; 
       ShapeDlgInfo.crBackgroundColor = shape.crBackgroundColor ; 
       ShapeDlgInfo.ppszBackgroundTileBitmap = NULL ; 
       ShapeDlgInfo.uBackgroundTileBitmapCount = 0 ; 
       ShapeDlgInfo.nActiveBackgroundTileBitmapItem = -1 ; 
       ShapeDlgInfo.nBorderStyle = shape.nBorderStyle ; 
       ShapeDlgInfo.nBorderBrushStyle = shape.nBorderBrushStyle ; 
       ShapeDlgInfo.crBorderColor = shape.crBorderColor ; 
       ShapeDlgInfo.ppszBorderTileBitmap = NULL ; 
       ShapeDlgInfo.uBorderTileBitmapCount = 0 ; 
       ShapeDlgInfo.nActiveBorderTileBitmapItem  = -1 ; 
       ShapeDlgInfo.nBorderWidth = shape.nBorderWidth ; 
       ShapeDlgInfo.nBorderEndCap = shape.nBorderEndCap ; 
       ShapeDlgInfo.nGradientStyle = shape.nGradientStyle ; 
       ShapeDlgInfo.crGradientStartColor = shape.crGradientStartColor ; 
       ShapeDlgInfo.crGradientEndColor = shape.crGradientEndColor ; 
       ShapeDlgInfo.uGradientSteps = shape.uGradientSteps ; 
       ShapeDlgInfo.nRoundRectEllipseWidth = shape.nRoundRectEllipseWidth ; 
       ShapeDlgInfo.nRoundRectEllipseHeight = shape.nRoundRectEllipseHeight ; 
       ShapeDlgInfo.nOpacity = shape.nOpacity ; 
       ShapeDlgInfo.ppszPaperTexture = NULL ; 
       ShapeDlgInfo.uPaperTextureCount = 0 ; 
       ShapeDlgInfo.nActivePaperTextureItem = -1 ; 
       nRet = L_PntDlgShape ( hWnd, &ShapeDlgInfo ) ; 
       if ( SUCCESS == nRet ) 
       { 
          shape.nSize = sizeof ( PAINTSHAPE ) ; 
          shape.dwMask = PSF_ALL ; 
          shape.nBackgroundStyle = ShapeDlgInfo.nBackgroundStyle ; 
          shape.crBackgroundColor = ShapeDlgInfo.crBackgroundColor ; 
          shape.pBackgroundTileBitmap = NULL ; 
          shape.nBorderStyle = ShapeDlgInfo.nBorderStyle ; 
          shape.nBorderBrushStyle = ShapeDlgInfo.nBorderBrushStyle ; 
          shape.crBorderColor = ShapeDlgInfo.crBorderColor ; 
          shape.hBorderTileBitmap = NULL ; 
          shape.nBorderWidth = ShapeDlgInfo.nBorderWidth ; 
          shape.nBorderEndCap = ShapeDlgInfo.nBorderEndCap ; 
          shape.nGradientStyle = ShapeDlgInfo.nGradientStyle ; 
          shape.crGradientStartColor = ShapeDlgInfo.crGradientStartColor ; 
          shape.crGradientEndColor = ShapeDlgInfo.crGradientEndColor ; 
          shape.uGradientSteps = ShapeDlgInfo.uGradientSteps ; 
          shape.nRoundRectEllipseWidth = ShapeDlgInfo.nRoundRectEllipseWidth ; 
          shape.nRoundRectEllipseHeight = ShapeDlgInfo.nRoundRectEllipseHeight ; 
          shape.nOpacity = ShapeDlgInfo.nOpacity ; 
          shape.pTexture = NULL ; 
          L_PntSetProperty ( pPaint, PAINT_GROUP_SHAPE, &shape ) ; 
          // now draw something to see the results of the dialog settings 
          SetRect(&rcRect, 10, 10, 100, 100); 
          L_PntDrawShapeRectangle(pPaint, hdcTest, &rcRect); 
       } 
    } 
  4. Add the following line after the "return 0L ;" of the "case IDM_PAINTTEST_TEXT:" statement:
    case IDM_DIALOGTEST_SHAPE:   
                   OnShapeDlg ( hWnd, pPaint ) ;   
                   return 0L ; 
  5. Add the following lines in Imports.cpp

    #if defined(FOR_WIN64)</p> 
        #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLL\\x64\\ltpdg_x.lib") 
    #elif defined(FOR_WIN32)</p> 
        #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLL\\Win32\\ltpdg_u.lib") 
    #endif 

  6. Compile and run the project by selecting Build->Execute tutorial.exe from the menu.

  7. Go to the "Dialog Test" menu and select the item "Shape" to start playing with the shape dialog.
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.