/*[]=====================================================================[]*/ /*[] LEADTOOLS for Windows - Version 11 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ /*---( EZRegC )------------------------------------------------------------ LEAD Functions Used. None. We have made the assumption that the user has the knowledge of programing in C and Windows. This example will: 1. load the image from a file, whose name is sent through the command line, to a bitmap, 2. display the image. This example demonstrates programing basics for the LEAD registered class. Usage: EZREGC --------------------------------------------------------------------------*/ #include /* required for all Windows applications */ #include #include "tchar.h" #include #include #include #include "..\\..\\..\\include\\l_bitmap.h" /* LEADTOOLS main header file */ #include "..\\..\\..\\include\\l_error.h" /* LEADTOOLS error definition header file */ #include "EZRegC.h" /* Application specific header file */ L_BOOL ExtractCommandData ( ); /*---[WinMain]--------------------------------------------------------------- Syntax: int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) Parameters: hInstance Current instance. hPrevInstance previous instance. lpCmdLine command line. nCmdShow show-window type. Prototype: Windows.h Notes: Windows main function, calls initialization function and processes message loop. --------------------------------------------------------------------------*/ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; /* Message structure, See Windows SDK for more information. */ HWND hwnd; /* Handle to the application window */ LEADBITMAPLOAD LoadStruct; /* Structure for the name of the DLL */ HICON hIconSmall; UNREFERENCED_PARAMETER (hPrevInstance); UNLOCKSUPPORT (); L_UseBitmapClass (); ExtractCommandData ( ) ; /* Create a normal overlapped window with scroll bars and automatic window sizing when a bitmap is loaded. */ hwnd = CreateWindow (L_BITMAPCLASS, TEXT("LEADBITMAP Registered Class Example"), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | L_BS_THUMBTRACK | L_BS_SIZEWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow (hwnd, nCmdShow); /* Load the bitmap and force screen update */ #ifdef WIN32 memset (&LoadStruct, 0, sizeof (LoadStruct)); hIconSmall = (HICON) LoadImage( hInstance, MAKEINTRESOURCE(ID_MAIN), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ); /* Set the applilcation small and big icons */ SendMessage( hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall ); #else _fmemset (&LoadStruct, 0, sizeof (LoadStruct)); #endif LoadStruct.uStructSize = sizeof (LoadStruct); lstrcpy (LoadStruct.Name, szFilename); /* Get the name of the image file */ SendMessage (hwnd, L_BM_LOAD, /* Send the message to load the image */ TRUE, (LONG) (LPSTR) & LoadStruct); /* Normal message loop. The LEADBITMAP window procedure will post a WM_QUIT message if there is not a parent. Such as in this case... */ while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } return (0); } /*---[ExtractCommandData]---------------------------------------------------- Syntax: L_BOOL ExtractCommandData( ); Parameters: None. ProtoType: ezregc.c Notes: - This procedure is responsible for extracting the file name passed through the command line. - You should call this function only in WinMain function. --------------------------------------------------------------------------*/ L_BOOL ExtractCommandData ( ) { LPTSTR pszFirst = NULL; LPTSTR pszCmdLine = NULL; LPTSTR psz = NULL; L_INT nFirstPos = 0 ; L_INT nStringLen = 0 ; pszCmdLine = GetCommandLine(); nStringLen = lstrlen ( pszCmdLine ) + 1 ; // To specify that it is command line or not. if(( pszCmdLine[1] == ':' ) || // Shortcut case ( pszCmdLine[2] == ':' )) //VS case { // 1- TRY TO EXPOSE THE EXE NAME FROM THE COMMAND LINE psz = _tcschr ( pszCmdLine, ':' ) ; if ( NULL == psz ) { return FALSE ; } } else { psz = pszCmdLine ; } pszFirst = _tcschr ( psz + 1, ':' ) ; if ( NULL == pszFirst ) { return FALSE ; } // Calc the char number to the image file name. nFirstPos = pszFirst - pszCmdLine - 1 ; if ( 0 > nFirstPos ) { return FALSE ; } memset (szFilename, 0, sizeof(szFilename)); lstrcpyn ( szFilename, pszFirst - 1, ( nStringLen - nFirstPos ) ) ; return TRUE; }