Receiving Toolbar Events

Start with the project you created in Changing the Toolbar button State.

  1. Add the following callback function before the WndProc function definition:

    L_INT EXT_CALLBACK LeadToolbarProc 
    ( 
    pTOOLBARHANDLE  pToolbar, 
    L_UINT  nButtonID, 
    L_UINT32        dwData, 
    L_VOID    *pUserData 
    ) 
    { 
       switch ( nButtonID ) 
       { 
          case ID_TOOL_PAINT_BRUSH: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("BRUSH"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_SHAPE_LINE: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("LINE"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_SHAPE_RECT: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("RECT"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_SHAPE_ROUNDRECT: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("ROUND RECT"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_SHAPE_BEZIER: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("BEZIER"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_REGION_RECT: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("RECT"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_FILL_SURFACE: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("SURFACE"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
          case ID_TOOL_PAINT_TEXT: 
          { 
             MessageBox ( * ( HWND * ) pUserData, TEXT("TEXT"), TEXT("Toolbar Message"), MB_OK ) ; 
          } 
          break ; 
       } 
        
       return SUCCESS ; 
    } 

  2. Add the following function call to the WndProc function after the L_TBSetVisible function call in the WM_CREATE message:

    // Set the toolbar callback with the owner window as the user defind data   
    L_TBSetCallback ( pToolbar, LeadToolbarProc, ( L_VOID  * ) &hwndMain ) ; 

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

See Also

Receiving Toolbar Events (Callback Functions)

Programming with LEADTOOLS Toolbars

Getting Started

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

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