Implementing Toolbars - Initializing, Creating and Freeing

The following tutorials are designed to guide you, step by step through creating toolbars, setting toolbar and button characteristics and receiving event notifications. These tutorials were developed using a Visual C++ version 2005 compiler and they are designed for the WIN32 and X64 C API platform.

To open a project and add code that will create a new toolbar handle:

The following tutorials are designed to guide you, step by step through creating toolbars, setting toolbar and button characteristics and receiving event notifications. These tutorials were developed using a Visual C++ version 2005 compiler and they are designed for the WIN32 and X64 C API platform.

To open a project and add code that will create a new toolbar handle:

  1. Start a new project as follows: Run Microsoft Visual Studio 2005, select the File>New>Project, and do the following:

    1. Expand Visual C++ tree, if it is not already expanded.
    2. Select Win32 from the sub tree.
    3. Select Win32 Project from the right window.
    4. In the Project name text box, specify ToolbarTutorial.
    5. In the Location text box, specify the path of the project.
    6. Click the OK button.
  2. In the overview window just click Next.
  3. In the** Application Type** step dialog box, do the following:
    1. Select Windows application.
    2. Be sure to un-check the Empty project checkbox.
    3. Click the Finish button.
  4. In ToolbarTutorial.cpp replace the WndProc procedure with the following code:
    static LRESULT WINAPI WndProc ( HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam ) 
    { 
       static HWND hwndMain ; 
       static pTOOLBARHANDLE pToolbar ; 
       switch( uMessage ) 
       { 
          case WM_CREATE: 
          if ( SUCCESS == L_TBInit ( &pToolbar ) ) 
          { 
             POINT pt = { 0, 0 } ; 
             hwndMain = hWnd ; 
             // Create the toolbar 
             L_TBCreate ( pToolbar, hWnd, TEXT("LEAD Toolbar"), TOOLBAR_PAINT ) ; 
             // Initiate the point will be used to align the toolbar at the top-left of its owner client area */ 
             ClientToScreen ( hWnd, &pt ) ; 
              
             // Set the toolbar position 
             L_TBSetPosition ( pToolbar, &pt, TOOLBAR_POSITION_TOP | TOOLBAR_POSITION_LEFT ) ; 
             // Show the toolbar 
             L_TBSetVisible ( pToolbar, TRUE ) ; 
             return 0L ; 
          } 
          else 
          { 
             return -1L ; 
          } 
          case WM_DESTROY: 
          if ( SUCCESS == L_TBIsValid ( pToolbar ) ) 
          { 
             L_TBFree ( pToolbar ) ; 
          } 
          PostQuitMessage( 0 ) ; 
          return 0L ; 
    default: 
          break ; 
       } 
       return DefWindowProc ( hWnd, uMessage, wParam, lParam ) ; 
    } 
  5. In stdafx.h add the following headers: (keep in mind, you may have to change the path to where the header files reside):

    #include "..\\..\\..\\..\\..\\Include\\lttlb.h" 

  6. Create a new file called Imports.cpp and place it beside your project files:

    1. In the Project Workspace, click the Solution Explorer tab.
    2. Double-click the ToolbarTutorial folder to open it.
    3. Right-click the Source files folder and select Add New item.
    4. Right-click on the Source file.
    5. Expand Visual C++ tree, if it is not already expanded.
    6. Select Code from the sub tree.
    7. Select C++ File (.cpp) from the right window.
    8. In the name text box, specify Imports.
    9. Click the OK button.
    10. Double-click the import.cpp in the Solution Explorer and add the following lines: (keep in mind, you may have to change the path to where the header files reside).
      #include "StdAfx.h" 
      #if defined(FOR_WIN64) 
         #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLLVC10\\x64\\Ltkrn_x.lib") 
         #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLLVC10\\x64\\Lttlb_x.lib") 
      #elif defined(FOR_WIN32) 
         #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLLVC10\\Win32\\Ltkrn_u.lib") 
         #pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLLVC10\\Win32\\Lttlb_u.lib") 
      #endif // #if defined(FOR_WIN64) 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Toolbar C API Help