Take the following steps to create and run a program that uses the UNICODE version of LEADTOOLS in a non-UNICODE application.
Start a new project as follows:
Run Microsoft Visual Studio, select the File >New menu option, and do the following:
In the Step 1 dialog box, do the following: Click Next on the next wizard.
From the main menu, select Project->Properties. Under Configuration\General, set the "Character Set" to "Not Set". Click OK button.
Edit the stdafx.h and add to the end of the file the following code (Note: you will have to change the path of ltwrappr.h to match the LEADTOOLS installation directory on your system):
// Define the version of LEADTOOLS you are using. (keep in mind, to change the XX to current LEADTOOLS version)
#define LTVXX_CONFIG
// Force using UNICODE version of LEADTOOLS (we will need to convert all strings)
#define _LEAD_FORCE_UNICODE
// Include the LEADTOOLS C++ Class Library header file
#include "C:\LEADTOOLS21\Include\ClassLib\LtWrappr.h"
// Utility macro - Note: You might have to change the path to match your system.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\LEADTOOLS21\\Resources\\Images\\")pFileName
Edit stdafx.cpp and replace the contents of the file with the following code (Note: you will have to change the path to the .lib files to match your system):
// stdafx.cpp : source file that includes just the standard includes
// chartest2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#pragma comment(lib, "C:\\LEADTOOLS21\\Lib\\CDLL\\Win32\\Ltwvc_u.lib")
Add a command button to your form and name it as follows:
ID | Caption |
---|---|
IDC_FILEINFO | File Info |
Double Click on the new button and Add the following code:
L_INT nRet;
FILEINFO FileInfo; /* LEAD File Information structure. */
LFile File;
char szMessage[1024]; /* Buffer to hold information for display. */
char szInputFile[_MAX_PATH]=MAKE_IMAGE_PATH("IMAGE1.CMP");
LSettings::LoadLibraries (LT_FIL);
/* Convert non-UNICODE to UNICODE */
L_TCHAR wcsInputFile[_MAX_PATH]=L"\0";
mbstowcs(wcsInputFile, szInputFile, _MAX_PATH);
/* Get the file information */
FileInfo.uStructSize = sizeof(FileInfo);
File.SetFileName(wcsInputFile);
nRet = File.GetInfo(&FileInfo, sizeof(FILEINFO), 0, NULL);
if(nRet != SUCCESS)
return;
/* Convert UNICODE to non-UNICODE */
char szName[16];
wcstombs(szName, FileInfo.Name, 16);
char szCompression[20];
wcstombs(szCompression, FileInfo.Compression, 20);
/* Format the message string with data from the FILEINFO structure */
wsprintf(szMessage, "Filename: %s\n\n"
"Format: %d\n\n"
"Width: %d\n\n"
"Height: %d\n\n"
"BitsPerPixel: %d\n\n"
"Size On Disk: %ld\n\n"
"Size In Memory: %ld\n\n"
"Compression: %s",
szName,
FileInfo.Format,
FileInfo.Width,
FileInfo.Height,
FileInfo.BitsPerPixel,
FileInfo.SizeDisk,
FileInfo.SizeMem,
szCompression);
/* Display the message string */
MessageBox(NULL, szMessage, "File Information", MB_OK);
LSettings::UnloadLibraries (LT_FIL);
On the Main menu, select Build > Build chartest.exe to build the project.
On the Main menu, select Build > Execute chartest.exe to run the project.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document