Working with the Paint Automation Toolbar

Start with the project you created in The Automation and the Container.

1.

Add the following declaration to the WndProc function:

static pTOOLBARHANDLE pToolbar ;

2.

Add the following code to the WndProc function before the "return 0L ;" statement in the WM_CREATE message:

 

{// INITIATE THE TOOLBAR
               if ( SUCCESS ==  L_TBInit  ( &pToolbar ) ) 
               {
                  L_BOOL fTBVisible ; 
                  POINT pt = { 0, 0 } ; 
                  RECT  rcClient ; 


                  GetClientRect ( hWnd, &rcClient ) ; 

                  pt.x = rcClient.left ; 
                  pt.y = rcClient.top ; 

                  ClientToScreen ( hWnd, &pt ) ; 

                  L_TBCreate  ( pToolbar, 
                               hWnd, 
                               TEXT("Paint Automation"),
                               TOOLBAR_PAINT ) ; 

                  L_TBSetPosition  ( pToolbar, 
                                    &pt, 
                                    TOOLBAR_POSITION_TOP | TOOLBAR_POSITION_LEFT ) ; 

                  L_TBIsVisible  ( pToolbar, &fTBVisible ) ; 

                  if ( ! fTBVisible ) 
                  {
                     L_TBSetVisible  ( pToolbar, TRUE ) ; 
                  }
               }
               else
               {
                  return FAILURE ; 
               }

               L_AutSetToolbar ( pAutomation, pToolbar ) ; 

}// INITIATE THE TOOLBAR

3.

Add the following code to the WndProc function after the " L_AutFree " function call in the WM_DESTROY message:

 

      {//DELETE THE TOOLBAR
         if (L_TBIsValid ( pToolbar ) ) 
         {
            L_TBFree  ( pToolbar ) ; 
         }
      }//DELETE THE TOOLBAR

4.

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