/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 13 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2001 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ /*------------------------------------------------------------------------- We have made the assumption that the user has the knowledge of programming in C and Windows. This demo program demonstrates the use of most LEAD TOOLS functions, builds a complete application that uses the Windows MDI capabilities, and shows methods of interaction with the Windows environment. --------------------------------------------------------------------------*/ #define STRICT #include #include #include #include #include #include #include #include #include "../../../include/l_bitmap.h" #include "../../../include/l_error.h" #include "demo.h" static HACCEL hAccel; static HACCEL hAccelPages; L_BOOL ExtractCommandData ( ); /*====(WinMain)============================================================ Description: Main windows function required for all windows applications. Syntax : int L_PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpstrCommandLine, int nComShow) Prototype : windows.h Parameters : hInstance Handle to current instance of application. hPrevInstance Handle to previous instance of application. lpstrCommandLine Pointer to the Command Line. nComShow Integer used in ShowWindow. Return Value: The return value the user specify in wParam when send WM_QUIT message, or the paramter in PostQuitMessage. ==========================================================================*/ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpstrCommandLine, int nComShow) { MSG Msg; static L_CHAR szTemp[L_MAXPATH]; UNLOCKSUPPORT(); ExtractCommandData(); L_UseBitmapClass(); hInst = hInstance; nOpenIndex = 0; nSaveIndex = 0; L_VersionInfo(&VersionInfo,sizeof(VERSIONINFO)); // The comments should be set as ANSI, even for a Unicode EXE! sprintf(szTemp, "%s %d.%d", (LPSTR)VersionInfo.Product, VersionInfo.MajorNumber, VersionInfo.MinorNumber); L_SetComment(CMNT_SZSOFTWARE, (L_UCHAR L_FAR *)szTemp, strlen(szTemp) + 1); strcpy(szTemp, "Copyright (c) 1991-2000 LEAD Technologies, Inc. All Rights Reserved."); L_SetComment(CMNT_SZCOPYRIGHT, (L_UCHAR L_FAR *)szTemp, strlen(szTemp) + 1); if(VersionInfo.Level == TOOLKIT_LEVEL_DOCUMENT || VersionInfo.Level == TOOLKIT_LEVEL_MEDICAL) { // use scale to gray by default nBitonalFlags = DISPLAYMODE_SCALETOGRAY; /* The rotated View Perspectives are available only in the Express toolkit */ L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION)); if(fLoadRotated) LoadFileOption.Flags |= ELO_ROTATED; else LoadFileOption.Flags &= ~ELO_ROTATED; } else fLoadRotated = FALSE; #if defined(WIN32) && !defined(_ALPHA_) && !defined (UNICODE) /* is ISIS installed? */ fISIS = L_IsISISAvailable(); #endif if (!hPrevInstance) RegisterAllWindows (); CreateFrameWindow (); hAccel = LoadAccelerators (hInst, MAKEINTRESOURCE (ACCEL_MAINMENU)); hAccelPages = LoadAccelerators (hInst, MAKEINTRESOURCE (IDR_ACCELERATOR1)); ShowWindow (hWndFrame, nComShow); UpdateWindow (hWndFrame); if(hListBkGndBrush==0) hListBkGndBrush=CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); #ifdef WIN32 //capture API functions L_GetDefaultObjectOption(&ObjectOptions,sizeof(LEADCAPTUREOBJECTOPTION)); L_GetDefaultAreaOption(&CaptureAreaOption,sizeof(LEADCAPTUREAREAOPTION)); #endif while (GetMessage (&Msg, NULL, 0, 0)) { if (!TranslateMDISysAccel (hWndClient, &Msg) && !TranslateAccelerator (hWndFrame, hAccel, &Msg)&& !TranslateAccelerator (hWndFrame, hAccelPages, &Msg) ) { TranslateMessage (&Msg); DispatchMessage (&Msg); } } if(hListBkGndBrush) DeleteObject(hListBkGndBrush); return(Msg.wParam); } /*====(RegisterAllWindows)================================================= Description: Registers Frame window and Client window. Syntax : L_BOOL RegisterAllWindows(L_VOID) Prototype : demo.h Parameters : None Return Value: > 0 New class successfully registered. FALSE Fail to Register the Class. ==========================================================================*/ L_BOOL RegisterAllWindows (L_VOID) { WNDCLASS wndClass; L_BOOL fRegistered; wndClass.style = 0; wndClass.lpfnWndProc = (WNDPROC) FrameWindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInst; wndClass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_MAIN)); wndClass.hCursor = LoadCursor (NULL, IDC_ARROW); wndClass.hbrBackground = GetStockObject (GRAY_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szFrameClass; fRegistered = RegisterClass (&wndClass); if(!fRegistered) return(FALSE); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = (WNDPROC) ChildWindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = GWL_CHILDEXTRA; wndClass.hInstance = hInst; wndClass.hIcon = NULL; wndClass.hCursor = LoadCursor (NULL,IDC_SIZEWE); wndClass.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szChildClass; fRegistered = RegisterClass(&wndClass); if(!fRegistered) return(FALSE); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = (WNDPROC) ProgressBarProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInst; wndClass.hIcon = NULL; wndClass.hCursor = LoadCursor (NULL, IDC_ARROW); wndClass.hbrBackground = GetStockObject (LTGRAY_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szProgressBarClass; fRegistered = RegisterClass (&wndClass); wndClass.style =0; wndClass.lpfnWndProc = (WNDPROC) BitmapWindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra =0; wndClass.hInstance = hInst; wndClass.hIcon = NULL; wndClass.hCursor = LoadCursor (NULL, IDC_ARROW); wndClass.hbrBackground = GetStockObject (GRAY_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szBitmapWndClass; fRegistered = RegisterClass (&wndClass); if(!fRegistered) return(FALSE); return(TRUE); } /*====(CreateFrameWindow)================================================== Description: Creates the Frame window. Syntax : L_VOID CreateFrameWindow(L_VOID) Prototype : demo.h Parameters : None. Return Value: None. ==========================================================================*/ L_VOID CreateFrameWindow (L_VOID) { hWndFrame = CreateWindow (szFrameClass, szFrameTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, LoadMenu (hInst, MAKEINTRESOURCE (MENU_MAIN)), hInst, NULL); } /*---[ExtractCommandData]---------------------------------------------------- Syntax: L_BOOL ExtractCommandData( ); Parameters: None. ProtoType: Demo.c Notes: - This procedure is responsible for extracting the dir 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 (szCommandLine, 0, sizeof(szCommandLine)); lstrcpyn ( szCommandLine, pszFirst - 1, ( nStringLen - nFirstPos ) ) ; if ( szCommandLine ) { if ( szCommandLine [ 0 ] != '-' && szCommandLine [ 0 ] != '/' ) { if ( szCommandLine [ 0 ] != 0 ) { bCommandLine = !IsDir(szCommandLine); if(!bCommandLine) { if(szCommandLine[lstrlen(szCommandLine)-1]=='\\') szCommandLine[lstrlen(szCommandLine)-1]=0; } } } } _tfullpath(szImageDir, szCommandLine, sizeof(szImageDir)); return TRUE; } /* EOF */