Using Container Objects

Start with the project you created in Setting Container Scaling Values:

  1. Add the following popup menu structure to the main menu you created in the Implementing the Container - Initializing, Creating and Freeing tutorial.

    &Draw Object 
    &Point   with ID = IDM_DRAWOBJECT_POINT 
    &Line   with ID = IDM_DRAWOBJECT_LINE 
    &Square   with ID = IDM_DRAWOBJECT_SQUARE 
    &Rect   with ID = IDM_DRAWOBJECT_RECT 
    &Circle   with ID = IDM_DRAWOBJECT_CIRCLE 
    &Ellipse   with ID = IDM_DRAWOBJECT_ELLIPSE 
    P&olyline   with ID = IDM_DRAWOBJECT_POLYLINE 
    &Bezier   with ID = IDM_DRAWOBJECT_BEZIER 
    &Arc   with ID = IDM_DRAWOBJECT_ARC 
    &Text   with ID = IDM_DRAWOBJECT_TEXT 

  2. Add the following code to the WndProc function just before the "return 0L ;" of the WM_CREATE message:

    CheckMenuRadioItem ( GetMenu ( hWnd ),  
       IDM_DRAWOBJECT_POINT,  
       IDM_DRAWOBJECT_TEXT, 
       IDM_DRAWOBJECT_POINT, 
       MF_BYCOMMAND ) ; 
    EnableMenuItem ( GetMenu ( hWnd ), 1, MF_BYPOSITION | MF_GRAYED ) ; 

  3. Add the following lines to the WndProc function, after the container metrics block, in the "case IDM_FILE_OPEN" of the WM_COMMAND message:

    EnableMenuItem ( GetMenu ( hWnd ), 1, MF_BYPOSITION | MF_ENABLED ) ; 
    DrawMenuBar ( hWnd ) ; 

  4. Add the following code to the WndProc function after the "return 0L;" statement of the "case IDM_FILE_EXIT:" statement:

    case IDM_DRAWOBJECT_POINT: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_POINT ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_POINT, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_LINE: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_LINE ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_LINE, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_SQUARE: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_SQUARE ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_SQUARE, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_RECT: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_RECT ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_RECT, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_CIRCLE: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_CIRCLE ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_CIRCLE, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_ELLIPSE: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_ELLIPSE ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_ELLIPSE, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_POLYLINE: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_POLYLINE ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_POLYLINE, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_BEZIER: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_BEZIER ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_BEZIER, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_ARC:    
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_ARC ) ;   
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_ARC, 
          MF_BYCOMMAND ) ; 
       return 0L ; 
    case IDM_DRAWOBJECT_TEXT: 
       L_ContainerSetObjectType ( pContainer, CONTAINER_OBJECT_TYPE_TEXT ) ; 
       CheckMenuRadioItem ( GetMenu ( hWnd ),  
          IDM_DRAWOBJECT_POINT,  
          IDM_DRAWOBJECT_TEXT, 
          IDM_DRAWOBJECT_TEXT, 
          MF_BYCOMMAND ) ; 
       return 0L ;   

  5. Compile and run the project by selecting Build->Rebuild Solution from the menu, and then Debug->Start Without Debugging.

  6. Select File->Open and open any image. Select any of the items in the Draw Object popup menu and begin drawing objects in the container.

Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Container and Automation C API Help