Start with the project you created in Low-Level DigitalPaint: Setting General DigitalPaint Information.
1. |
Add the following popup menu to the main menu you created in Low-Level DigitalPaint: Initializing and Freeing a Paint Handle. |
&Painting Test&Brush with ID = IDM_PAINTTEST_BRUSH
2. |
Add the following function before the OnOpen function definition: |
static L_VOID OnBrush ( HWND hWnd, pPAINTHANDLE pPaint ){HDC hDC ;PAINTBRUSH brush ;// Reset all of the brush fieldsmemset ( &brush, 0, sizeof ( brush ) ) ;// Get device context to draw onhDC = GetDC ( hWnd ) ;// Set the required paintbrush propertiesbrush.nSize = sizeof ( PAINTBRUSH ) ;brush.dwMask = PBF_DIAMETER |PBF_TOUCH |PBF_SPACING ;brush.nDiameter = 20 ;brush.Touch.crColor = RGB ( 255, 0, 0 ) ;brush.nSpacing = 25 ;// Set the new paintbruch propertiesL_PntSetProperty ( pPaint, PAINT_GROUP_BRUSH, &brush ) ;// Use the current paintbruch properties to draw a paintbrush stroke to DC (hDC)L_PntBrushMoveTo ( pPaint, hDC, 10, 10 ) ;L_PntBrushLineTo ( pPaint, hDC, 500, 500 ) ;// Release the device contextReleaseDC ( hWnd, hDC ) ;}
3. |
Add the following code after the statement "return 0L;" of the "case IDM_FILE_EXIT:" statement: |
case IDM_PAINTTEST_BRUSH:OnBrush ( hWnd, pPaint ) ;return 0L ;
4. |
Compile and run the project by selecting Build->Execute tutorial.exe from the menu. |
5. |
Go to the "File" menu and use the "Open" item to open an image. |
6. |
Go to the "Painting Test" and select the "Brush" item. This will draw a brush stroke on the given DC and on the opened bitmap. |