Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
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 DLL 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: |
|
|
a. |
Expand Visual C++ tree, if it is not already expanded. |
|
b. |
Select Win32 from the sub tree. |
|
c. |
Select Win32 Project from the right window. |
|
d. |
In the Project name text box, specify ToolbarTutorial. |
|
e. |
In the Location text box, specify the path of the project. |
|
f. |
Click the OK button. |
2. |
In the overview window Just click Next. |
|
3. |
In the Application Type step dialog box, do the following: |
|
|
a. |
Select Windows application. |
|
b. |
Be sure to un-check the Empty project checkbox. |
|
c. |
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 in place it beside your project files. |
a. |
In the Project Workspace, click the Solution Explorer tab. |
b. |
Double-click the ToolbarTutorial folder to open it. |
c. |
Right-click the Source files folder and select Add à New item. |
d. |
Right-click on the Source file |
e. |
Expand Visual C++ tree, if it is not already expanded. |
f. |
Select Code from the sub tree. |
g. |
Select C++ File (.cpp) from the right window. |
h. |
In the name text box, specify Imports. |
i. |
Click the OK button. |
j. |
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\\CDLL\\x64\\Ltkrn_x.lib")
#pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLL\\x64\\Lttlb_x.lib")
#elif defined(FOR_WIN32)
#pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLL\\Win32\\Ltkrn_u.lib")
#pragma comment(lib, "..\\..\\..\\..\\..\\..\\Lib\\CDLL\\Win32\\Lttlb_u.lib")
#endif // #if defined(FOR_WIN64)
See Also:
Initializing and Freeing a Toolbar
Programming with LEADTOOLS Toolbars