home *** CD-ROM | disk | FTP | other *** search
- // BDE - (C) Copyright 1994 by Borland International
-
- #include "inventry.h"
-
- //======================================================================
- // Function:
- // WinMsg(Msg, TypeMsg, TypeBtn);
- //
- // Input: pMsg - The message to display.
- // TypeMsg - The type of messagebox to use (i.e. Stop,
- // Information,
- // TypeBtn - The buttons to use (i.e. Yes, No, OK, ...)
- //
- // Return: Response from the user.
- //
- // Description:
- // Display a message box & return a value representing
- // the button the user pressed. Standard windows input is
- // required for the type of message, and button(s), to use.
- //======================================================================
- UINT16
- WinMsg (pCHAR pMsg, UINT16 TypeMsg, UINT16 TypeBtn)
- {
- return(MessageBox(hMainWnd, (LPSTR) pMsg, "Inventory Message",
- (WORD) TypeBtn | TypeMsg | MB_APPLMODAL));
- }
-
- //======================================================================
- // Function:
- // ChangeEntryMode();
- //
- // Input: None.
- //
- // Return: None.
- //
- // Description:
- // Swap the data entry mode. This will either switch from
- // "modify a record" to "add a record," or visa-versa.
- //======================================================================
- void
- ChangeEntryMode (void)
- {
- // These variables are used to determine which controls are visible
- UINT16 Show1; // Controls which are visible at startup
- UINT16 Show2; // Controls used far adding a record
- UINT16 Show3; // Menu items to enable
-
- char szString[150]; // Used to read data from the string resource
-
- if (NewRecMode)
- {
- // Change the mode flag
- NewRecMode = FALSE;
-
- // Show the startup resources
- Show1 = SW_SHOW;
-
- // Hide the OK and Cancel buttons
- Show2 = SW_HIDE;
-
- // Enable the menu options
- Show3 = MF_ENABLED;
- }
- else
- {
- // Change the mode flag
- NewRecMode = TRUE;
-
- // Hide the startup resources
- Show1 = SW_HIDE;
-
- // Show the OK and Cancel buttons
- Show2 = SW_SHOW;
-
- // Disable the menu options
- Show3 = MF_GRAYED;
- }
-
- // These resources are shown when the app starts
- ShowWindow(GetDlgItem(hMainWnd, ID_ADD_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_DEL_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_FIRST_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_PREV_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_NEXT_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_LAST_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_MOD_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_UNDO_REC), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_ORDER), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_SEARCH), Show1);
- ShowWindow(GetDlgItem(hMainWnd, ID_RANGE), Show1);
- ShowWindow(GetDlgItem(hMainWnd, IDS_DATABASE_HDR), Show1);
-
- // These menu options are enabled when the app starts
- EnableMenuItem(GetMenu(hMainWnd), ID_FIRST_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_PREV_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_NEXT_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_LAST_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_ADD_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_DEL_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_MOD_REC, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_ORDER, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_RANGE, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_CLEAR_RANGE, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_SEARCH, Show3);
- EnableMenuItem(GetMenu(hMainWnd), ID_UNDO_REC, Show3);
-
- // These resources need to be disabled while in add record mode
- EnableWindow(GetDlgItem(hMainWnd, ID_ORDER), !NewRecMode);
- EnableWindow(GetDlgItem(hMainWnd, ID_RANGE), !NewRecMode);
- EnableWindow(GetDlgItem(hMainWnd, ID_SEARCH), !NewRecMode);
-
- // These resources are hidden when the application starts
- ShowWindow(GetDlgItem(hMainWnd, IDOK), Show2);
- ShowWindow(GetDlgItem(hMainWnd, IDCANCEL), Show2);
- EnableWindow(GetDlgItem(hMainWnd, IDCANCEL), NewRecMode);
- EnableWindow(GetDlgItem(hMainWnd, IDOK), NewRecMode);
- if(NewRecMode)
- {
- LoadString(hInst, IDS_MAIN, szString, 150);
- SetDlgItemText(hMainWnd, IDS_NEW_REC_DESC, (pCHAR)szString);
- }
- ShowWindow(GetDlgItem(hMainWnd, IDS_NEW_REC_DESC), Show2);
- ShowWindow(GetDlgItem(hMainWnd, IDS_NEW_REC_DESC), Show2);
- }
-
- //=====================================================================
- // Function:
- // MakeFullPath (pszDirectory, pszRelativeDirectory)
- //
- // Input: pszDirectory - String to contain the path to the tables
- // directory.
- // pszRelativeDirectory - String which contains the relative offset
- // from the current directory.
- //
- // Return: int - If the directory exists
- //
- // Description:
- // This function is used to get the fully qualified path to
- // the directory which will contain the tables. This function
- // will only work when pszRelativeDirectory contains either "."
- // an absolute path, or ..\\..\\TABLES.
- //=====================================================================
- int
- MakeFullPath (pCHAR pszDirectory, pCHAR pszRelativeDirectory)
- {
- int iExists; // Does the directory exist?
- int iLen; // Length of the path
- int iLoop; // Loop counter
- int iDepth = 0;
-
- // Assume absolute path if second character is a ':'
- if (pszRelativeDirectory[1] == ':')
- {
- strcpy(pszDirectory, pszRelativeDirectory);
- }
- else if (!strcmp(pszRelativeDirectory, "."))
- {
- // Get the current working directory
- getcwd(pszDirectory, DBIMAXPATHLEN);
- }
- else
- {
- // Get the current working directory
- getcwd(pszDirectory, DBIMAXPATHLEN);
-
- iLen = strlen(pszDirectory);
-
- // Remove relative parts of the path.
- iDepth = 0;
- while (!strncmp(&pszRelativeDirectory[iDepth * 3], "..\\", 3))
- {
- for (iLoop = iLen; iLoop > -1; iLoop = iLoop - 1)
- {
- if (pszDirectory[iLoop] == '\\')
- {
- break;
- }
- }
- iLen = iLoop - 1;
- iDepth++;
- }
-
- // Copy the 'TABLES' directory to form the full path to the tables.
- // Need to move szDirectory past the '\\' and szTblDirectory
- // past the '..\\'.
- strcpy(&pszDirectory[iLoop+1], &pszRelativeDirectory[(3 * iDepth)]);
- }
-
- // Check if the directory exists
- iExists = access(pszDirectory, 00);
-
- return iExists;
- }
-
-