/*[]=====================================================================[]*/ /*[] LEADTOOLS for Windows - Version 11 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #define STRICT #include #include #include #include #include #include #include #include #include "TCHAR.H" #include "../../../include/l_bitmap.h" #include "../../../include/l_error.h" #include "fpxdemo.h" static HACCEL hAccel; 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_TCHAR szTemp[_MAX_PATH]; UNLOCKSUPPORT(); L_UseBitmapClass(); L_DlgInit(DLG_INIT_COLOR); ExtractCommandData ( ); hInst = hInstance; L_VersionInfo(&VersionInfo, sizeof(VERSIONINFO)); wsprintf(szTemp, TEXT("%s %d.%d"), (LPTSTR)VersionInfo.Product, VersionInfo.MajorNumber, VersionInfo.MinorNumber); L_SetComment(CMNT_SZSOFTWARE, (L_UCHAR L_FAR *)szTemp, lstrlen(szTemp) + 1); lstrcpy(szTemp, TEXT("Copyright \251 1991-2000 LEAD Technologies, Inc. All Rights Reserved.")); L_SetComment(CMNT_SZCOPYRIGHT, (L_UCHAR L_FAR *)szTemp, lstrlen(szTemp) + 1); L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION)); L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SAVEFILEOPTION)); if(VersionInfo.Level == TOOLKIT_LEVEL_DOCUMENT || VersionInfo.Level == TOOLKIT_LEVEL_MEDICAL) LoadFileOption.Flags &= ~ELO_ROTATED; if (!hPrevInstance) RegisterAllWindows (); CreateFrameWindow (); hAccel = LoadAccelerators (hInst, MAKEINTRESOURCE (ACCEL_MAINMENU)); ShowWindow (hWndFrame, nComShow); UpdateWindow (hWndFrame); while (GetMessage (&Msg, NULL, 0, 0)) { if (!TranslateMDISysAccel (hWndClient, &Msg) && !TranslateAccelerator (hWndFrame, hAccel, &Msg)) { TranslateMessage (&Msg); DispatchMessage (&Msg); } } return(Msg.wParam); } /*====(RegisterAllWindows)================================================= Description: Registers Frame window and Client window. Syntax : L_BOOL RegisterAllWindows(L_VOID) Prototype : fpxdemo.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 = CS_HREDRAW | CS_VREDRAW; 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_ARROW); wndClass.hbrBackground = GetStockObject (GRAY_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = szChildClass; fRegistered = RegisterClass (&wndClass); if(!fRegistered) return(FALSE); return(TRUE); } /*====(CreateFrameWindow)================================================== Description: Creates the Frame window. Syntax : L_VOID CreateFrameWindow(L_VOID) Prototype : fpxdemo.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); return; } /*---[ExtractCommandData]---------------------------------------------------- Syntax: L_BOOL ExtractCommandData( ); Parameters: None. ProtoType: Fpxdemo.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 ; L_TCHAR szTemp [ L_MAXPATH ] ; 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 ( szImageDir, 0, sizeof ( szImageDir ) ); memset ( szTemp, 0, sizeof ( szTemp ) ); lstrcpyn ( szTemp, pszFirst - 1, ( nStringLen - nFirstPos ) ) ; _tfullpath ( szImageDir, szTemp, ( nStringLen - nFirstPos ) ); return TRUE; }