home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Total C++ 2
/
TOTALCTWO.iso
/
borland
/
32addres.pak
/
ADR_UTIL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-06
|
7KB
|
201 lines
// BDE32 3.x - (C) Copyright 1996 by Borland International
#include "address.h"
//======================================================================
// Name: 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, UINT TypeMsg, UINT TypeBtn)
{
return (UINT16)MessageBox(hMainWnd, (LPSTR) pMsg,
(LPSTR)"AddressBook Manager",
(UINT) TypeBtn | TypeMsg | MB_APPLMODAL);
}
//======================================================================
// Name: ChangeEntryMode(hCur);
//
// Input: hCur - Handle to the cursor
//
// 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 (hDBICur hCur)
{
UINT16 iShow1;
UINT16 iShow2;
UINT16 iShow3;
char szString[150];
if (NewRecMode)
{
// Change the mode flag
NewRecMode = FALSE;
// Show the startup resources
iShow1 = SW_SHOW;
// Hide the OK and Cancel buttons
iShow2 = SW_HIDE;
// Enable the menu options
iShow3 = MF_ENABLED;
}
else
{
// Change the mode flag
NewRecMode = TRUE;
// Hide the startup resources
iShow1 = SW_HIDE;
// Show the OK and Cancel buttons
iShow2 = SW_SHOW;
// Disable the menu options
iShow3 = MF_GRAYED;
}
// These resources are shown when the app starts
ShowWindow(GetDlgItem(hMainWnd, ID_ADD_REC), iShow1);
// These menu options are enabled when the app starts
EnableMenuItem(GetMenu(hMainWnd), ID_ADD_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_NEW, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_OPEN, iShow3);
// Check if the table is empty
if((AtBOF(hCur) && AtEOF(hCur)))
{
iShow3 = MF_GRAYED;
}
ShowWindow(GetDlgItem(hMainWnd, ID_DEL_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_FIRST_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_PREV_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_NEXT_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_LAST_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_MOD_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_UNDO_REC), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_ORDER), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_SEARCH), iShow1);
ShowWindow(GetDlgItem(hMainWnd, ID_RANGE), iShow1);
ShowWindow(GetDlgItem(hMainWnd, IDS_DATABASE_HDR), iShow1);
EnableMenuItem(GetMenu(hMainWnd), ID_FIRST_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_PREV_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_NEXT_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_LAST_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_DEL_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_MOD_REC, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_ORDER, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_RANGE, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_CLEAR_RANGE, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_SEARCH, iShow3);
EnableMenuItem(GetMenu(hMainWnd), ID_UNDO_REC, iShow3);
// 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), iShow2);
ShowWindow(GetDlgItem(hMainWnd, IDCANCEL), iShow2);
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), iShow2);
}
//=====================================================================
// 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;
// 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;
}