Поможем написать учебную работу
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Приложения
int OpenProject (void); (Project.h Project.cpp)
int OpenProject (void)
{
OPENFILENAME ofn;
char OpenName [122];
char szFile[256],
sz1[129],
szFileTitle[256];
char *szFilter = new char[256];
LoadString (hinstResource, STR56, szFilter, 256);
szFile[0] = '\0';
memset (&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrTitle = new char[50];
LoadString (hinstResource, STR1,(char*)ofn.lpstrTitle, 50);
ofn.lpstrDefExt = "pjt";
if (!bOpenAfterDir)
{
if (!GetOpenFileName(&ofn))
return CE_NOPROJECT;
UpdateWindow (hToolBarWnd);
UpdateWindow (hWnd);
strcpy (szCurrentProject,
strlwr(strcat (Mystrtok(szFile + ofn.nFileOffset, "."), ".pjt")));
strcpy (szProjectDirectory,szFile);
szProjectDirectory[ofn.nFileOffset] = '\0';
ProjectFlags = new ProjectFlagStruct;
CurrentProject = new ProjectStatusStruct;
NewCurrentProject = new PJTStruct;
strcpy(OpenName,strlwr(szFile));
}
else
{
ProjectFlags = new ProjectFlagStruct;
CurrentProject = new ProjectStatusStruct;
NewCurrentProject = new PJTStruct;
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
strcpy(OpenName,sz1);
}
delete szFilter;
delete (char *)ofn.lpstrTitle;
int rc;
if ((rc = OpenProjectFunct (OpenName)) == CE_NOPROJECT)
{
delete CurrentProject;
delete ProjectFlags;
delete NewCurrentProject;
return rc;
}
if (rc & CE_NODATABASE)
return rc;
DestroyMenu (hmenuMain);
hmenuMain = LoadMenu (hinstResource, "MAINMENU");
hmenuProject = GetSubMenu (hmenuMain, 0);
hmenuAdjust = GetSubMenu (hmenuMain, 1);
hmenuDatabase = GetSubMenu (hmenuMain, 2);
hmenuStudy = GetSubMenu (hmenuMain, 3);
hmenuEvaluate = GetSubMenu (hmenuMain, 4);
hmenuOptions = GetSubMenu (hmenuMain, 5);
hmenuWindow = GetSubMenu(hmenuMain, 6);
SetMenu (hMainWnd, hmenuMain);
DrawMenuBar (hMainWnd);
SendMessage (hMDIClient, WM_MDISETMENU, FALSE,
MAKELPARAM (hmenuMain, GetSubMenu (hmenuMain, WINDOWMENU)));
BYTE flg = NewCurrentProject->Flags;
flg &= 3;
if ((flg < FL_PHASE2) || strcmp(CurrentProject->ProjectTask, "Classification"))
{
EnableMenuItem (hmenuOptions, ID_O_PHASE2, MF_GRAYED);
}
if ((flg < FL_TOUGHT) || strcmp(CurrentProject->ProjectTask, "Classification"))
{
EnableMenuItem (hmenuStudy, ID_S_PHASE2, MF_GRAYED);
EnableMenuItem (hmenuStudy, ID_S_ANALYZE, MF_GRAYED);
}
if (flg < FL_TOUGHT)
{
int Condition = TL_ANALISE;
((RTButton)(ExpekTools->firstThat(TestFncn, Condition))).ChangeButtonState(DISABLE);
EnableMenuItem (hmenuEvaluate, 0, MF_GRAYED | MF_BYPOSITION);
EnableMenuItem (hmenuEvaluate, 1, MF_GRAYED | MF_BYPOSITION);
}
if (flg < FL_BUILT)
EnableMenuItem (hmenuStudy, 0, MF_BYPOSITION | MF_GRAYED); // Standards popup
if (!strcmp (CurrentProject->ProjectTask, "Classification"))
EnableMenuItem (hmenuAdjust, ID_P_MODIFYCLS, MF_ENABLED);
else
EnableMenuItem (hmenuAdjust, ID_P_MODIFYCLS, MF_GRAYED);
if(!strcmp(CurrentProject->ProjectTask, "Classification")) {
extern BOOL isPhase2;
extern int Ph2Ranges;
isPhase2 = FALSE;
Ph2Ranges = 10;
}
else {
extern BOOL isPhase2;
isPhase2 = FALSE;
}
ProjectFlags->NeedToDouble = FALSE;
return rc;
}
BOOL CreateProject (void); (Project.h Project.cpp)
BOOL CreateProject (void)
{
BOOL nRC;
char *sztmp = new char [128];
char sz1 [121];
char sz2 [121];
ProjectFlags = new ProjectFlagStruct;
CurrentProject = new ProjectStatusStruct;
NewCurrentProject = new PJTStruct;
if (!GetProjectName ())
{
delete ProjectFlags;
delete CurrentProject;
delete NewCurrentProject;
return FALSE;
}
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
DelPrj (sz1);
if (RusResourse)
HelpStack->PushInt (ID_W_CREATE);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpProjectDialog =
MakeProcInstance((int (PASCAL *)()) ProjectDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CREATE_PROJECT", hWnd, lpProjectDialog);
FreeProcInstance (lpProjectDialog);
HelpStack->PopInt ();
if (!nRC)
{
delete ProjectFlags;
delete CurrentProject;
delete NewCurrentProject;
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
DelPrj (sz1);
return FALSE;
}
if (!OpenProjectDatabase())
{
delete ProjectFlags;
delete CurrentProject;
delete NewCurrentProject;
PXPswDel (szPsw);
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
DelPrj (sz1);
return FALSE;
}
ProjectFlags->TableIsValid = TRUE;
NumOfClasses = 1;
if (!strcmp(CurrentProject->ProjectTask, "Classification"))
if (!CreateProjectClasses ())
{
NumOfClasses = 1;
clClasses->Clear ();
delete ProjectFlags;
delete CurrentProject;
delete NewCurrentProject;
delete Table;
delete Records;
PXPswDel (szPsw);
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
DelPrj (sz1);
return FALSE;
}
Standards = new ClassList;
strcpy (sz1, szProjectDirectory);
strcpy (sz2, szDBDirectory);
strcpy (sztmp, szCurrentProject);
strcpy (CurrentProject->ReqName, strcat(Mystrtok (sztmp, "."), ".tpt"));
strcpy (CurrentProject->StdName, strcat(Mystrtok (sztmp, "."), ".std"));
ProjectFlags->TemplateIsValid = CreateDemandTemplate ();
if (ProjectFlags->TemplateIsValid)
strcpy (CurrentProject->ProjectState, "Built");
Old2New (NewCurrentProject, CurrentProject);
Results = new TSTCList ("", FALSE, Classes, NumOfClasses, Records);
AdjustResults (Results);
Standards->Init(strcat(sz1,szCurrentProject));
if (Demands->GetCount () !=0)
if (!strcmp (CurrentProject->ProjectState, "Built"))
EditStandards();
DestroyMenu (hmenuMain);
hmenuMain = LoadMenu (hinstResource, "MAINMENU");
hmenuProject = GetSubMenu (hmenuMain, 0);
hmenuAdjust = GetSubMenu (hmenuMain, 1);
hmenuDatabase = GetSubMenu (hmenuMain, 2);
hmenuStudy = GetSubMenu (hmenuMain, 3);
hmenuEvaluate = GetSubMenu (hmenuMain, 4);
hmenuOptions = GetSubMenu (hmenuMain, 5);
hmenuWindow = GetSubMenu(hmenuMain, 6);
SetMenu (hWnd, hmenuMain);
DrawMenuBar (hWnd);
SendMessage (hMDIClient, WM_MDISETMENU, FALSE,
MAKELPARAM (hmenuMain, GetSubMenu (hmenuMain, WINDOWMENU)));
if (!strcmp (CurrentProject->ProjectTask, "Classification"))
EnableMenuItem (hmenuAdjust, ID_P_MODIFYCLS, MF_ENABLED);
else
EnableMenuItem (hmenuAdjust, ID_P_MODIFYCLS, MF_GRAYED);
// **********************************************************
if(!strcmp(CurrentProject->ProjectTask, "Classification")) {
EnableMenuItem (hmenuOptions, ID_O_PHASE2, MF_ENABLED);
EnableMenuItem (hmenuStudy, ID_S_PHASE2, MF_ENABLED);
EnableMenuItem (hmenuStudy, ID_S_ANALYZE, MF_ENABLED);
extern BOOL isPhase2;
extern int Ph2Ranges;
isPhase2 = FALSE;
Ph2Ranges = 10;
}
else {
extern BOOL isPhase2;
isPhase2 = FALSE;
EnableMenuItem (hmenuOptions, ID_O_PHASE2, MF_GRAYED);
EnableMenuItem (hmenuStudy, ID_S_PHASE2, MF_GRAYED);
EnableMenuItem (hmenuStudy, ID_S_ANALYZE, MF_GRAYED);
}
// **********************************************************
ProjectFlags->NeedToDouble = FALSE;
pColumns[0] = pColumns[1] = pColumns[2] = NULL;
nColumns[0] = nColumns[1] = nColumns[2] = 0;
SaveProject (szCurrentProject);
BYTE flg = NewCurrentProject->Flags;
flg &= 3;
EnableMenuItem (hmenuOptions, ID_O_PHASE2, MF_GRAYED);
EnableMenuItem (hmenuStudy, ID_S_PHASE2, MF_GRAYED);
EnableMenuItem (hmenuStudy, ID_S_ANALYZE, MF_GRAYED);
EnableMenuItem (hmenuAdjust, ID_P_MODIFYCLS, MF_GRAYED);
EnableMenuItem (hmenuEvaluate, 0, MF_GRAYED | MF_BYPOSITION);
EnableMenuItem (hmenuEvaluate, 1, MF_GRAYED | MF_BYPOSITION);
EnableMenuItem (hmenuStudy, 0, MF_BYPOSITION | MF_GRAYED);
if (flg > FL_BUILDING)
EnableMenuItem (hmenuStudy, 0, MF_BYPOSITION | MF_ENABLED);
if (flg > FL_BUILT)
{
EnableMenuItem (hmenuEvaluate, 0, MF_ENABLED | MF_BYPOSITION);
EnableMenuItem (hmenuEvaluate, 1, MF_ENABLED | MF_BYPOSITION);
}
if ((flg > FL_BUILT) && !strcmp (CurrentProject->ProjectTask, "Classification"))
{
EnableMenuItem (hmenuStudy, ID_S_ANALYZE, MF_ENABLED);
EnableMenuItem (hmenuStudy, ID_S_PHASE2, MF_ENABLED);
}
return TRUE;
}
void CloseProjectChoice (void); (Project.h Project.cpp)
void CloseProjectChoice (void)
{
if (!CloseProject (szCurrentProject)) return;
delete ProjectFlags;
}
void SaveProject (char *) (Project.h Project.cpp)
BOOL SaveProject (char *ProjectName)
{
char sztmp[121];
char sz1[121];
char sz2[121];
char szRCSTR [100];
LoadString (hinstResource, STR44,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_STARTPROCESS, 0, (LPARAM)(LPSTR) szRCSTR);
strcpy (sz1, szProjectDirectory);
strcpy (sz2, szDBDirectory);
strcpy (sztmp, ProjectName);
Mystrtok (sztmp, ".");
BOOL bflag = TRUE;
Records->GetSTC ();
Table->GetSTC ();
Demands->Get();
if (!SaveSTCFile (strcat(sz2, strcat
(Mystrtok(CurrentProject->ObjectsName, "."),
".stc")))) bflag = FALSE;
SendMessage (hIndicationBarWnd, WM_PROCESS, 51, 0L);
if (strcmp (CurrentProject->ProjectState, "Building"))
if (!SaveTPTFile (strcat (sz1,
strcat (Mystrtok (CurrentProject->ReqName, "."),
".tpt")))) bflag = FALSE;
SendMessage (hIndicationBarWnd, WM_PROCESS, 81, 0L);
strcpy (sz1, szProjectDirectory);
if (!SavePJTFile (strcat (sz1,
strcat (Mystrtok(ProjectName, "."),
".pjt")))) bflag = FALSE;
SendMessage (hIndicationBarWnd, WM_PROCESS, 100, 0L);
ProjectFlags->TemplateModified = ProjectFlags->TableModified = FALSE;
Records->ReleaseSTC ();
Table->ReleaseSTC ();
Demands->Release();
SendMessage (hIndicationBarWnd, WM_ENDPROCESS, 0, 0L);
return bflag;
}
void DeleteProject (void) (Project.h Project.cpp)
void DeleteProject (void)
{
OPENFILENAME ofn;
char szFile[256],
szFileTitle[256];
char *szFilter = new char[256];
LoadString (hinstResource, STR56, szFilter, 256);
szFile[0] = '\0';
memset (&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_HIDEREADONLY |
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrTitle = new char[50];
LoadString (hinstResource, STR55, (char*)ofn.lpstrTitle, 50);
ofn.lpstrDefExt = "pjt";
if (!GetOpenFileName(&ofn))
return ;
strcpy (szCurrentProject,
strlwr(strcat (Mystrtok(szFile + ofn.nFileOffset, "."), ".pjt")));
szFile[ofn.nFileOffset] = '\0';
strcpy (szProjectDirectory, szFile);
char sz1[121];
char sz2[121];
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
DelPrj (sz1);
}
void ModifyDB (void) (Project.h Project.cpp)
void ModifyDB (void)
{
int nRC;
int nLock;
nLock = Table->Lock;
Table->Destroy ();
if (!Table->GetSTC ())
{
char szRCSTR [100];
LoadString (hinstResource, STR18, szRCSTR, sizeof (szRCSTR));
MessageBox (hWnd, szRCSTR,
NULL, MB_OK | MB_ICONHAND);
return;
}
Table->Lock += nLock;
OrgRegNumber = Table->GetRegFields ();
OrgFieldNumber = Table->GetCount ();
Standards->Get ();
if (RusResourse)
HelpStack->PushInt (ID_W_FEATURES);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateStcProc = MakeProcInstance((int (PASCAL *)()) CreateStcDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CREATESTC", hWnd, lpCreateStcProc);
FreeProcInstance (lpCreateStcProc);
HelpStack->PopInt ();
if ((!nRC) || (!ProjectFlags->NeedToDouble))
{
nLock = Table->Lock;
Table->Destroy ();
Table->GetSTC ();
Table->Lock += nLock;
Table->ReleaseSTC();
return;
}
ProjectFlags->TableModified = TRUE;
if (ProjectFlags->NeedToDouble)
{
DoubleDB ();
Table->Renumber ();
Table->SaveSTC ();
nLock = Table->Lock;
Table->Destroy ();
Table->GetSTC ();
Table->Lock += nLock;
Table->ReleaseSTC ();
}
}
void ModifyDemands (void) (Project.h Project.cpp)
void ModifyDemands (void)
{
int nRC;
if (ProjectFlags->TemplateModified)
if (!SaveTPTFile (CurrentProject->ReqName))
return ;
ProjectFlags->TemplateModified = FALSE;
if (!Demands->Get ())
{
Demands->Create ();
}
if (RusResourse)
HelpStack->PushInt (ID_W_DEMANDS);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateTptProc = MakeProcInstance((int (PASCAL *)()) CreateTptDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CREATETPT", hWnd, (DLGPROC) lpCreateTptProc);
FreeProcInstance (lpCreateTptProc);
HelpStack->PopInt ();
#if defined (DEMO_RECORD) || defined (DEMO_PLAY)
Demands->Destroy ();
Old2New (NewCurrentProject, CurrentProject);
return;
#endif
if (nRC)
{
if (Demands->GetCount() == 0)
{
Demands->Save ();
return;
}
if (!Demands->Save ())
return;
if (!strcmp (CurrentProject->ProjectState, "Building"))
strcpy (CurrentProject->ProjectState, "Built");
EnableMenuItem (hmenuStudy, 0, MF_BYPOSITION | MF_ENABLED);
SendMessage (hIndicationBarWnd, WM_PROJECTCHANGESTATE, FL_BUILT, 0l);
}
else
Demands->Destroy ();
Old2New (NewCurrentProject, CurrentProject);
}
void ModifyClasses (void) (Project.h Project.cpp)
void ModifyClasses (void)
{
int nRC;
BOOL bOpened;
clClasses->Get (Classes, NumOfClasses);
Standards->Get ();
Demands->Get ();
if (RusResourse)
HelpStack->PushInt (ID_W_CLASSES);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateClassesProc = MakeProcInstance((int (PASCAL *)()) ClassesDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CLASSLIST_DIALOG", hWnd, lpCreateClassesProc);
FreeProcInstance (lpCreateClassesProc);
HelpStack->PopInt ();
#if defined (DEMO_PLAY) || defined (DEMO_RECORD)
clClasses->Release ();
Standards->Release ();
return;
#endif
if (!nRC)
{
clClasses->Release ();
Standards->Release ();
return;
}
Standards->UpdateClasses (clClasses);
Demands->UpdateClasses (clClasses);
clClasses->Save (Classes, NumOfClasses);
Table->GetSTC ();
Results->GetSTC ();
OrgFieldNumber = Results->GetCount();
OrgRegNumber = Results->GetRegFields ();
Results->ReleaseSTC ();
char szRCSTR [100];
LoadString (hinstResource, STR51, szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_STARTPROCESS, 0, (LONG) szRCSTR);
bOpened = hDataBase;
if (bOpened)
SendMessage (hMDIClient, WM_MDIDESTROY, hDataBase, 0L);
UpdateWindow (hMDIClient);
int oldLock;
oldLock = Results->Lock;
delete Results;
Results = new TSTCList ("",FALSE, Classes, NumOfClasses,
Table);
Table->ReleaseSTC ();
Results->GetSTC ();
Results->Lock = oldLock+1;
Results->Renumber (clClasses);
char sz1[121];
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
strcat (Mystrtok(sz1, "."), ".db");
{
unsigned *crslnk;
startPercentage = 0;
endPercentage = 100;
crslnk = CreateCrossLinks (TRUE, Results);
DoRestruct (sz1, Results, crslnk, Results->GetCount () + 1);
delete crslnk;
delete pColumns[0];
delete pColumns[1];
delete pColumns[2];
pColumns[0] = pColumns[1] = pColumns[2] = NULL;
nColumns[0] = nColumns[1] = nColumns[2] = 0;
if (bOpened)
SendMessage (hMainWnd, WM_COMMAND, ID_D_OPEN, 0L);
}
Results->ReleaseSTC ();
Standards->Save ();
clClasses->Release ();
Standards->Release ();
Demands->Release ();
SendMessage (hIndicationBarWnd, WM_ENDPROCESS, 0, 0l);
SaveProject (szCurrentProject);
}
int OpenProjectFunct (char *) (void) (Project.h Project.cpp)
int OpenProjectFunct (char *ProjectName)
{
FILE *file;
char sztmp[121];
char sz1[121], sz2[121];
char szCurrentFont[LF_FACESIZE];
int nRC = CE_SUCCESS;
strcat (Mystrtok (ProjectName, "."), ".pjt");
if (!IsFileExist (ProjectName))
return CE_NOPROJECT;
extern BOOL CheckProjectFile(char *);
if(!CheckProjectFile(ProjectName)) {
char mess[100];
LoadString(hinstResource, STR99, mess, sizeof(mess));
MessageBox(hWnd, mess, NULL, MB_OK | MB_ICONHAND);
return CE_NOPROJECT;
}
if ((file = fopen (ProjectName, "rb")) == NULL) return CE_NOPROJECT;
if (!ReadOldPJT (file))
if (!ReadNewPJT (file))
{
fclose (file);
return CE_NOPROJECT;
}
Old2New (NewCurrentProject, CurrentProject);
if (OpenAfterSaveAs)
{
strcpy (szPsw, sz1Psw);
PXPswAdd (szPsw);
if (!strcmp (CurrentProject->ProjectStatus, "Private"))
strcpy (CurrentProject->Password, szPsw);
}
else
if (!strcmp (CurrentProject->ProjectStatus, "Private"))
{
if (!EnterPassword ())
{
return CE_NOPROJECT;
}
PXPswAdd (CurrentProject->Password);
strcpy (szPsw,CurrentProject->Password);
}
else
{
PXPswAdd ("Password");
strcpy (szPsw,"Password");
}
char szRCSTR1 [100];
LoadString (hinstResource, STR43,szRCSTR1, sizeof (szRCSTR1));
SendMessage (hIndicationBarWnd, WM_STARTPROCESS, 0, (LPARAM)(LPSTR) szRCSTR1);
NumOfClasses = 1;
if (!strcmp (CurrentProject->ProjectTask, "Classification"))
{
if (fread (&NumOfClasses, sizeof (NumOfClasses), 1, file) != 1)
{
fclose (file);
SendMessage (hIndicationBarWnd, WM_ENDPROCESS, 0, 0l);
return CE_NOPROJECT;
}
for (int nI = 0; nI < NumOfClasses; nI++)
{
Classes[nI] = new char[51];
if (fread (Classes[nI], 51, 1, file) != 1)
{
fclose (file);
SendMessage (hIndicationBarWnd, WM_ENDPROCESS, 0, 0l);
return CE_NOPROJECT;
}
}
}
SendMessage (hIndicationBarWnd, WM_PROCESS, 6, 0l);
fread (szDBDirectory, sizeof(szDBDirectory), 1, file);
if (fread (&nClmns, sizeof (nClmns), 1, file) != 1)
{
nClmns = 0;
}
else
{
int Width;
BOOL Visible;
if (nClmns)
pClmns = new COLUMN[nClmns];
for (int nI = 0; nI < nClmns; nI++)
{
fread (&Width, sizeof (Width), 1, file);
pClmns[nI].nWidth = Width;
fread (&Visible, sizeof (Visible), 1, file);
pClmns[nI].bVisible = Visible;
}
}
SendMessage (hIndicationBarWnd, WM_PROCESS, 8, 0l);
if (fread (szCurrentFont, sizeof (szCurrentFont), 1, file)!=1)
{
strcpy (szCurrentFont, "");
}
else
{
if (strcmp (szCurrentFont, ""))
strcpy (MainFontRec.lfFaceName, szCurrentFont);
}
if (!strcmp(CurrentProject->ProjectStatus, "Private"))
strcpy (szPsw, CurrentProject->Password);
else
strcpy (szPsw, "Password");
nRC = CheckingExistence ();
if (nRC & CE_NODATABASE)
{
char szRCSTR [100];
LoadString (hinstResource, STR25,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
MessageBox (hWnd, szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
if ((nRC & CE_NOTEMPLATE) && strcmp (CurrentProject->ProjectState, "Building"))
{
char szRCSTR [100];
LoadString (hinstResource, STR26,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0,0l);
MessageBox (hWnd, szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0,0l);
strcpy (CurrentProject->ProjectState, "Building");
}
if (nRC & CE_NORESULTS)
{
char szRCSTR [100];
LoadString (hinstResource, STR27,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
MessageBox (hWnd, szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
if ((nRC & CE_NOSTANDARDS) && (!strcmp (CurrentProject->ProjectState,
"Tought") || !strcmp (CurrentProject->ProjectState, "Phase 2")))
{
char szRCSTR [100];
LoadString (hinstResource, STR28,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
MessageBox (hWnd, szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
strcpy (CurrentProject->ProjectState, "Built");
}
if ((!(nRC & CE_NOTEMPLATE)) && !strcmp (CurrentProject->ProjectState,
"Building"))
{
char szRCSTR [100];
char szRCSTR1 [100];
LoadString (hinstResource, STR29,szRCSTR, sizeof (szRCSTR));
LoadString (hinstResource, STR_SA_ATT,szRCSTR1, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
if (MessageBox (GetFocus(), szRCSTR,szRCSTR1,
MB_YESNO | MB_ICONQUESTION) == IDYES)
strcpy (CurrentProject->ProjectState, "Built");
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
if ((!(nRC & CE_NOSTANDARDS)) && !strcmp (CurrentProject->ProjectState,
"Built"))
{
char szRCSTR [100];
char szRCSTR1 [100];
LoadString (hinstResource, STR_SA_ATT,szRCSTR1, sizeof (szRCSTR));
LoadString (hinstResource, STR30,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
if (MessageBox (GetFocus(), szRCSTR,
szRCSTR1, MB_YESNO | MB_ICONQUESTION) == IDYES)
strcpy (CurrentProject->ProjectState, "Tought");
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
fclose (file);
SendMessage (hIndicationBarWnd, WM_PROCESS, 10, 0l);
if (!CheckingWritable (nRC))
{
char szRCSTR[200];
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
LoadString (hinstResource, STR98, szRCSTR, sizeof (szRCSTR));
MessageBox (GetFocus (),szRCSTR, NULL, MB_ICONHAND | MB_OK);
SendMessage (hIndicationBarWnd, WM_ENDPROCESS,0,0l);
return CE_NOPROJECT;
}
strcpy (sztmp, CurrentProject->ObjectsName);
strcat (Mystrtok(sztmp, "."), ".stc");
strcpy (sz1, szProjectDirectory);
strcpy (sz2, szDBDirectory);
Table = new TSTCList (strcat(sz2, sztmp), TRUE);
Results = new TSTCList ("", FALSE, Classes, NumOfClasses, Table);
strcat (sz1, szCurrentProject);
strcat (Mystrtok (sz1, "."), ".stc");
Records = new TSTCList (sz1, TRUE);
if ((nRC & CE_NOSTRUCTURE) && !(nRC & CE_NODATABASE))
Copy (Records, Table);
if ((nRC & CE_NOSTRUCTURE) && (nRC & CE_NODATABASE))
return nRC;
if (!strcmp (CurrentProject->ProjectState, "Phase 2"))
switch (CheckPhase2 (sz1))
{
case OK_PH2:
break;
case MISSING_PH2:
case BAD_PH2:
{
char szRCSTR [100];
LoadString (hinstResource, STR52,szRCSTR, sizeof (szRCSTR));
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
MessageBox (GetFocus (), szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
DeletePhase2 (sz1);
strcpy (CurrentProject->ProjectState, "Tought");
break;
}
if (!strcmp (CurrentProject->ProjectState, "Tought") ||
!strcmp (CurrentProject->ProjectState, "Phase 2"))
switch (CheckStandards (sz1))
{
case OK_STD:
break;
case BAD_STD:
{
char szRCSTR [100];
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
LoadString (hinstResource, STR31,szRCSTR, sizeof (szRCSTR));
MessageBox (GetFocus (), szRCSTR, NULL,
MB_OK | MB_ICONEXCLAMATION);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
}
DeleteStandards (sz1);
strcpy (CurrentProject->ProjectState, "Built");
break;
}
if (!(nRC & CE_NODATABASE))
if (!CheckingDB (sz2))
{
SendMessage (hIndicationBarWnd, WM_ENDPROCESS, 0, 0l);
char szRCSTR [100];
SendMessage (hIndicationBarWnd, WM_DELAYPROCESS, 0, 0l);
LoadString (hinstResource, STR8,szRCSTR, sizeof (szRCSTR));
MessageBox (GetFocus (), szRCSTR,
NULL,
MB_OK | MB_ICONHAND);
UpdateWindow (hMainWnd);
SendMessage (hIndicationBarWnd, WM_RESTOREPROCESS, 0, 0l);
nRC = nRC | CE_NODATABASE;
}
strcpy (sz1, szProjectDirectory);
ProjectFlags->TableModified = FALSE;
ProjectFlags->TemplateModified = FALSE;
Records->GetSTC ();
Standards = new ClassList;
Standards->Init(strcat (sz1, szCurrentProject));
Standards->Get ();
Records->ReleaseSTC ();
strcpy (sz1, szProjectDirectory);
if (!strcmp(CurrentProject->ProjectTask, "Classification"))
Demands = new TReqList (strcat (sz1,
CurrentProject->ReqName), NumOfClasses);
else
Demands = new TReqList (strcat (sz1,
CurrentProject->ReqName));
ProjectFlags->ResultsNeedSave = FALSE;
ProjectFlags->NowCreated = FALSE;
Records->GetSTC ();
OrgRegNumber = Records->GetRegFields();
if (!(nRC & CE_NOPROJECT) && !(nRC & CE_NODATABASE))
if ( CompareStructures ())
{
{
unsigned *crslnk;
BOOL bOpened;
strcpy (sz1, szProjectDirectory);
Mystrtok (strcat (sz1, szCurrentProject), ".");
bOpened = hDataBase;
if (bOpened)
SendMessage (hMDIClient, WM_MDIDESTROY, hDataBase, 0L);
crslnk = CreateCrossLinks (FALSE);
DoRestruct (sz1, Results, crslnk, Records->GetRegFields () + 1);
delete crslnk;
if (bOpened)
SendMessage (hMainWnd, WM_COMMAND, ID_D_OPEN, 0L);
}
if (!(nRC & CE_NOTEMPLATE))
{
RecreateDemands ();
Standards->UpdateStructure ();
if (!Standards->Save ())
return CE_NOPROJECT;
}
else
{
strcpy (CurrentProject->ProjectState, "Building");
}
}
Records->ReleaseSTC ();
if (!Records->GetSTC ()) return (nRC | CE_NODATABASE);
Records->Renumber ();
if (!Records->SaveSTC ())
return CE_NOPROJECT;
Records->ReleaseSTC ();
SendMessage (hIndicationBarWnd, WM_PROCESS, 14, 0L);
Old2New (NewCurrentProject, CurrentProject);
return nRC;
}
BOOL CreateDemandTemplate (void) (void) (Project.h Project.cpp)
BOOL CreateDemandTemplate (void)
{
int nRC;
char sz1[129];
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
strcat (Mystrtok (sz1, "."), ".stc");
if (!strcmp (CurrentProject->ProjectTask, "Classification"))
Demands = new TReqList (sz1, NumOfClasses);
else
Demands = new TReqList (sz1);
Demands->Create ();
if (RusResourse)
HelpStack->PushInt (ID_W_DEMANDS);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateTptProc = MakeProcInstance((int (PASCAL *)()) CreateTptDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CREATETPT", hWnd, (DLGPROC) lpCreateTptProc);
FreeProcInstance (lpCreateTptProc);
HelpStack->PopInt ();
ProjectFlags->TemplateModified = nRC;
if (nRC)
{
if (Demands->GetCount () == 0)
{
Demands->Release ();
return FALSE;
}
if (!strcmp (CurrentProject->ProjectState, "Building"))
strcpy (CurrentProject->ProjectState, "Built");
}
else
Demands->Release ();
return nRC;
}
BOOL CreateProjectClasses (void) (void) (Project.h Project.cpp)
BOOL CreateProjectClasses (void)
{
int nRC;
if (RusResourse)
HelpStack->PushInt (ID_W_CLASSES);
else
HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateClassesProc = MakeProcInstance((int (PASCAL *)()) ClassesDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CLASSLIST_DIALOG", hWnd, lpCreateClassesProc);
FreeProcInstance (lpCreateClassesProc);
HelpStack->PopInt ();
if (nRC)
{
for (int i = 0; i < clClasses->GetCount (); i++)
Classes[i] = new char[51];
clClasses->Save (Classes, NumOfClasses);
clClasses->Release ();
}
return nRC;
}
BOOL CreateDBStructure (char *) (void) (Project.h Project.cpp)
BOOL CreateDBStructure (char *ATableName)
{
int nRC;
char szAlpha[122];
char sztmp [122];
char sz1[129];
strcpy (szAlpha, ATableName);
Mystrtok (szAlpha, ".");
strcpy (sztmp, szAlpha);
strcat (sztmp, ".stc");
Table = new TSTCList (sztmp, TRUE);
Table->Create();
if (RusResourse) HelpStack->PushInt (ID_W_FEATURES);
else HelpStack->PushInt (ID_ENGLISHHELP);
FARPROC lpCreateStcProc = MakeProcInstance((int (PASCAL *)()) CreateStcDlgProc,hInst);
nRC = DialogBox(hinstResource, (LPSTR) "CREATESTC", hWnd, lpCreateStcProc);
FreeProcInstance (lpCreateStcProc);
HelpStack->PopInt ();
if (!nRC) return FALSE;
Table->Renumber();
strcat (szAlpha, ".stc");
if (!SaveSTCFile (szAlpha)) return FALSE;
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
strcat (Mystrtok(sz1, "."), ".stc");
Records = new TSTCList (sz1, TRUE);
Copy (Records, Table);
return TRUE;
}
BOOL UseExistingTable (char *) (void) (Project.h Project.cpp)
BOOL UseExistingTable (char *ATableName)
{
char szAlpha[122];
char sztmp[121];
char sz1[129];
TABLEHANDLE tmpTblHandle;
strcpy (szAlpha, ATableName);
Mystrtok (szAlpha, ".");
if (!CheckingDB (szAlpha))
{
return FALSE;
}
strcat (szAlpha, ".stc");
if (!IsFileExist (szAlpha)) return FALSE;
Table = new TSTCList (szAlpha, TRUE);
strcpy (sz1, szProjectDirectory);
strcat (sz1, szCurrentProject);
strcat (Mystrtok(sz1, "."), ".stc");
Records = new TSTCList (sz1, TRUE);
Copy (Records, Table);
ProjectFlags->TableModified = FALSE;
return TRUE;
}
BOOL FAR PASCAL _export CreateSTCDlgProc
(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam) (void) (Project.h Project.cpp)
BOOL FAR PASCAL _export CreateStcDlgProc (HWND hDlg,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
static int nCurrType;
static int nCurrPos;
static BOOL Modified;
static HPEN hBlackPen, hWhitePen;
static HBRUSH hNormBrush, hSelBrush, hBrush;
static char szRCSTR1[200];
static char szRCSTR2[200];
switch (message)
{
case WM_RBUTTONDBLCLK:
WORD w;
w = wParam;
if ((w & MK_CONTROL) && (w & MK_SHIFT)) return FALSE;
case WM_INITDIALOG:
CheckRadioButton (hDlg, ID_STC_REGFLD, ID_STC_IMPFLD,
ID_STC_REGFLD);
nCurrType = 2;
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_ADDSTRING,
, (LPARAM) "");
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_SETCURSEL,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_SETHORIZONTALEXTENT,
, 0l);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_SETHORIZONTALEXTENT,
, 0L);
Table->GotoFirst();
for (int nJ = 0; nJ < Table->GetNumOfFields(); nJ++)
{
(*Table)[nJ];
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_INSERTSTRING,
nJ,
(LONG) Table->GetFieldName());
}
Modified = FALSE;
SetTimer (hDlg, 1, 1000, NULL);
LoadString (hinstResource, STR9,szRCSTR1, sizeof (szRCSTR1));
LoadString (hinstResource, STR10,szRCSTR2, sizeof (szRCSTR2));
SendMessage (hDlg, WM_COMMAND, ID_STC_CHARLIST,
((LONG) LBN_SELCHANGE) << 16);
hBlackPen = GetStockObject(BLACK_PEN);
hWhitePen = GetStockObject(WHITE_PEN);
hNormBrush = CreateSolidBrush (GetSysColor(COLOR_WINDOW));
hSelBrush = CreateSolidBrush (GetSysColor (COLOR_HIGHLIGHT));
ProjectFlags->NeedToDouble = FALSE;
break;
case WM_TIMER:
if (Modified && (Table->GetState() != 2) )
{
char sztemp[21];
GetDlgItemText (hDlg, ID_STC_EDITFIELD, sztemp, 20);
if (!strcmp(sztemp, szRCSTR2))
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR1);
else
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR2);
}
if (SendDlgItemMessage (hDlg,
ID_STC_LISTVAL, LB_GETCOUNT, 0, 0l) < 2)
EnableWindow (GetDlgItem (hDlg, ID_STC_DELVAL), FALSE);
else
EnableWindow (GetDlgItem (hDlg, ID_STC_DELVAL), TRUE);
break;
case WM_MEASUREITEM:
MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
switch (mis->CtlID)
{
case ID_STC_CHARLIST:
mis->itemHeight = 14;
break;
default: return FALSE;
}
break;
case WM_DRAWITEM:
DRAWITEMSTRUCT *disCtl = (DRAWITEMSTRUCT *)lParam;
switch (disCtl->CtlID)
{
case ID_STC_CHARLIST:
if (disCtl->itemState & ODS_SELECTED)
{
hBrush = hSelBrush;
SetBkColor (disCtl->hDC,GetSysColor(COLOR_HIGHLIGHT));
}
else
{
hBrush = hNormBrush;
SetBkColor (disCtl->hDC, GetSysColor(COLOR_WINDOW));
}
FillRect (disCtl->hDC, &(disCtl->rcItem), hBrush);
COLORREF crColor;
if(((*Table)[disCtl->itemID]) == NULL) break;
if (disCtl->itemState & ODS_SELECTED)
{
crColor = GetSysColor (COLOR_HIGHLIGHTTEXT);
}
else
switch (Table->GetState ())
{
case 1:
crColor = RGB (0,0,255);
break;
case 0:
crColor = RGB (0,0,0);
break;
case 2:
crColor = RGB (255,0,0);
break;
}
SetTextColor (disCtl->hDC, crColor);
char szbuf[129];
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_GETTEXT,
disCtl->itemID, (LONG) szbuf);
ExtTextOut (disCtl->hDC, disCtl->rcItem.left,
disCtl->rcItem.top, ETO_CLIPPED,
&(disCtl->rcItem), szbuf,
strlen (szbuf), NULL);
if (disCtl->itemState & ODS_FOCUS)
DrawFocusRect(disCtl->hDC, &(disCtl->rcItem));
break;
default: return FALSE;
}
break;
case WM_COMMAND:
switch (wParam)
{
case ID_STC_CHARLIST:
switch (HIWORD(lParam))
{
char sztmp[129];
case LBN_SELCHANGE:
nCurrPos = SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETCURSEL,
,
L);
if ((*Table)[nCurrPos] == NULL)
{
Modified = FALSE;
break;
}
else
{
EnableWindow (GetDlgItem (hDlg, ID_STC_EDITFIELD),
TRUE);
EnableWindow (GetDlgItem (hDlg, ID_STC_DELFIELD),
TRUE);
}
SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_RESETCONTENT,
,
L);
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR1);
Modified = FALSE;
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
SetDlgItemText (hDlg, ID_STC_VALNAME, "");
SetDlgItemText (hDlg, ID_STC_FLDNAME,
Table->GetFieldName());
switch (Table->GetFieldType())
{
case 0:
SendMessage (hDlg, WM_COMMAND,
ID_STC_ENUMFLD,
L);
for (int nJ = 0; nJ < Table->GetNumOfValues(); nJ++)
{
Table->GotoVal (nJ);
SendDlgItemMessage(hDlg, ID_STC_LISTVAL,
LB_INSERTSTRING,
nJ,
(LONG) Table->GetValue());
SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_SETCURSEL,
, 0l);
break;
case 1:
SendMessage (hDlg, WM_COMMAND,
ID_STC_NUMFLD,
L);
char szNum[21];
sprintf(szNum, "%g",Table->GetMin());
SetDlgItemText (hDlg, ID_STC_MINVAL, szNum);
sprintf(szNum, "%g",Table->GetMax());
SetDlgItemText (hDlg, ID_STC_MAXVAL, szNum);
break;
case 2:
SendMessage (hDlg, WM_COMMAND,
ID_STC_REGFLD,
L);
break;
}
break;
default: return FALSE;
}
break;
case ID_STC_FLDNAME:
switch (HIWORD (lParam))
{
char sztmp[129];
char sztmp1[129];
case EN_CHANGE:
GetDlgItemText (hDlg, ID_STC_FLDNAME, sztmp, 128);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_GETTEXT,
SendDlgItemMessage (hDlg,
ID_STC_CHARLIST,
LB_GETCURSEL, 0, 0l),
(LONG) sztmp1);
break;
case EN_SETFOCUS:
SendDlgItemMessage (hDlg, ID_STC_FLDNAME, EM_SETSEL,
, MAKELPARAM (0, -1));
break;
default: return FALSE;
}
break;
case ID_STC_REGFLD:
CheckRadioButton (hDlg, ID_STC_REGFLD, ID_STC_IMPFLD,
ID_STC_REGFLD);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_RESETCONTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_ADDSTRING,
, (LONG) "");
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
nCurrType = 2;
break;
case ID_STC_NUMFLD:
CheckRadioButton (hDlg, ID_STC_REGFLD, ID_STC_IMPFLD,
ID_STC_NUMFLD);
nCurrType = 1;
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_RESETCONTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_ADDSTRING,
, (LONG) "");
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
break;
case ID_STC_ENUMFLD:
CheckRadioButton (hDlg, ID_STC_REGFLD, ID_STC_IMPFLD,
ID_STC_ENUMFLD);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_RESETCONTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_ADDSTRING,
, (LONG) "");
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_SETCURSEL,
, 0l);
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
nCurrType = 0;
break;
case ID_STC_IMPFLD:
CheckRadioButton (hDlg, ID_STC_REGFLD, ID_STC_IMPFLD,
ID_STC_IMPFLD);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_RESETCONTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_ADDSTRING,
, (LONG) "");
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
nCurrType = 3;
break;
case ID_STC_ADDFIELD:
char sztmp [129];
nCurrPos = SendMessage (GetDlgItem (hDlg, ID_STC_CHARLIST),
LB_GETCURSEL, 0, 0L);
if (!AddField (hDlg, nCurrType, nCurrPos, FALSE)) return TRUE;
char sztemp [129];
GetDlgItemText (hDlg, ID_STC_FLDNAME, sztemp, 128);
nCurrPos = SendMessage (GetDlgItem (hDlg, ID_STC_CHARLIST),
LB_GETCURSEL, 0, 0L);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_INSERTSTRING, nCurrPos, (LONG) sztemp);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_SETCURSEL,
nCurrPos + 1,
L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_RESETCONTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_ADDSTRING,
, (LONG) "");
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_SETCURSEL,
, 0l);
SetDlgItemText (hDlg, ID_STC_MINVAL, "");
SetDlgItemText (hDlg, ID_STC_MAXVAL, "");
SetDlgItemText (hDlg, ID_STC_VALNAME, "");
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR1);
ProjectFlags->NeedToDouble = TRUE;
Modified = FALSE;
break;
case ID_STC_DELFIELD:
nCurrPos = SendMessage (GetDlgItem (hDlg, ID_STC_CHARLIST),
LB_GETCURSEL, 0, 0L);
char sz [129];
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_GETTEXT,
nCurrPos, (LONG) sz);
if (!strcmp (sz, "")) break;
(*Table)[nCurrPos];
Table->SetState (2);
Modified = FALSE;
ProjectFlags->NeedToDouble = TRUE;
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR1);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_SETCURSEL,
nCurrPos + 1, 0l);
SendMessage (hDlg, WM_COMMAND, ID_STC_CHARLIST,
MAKELPARAM (0, LBN_SELCHANGE));
break;
case ID_STC_EDITFIELD:
int Type;
nCurrPos = SendMessage (GetDlgItem (hDlg, ID_STC_CHARLIST),
LB_GETCURSEL, 0, 0L);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST, LB_GETTEXT,
nCurrPos, (LONG) sz);
if (!strcmp (sz, "")) break;
(*Table)[Table->GetNumberByName(sz)];
Type = Table->GetFieldType();
int Num = Table->GetFieldNumber ();
switch (nCurrType)
{
case 2:
if (Type != 2)
{
char szRCSTR [100];
LoadString (hinstResource, STR11,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg,
szRCSTR,
NULL,
MB_ICONHAND | MB_OK);
return TRUE;
}
break;
case 1:
if (Type != 1)
{
char szRCSTR [100];
LoadString (hinstResource, STR11,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg,
szRCSTR,
NULL,
MB_ICONHAND | MB_OK);
return TRUE;
}
break;
case 0:
if (Type != 0)
{
char szRCSTR [100];
LoadString (hinstResource, STR11,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg,
szRCSTR,
NULL,
MB_ICONHAND | MB_OK);
return TRUE;
}
break;
}
switch (Table->GetState())
{
case 2:
{
char szRCSTR [100];
LoadString (hinstResource, STR12,szRCSTR, sizeof (szRCSTR));
if (MessageBox (hDlg, szRCSTR,
NULL,
MB_YESNO | MB_ICONQUESTION)==IDNO)
return TRUE;
else
{
if (!AddField (hDlg, nCurrType, nCurrPos, TRUE)) return TRUE;
Table->SetFieldNumber (Num);
break;
}
}
case 0:
case 1:
BOOL bflg;
if (!AddField (hDlg, nCurrType, nCurrPos, TRUE)) return TRUE;
Table->SetFieldNumber (Num);
if ((*Table)++ == NULL)
bflg = TRUE;
else
bflg = FALSE;
Table->DeleteField ();
GetDlgItemText (hDlg, ID_STC_FLDNAME, sztemp, 128);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_INSERTSTRING, nCurrPos,
(LONG) sztemp);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_DELETESTRING, nCurrPos + 1, 0l);
if (!bflg) (*Table)--;
Table->SetState (1);
break;
}
Modified = FALSE;
SetDlgItemText (hDlg, ID_STC_EDITFIELD, szRCSTR1);
ProjectFlags->NeedToDouble = TRUE;
break;
case ID_STC_MINVAL:
char sz1 [21];
switch (HIWORD (lParam))
{
case EN_KILLFOCUS:
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETTEXT,
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETCURSEL,
, 0l),
(LONG) sz);
GetDlgItemText (hDlg, ID_STC_MINVAL, sz1, 20);
if (strcmp (sz, ""))
if (atof (sz1) != Table->GetMin ())
Modified = TRUE;
break;
default : return FALSE;
}
break;
case ID_STC_MAXVAL:
sz1 [21];
switch (HIWORD (lParam))
{
case EN_KILLFOCUS:
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETTEXT,
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETCURSEL,
, 0l),
(LONG) sz);
GetDlgItemText (hDlg, ID_STC_MAXVAL, sz1, 20);
if (strcmp (sz, ""))
if (atof (sz1) != Table->GetMax ())
Modified = TRUE;
break;
default : return FALSE;
}
break;
case ID_STC_NEWVAL:
char szStr [31];
sz [129];
int nCurrVal;
nCurrVal = SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_GETCURSEL,0, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_GETTEXT,
nCurrVal, (LONG) szStr);
GetDlgItemText (hDlg, ID_STC_VALNAME, szStr, 30);
if (!strcmp (szStr, "")) break;
if (SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_FINDSTRINGEXACT, -1, (LONG)szStr)
== LB_ERR)
SendMessage (GetDlgItem (hDlg, ID_STC_LISTVAL),
LB_INSERTSTRING, nCurrVal,
(LONG) szStr);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_SETCURSEL, nCurrVal + 1, 0l);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETTEXT,
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETCURSEL,
, 0l),
(LONG) sz);
if (strcmp (sz, "")) Modified = TRUE;
break;
case ID_STC_DELVAL:
nCurrVal = SendDlgItemMessage (hDlg, ID_STC_LISTVAL,
LB_GETCURSEL,0, 0L);
SendDlgItemMessage (hDlg, ID_STC_LISTVAL, LB_GETTEXT,
nCurrVal, (LONG) sz);
if (!strcmp (sz, "")) break;
SendMessage (GetDlgItem (hDlg, ID_STC_LISTVAL),
LB_DELETESTRING, nCurrVal,
L);
SendMessage (GetDlgItem (hDlg, ID_STC_LISTVAL),
LB_SETCURSEL, nCurrVal,
L);
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETTEXT,
SendDlgItemMessage (hDlg, ID_STC_CHARLIST,
LB_GETCURSEL,
, 0l),
(LONG) sz);
if (strcmp (sz, "")) Modified = TRUE;
break;
case ID_STC_EDITVAL:
SendMessage (hDlg, WM_COMMAND, ID_STC_DELVAL, 0L);
SendMessage (hDlg, WM_COMMAND, ID_STC_NEWVAL, 0L);
break;
case IDOK:
int All, Reg, Inf;
All = Reg = Inf = 0;
for (int i = 0; i < Table->GetCount (); i++)
{
(*Table)[i];
switch (Table->GetState ())
{
case 1:
case 0:
switch (Table->GetFieldType())
{
case 0:
case 1:
Inf ++;
break;
case 2:
Reg ++;
break;
}
All++;
break;
default : continue;
}
}
if (!All)
{
char szRCSTR [100];
LoadString (hinstResource, STR13,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg, szRCSTR,
NULL,
MB_OK | MB_ICONEXCLAMATION);
break;
}
if (!Inf)
{
char szRCSTR [100];
LoadString (hinstResource, STR14,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg, szRCSTR,
NULL,
MB_OK | MB_ICONEXCLAMATION);
break;
}
if (!Reg)
{
char szRCSTR [100];
LoadString (hinstResource, STR15,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg, szRCSTR,
NULL,
MB_OK | MB_ICONEXCLAMATION);
break;
}
Clear ();
Adjust ();
KillTimer (hDlg, 1);
EndDialog (hDlg, TRUE);
break;
case IDCANCEL:
KillTimer (hDlg, 1);
EndDialog (hDlg, FALSE);
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}
BOOL FAR PASCAL _export CreateTPTDlgProc
(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam) (void) (Project.h Project.cpp)
BOOL FAR PASCAL _export CreateTptDlgProc (HWND hDlg,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
static char sztmp[129];
static int Items[255];
static int RealItems[255];
static unsigned nCount;
static unsigned nRealCount;
static int nCurrClass;
static int nCurrReq;
static int nCurrArch;
static BOOL WeightIsValid;
static BOOL RateIsValid;
static HBRUSH hNormBrush, hSelBrush, hBrush;
case WM_INITDIALOG:
WeightIsValid = TRUE;
RateIsValid = TRUE;
CheckDlgButton (hDlg, ID_TPT_EXTRDEM, FALSE);
SendDlgItemMessage (hDlg, ID_TPT_CLASSLIST, LB_SETHORIZONTALEXTENT,
, 0l);
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST, LB_SETHORIZONTALEXTENT,
, 0L);
SendDlgItemMessage (hDlg, ID_TPT_CHARLIST, LB_SETHORIZONTALEXTENT,
, 0l);
for (int nI = 0; nI < Demands->GetCount (); nI++)
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_ADDSTRING,
, (LONG)Demands->GetReqName (nI, sztmp));
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_ADDSTRING,
, (LONG)"");
if (!strcmp (CurrentProject->ProjectTask, "Qualimetric"))
{
EnableWindow (GetDlgItem (hDlg, ID_TPT_CLASSES), FALSE);
EnableWindow (GetDlgItem (hDlg, ID_TPT_CLASSLIST), FALSE);
nCurrClass = 0;
}
else
{
for (int nI = 0; nI < NumOfClasses; nI++)
SendDlgItemMessage (hDlg, ID_TPT_CLASSLIST,
LB_ADDSTRING,
, (LONG)Classes[nI]);
SendDlgItemMessage (hDlg, ID_TPT_CLASSLIST,
LB_SETCURSEL, 0, 0l);
}
if (!Records->GetSTC())
{
char szRCSTR [100];
LoadString (hinstResource, STR18,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg, szRCSTR,
NULL,
MB_OK | MB_ICONEXCLAMATION);
EndDialog (hDlg, FALSE);
break;
}
Records->ReleaseSTC();
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST, LB_SETCURSEL, 0, 0L);
SendMessage (hDlg, WM_COMMAND, ID_TPT_DEMLIST, ((LONG) LBN_SELCHANGE) << 16);
nCurrReq = 0;
nCurrClass = 0;
nCurrArch = 0;
hSelBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
hNormBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
break;
case WM_MEASUREITEM:
MEASUREITEMSTRUCT *mis = (LPMEASUREITEMSTRUCT) lParam;
switch (mis->CtlID)
{
case ID_TPT_ARCHLIST:
mis = (MEASUREITEMSTRUCT *) lParam;
mis->itemHeight = 14;
break;
default: return FALSE;
}
break;
case WM_DRAWITEM:
DRAWITEMSTRUCT *disCtl = (LPDRAWITEMSTRUCT) lParam;
COLORREF crColor, crColor1;
static char *szbuf1;
switch (disCtl->CtlID)
{
case ID_TPT_ARCHLIST:
disCtl = (DRAWITEMSTRUCT *)lParam;
if (Demands->GetArcQuantity (nCurrReq) < 1)
break;
if (disCtl->itemState & ODS_SELECTED)
{
hBrush = hSelBrush;
SetBkColor (disCtl->hDC,GetSysColor(COLOR_HIGHLIGHT));
crColor = GetSysColor (COLOR_HIGHLIGHTTEXT);
crColor1 = GetSysColor (COLOR_HIGHLIGHTTEXT);
}
else
{
hBrush = hNormBrush;
SetBkColor (disCtl->hDC, GetSysColor(COLOR_WINDOW));
crColor = GetSysColor (COLOR_WINDOWTEXT);
crColor1 = RGB (0, 0, 255);
}
FillRect (disCtl->hDC, &(disCtl->rcItem), hBrush);
SetTextColor (disCtl->hDC, crColor);
char szbuf[129];
SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST, LB_GETTEXT,
disCtl->itemID, (LONG) szbuf);
strtok (szbuf, "\3");
WORD wWidht = LOWORD (GetTextExtent (disCtl->hDC, szbuf,
strlen (szbuf)));
disCtl->rcItem.right = disCtl->rcItem.right - 40;
ExtTextOut (disCtl->hDC, disCtl->rcItem.left,
disCtl->rcItem.top, ETO_CLIPPED,
&(disCtl->rcItem), szbuf,
strlen (szbuf), NULL);
szbuf1 = strtok (NULL, "\3");
if (szbuf1 != NULL)
strcpy (szbuf, szbuf1);
else
strcpy (szbuf, "");
SetTextColor (disCtl->hDC, crColor1);
disCtl->rcItem.right = disCtl->rcItem.right + 40;
ExtTextOut (disCtl->hDC, disCtl->rcItem.right - 35,
disCtl->rcItem.top, ETO_CLIPPED,
&(disCtl->rcItem), szbuf,
strlen (szbuf), NULL);
if (disCtl->itemState & ODS_FOCUS)
DrawFocusRect(disCtl->hDC, &(disCtl->rcItem));
break;
default: return FALSE;
}
break;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
if (!WeightIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_WEIGHT));
break;
}
if (!RateIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_ARCHRATE));
break;
}
int AllArc = 0;
for (int ind = 0; ind < Demands->GetCount (); ind++)
AllArc += Demands->GetArcQuantity (ind);
if (!AllArc)
{
char szRCSTR [100];
LoadString (hinstResource, STR61,szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg, szRCSTR,
NULL,
MB_OK | MB_ICONEXCLAMATION);
break;
}
AdjustDemands ();
DeleteObject (hSelBrush);
DeleteObject (hNormBrush);
EndDialog (hDlg, TRUE);
break;
case IDCANCEL:
DeleteObject (hSelBrush);
DeleteObject (hNormBrush);
EndDialog (hDlg, FALSE);
break;
case ID_TPT_DEFAULT:
if (!WeightIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_WEIGHT));
break;
}
if (!RateIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_ARCHRATE));
break;
}
Records->GetSTC ();
Demands->Clear ();
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_RESETCONTENT, 0, 0l);
SendDlgItemMessage (hDlg, ID_TPT_CLASSLIST,
LB_RESETCONTENT, 0, 0l);
for (int i = Records->GetRegFields(), j = 0; i < Records->GetCount (); i++, j++)
{
(*Records)[i];
Demands->AddRequest (Records->GetFieldName());
Demands->AddArc (j, i);
}
SendMessage (hDlg, WM_INITDIALOG, 0, 0l);
Records->ReleaseSTC ();
break;
case ID_TPT_EXTRDEM:
CheckDlgButton (hDlg, ID_TPT_EXTRDEM,
!IsDlgButtonChecked (hDlg, ID_TPT_EXTRDEM));
Demands->SetExtremal (nCurrReq, nCurrClass,
IsDlgButtonChecked(hDlg, ID_TPT_EXTRDEM));
break;
case ID_TPT_ADD:
if (!WeightIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_WEIGHT));
break;
}
if (!RateIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_ARCHRATE));
break;
}
char sztmp[129];
int n;
int nCurrPos = SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_GETCURSEL, 0, 0L);
GetDlgItemText (hDlg, ID_TPT_DEMNAME, sztmp, 128);
if (!strcmp (sztmp, "")) break;
if ((n = SendDlgItemMessage(hDlg, ID_TPT_DEMLIST,
LB_FINDSTRINGEXACT, -1,
(LONG) sztmp)) != LB_ERR)
{
break;
}
AddDemand (GetDlgItem (hDlg, ID_TPT_DEMLIST),
nCurrPos,
GetDlgItem (hDlg, ID_TPT_DEMNAME),
GetDlgItem (hDlg, ID_TPT_EXTRDEM));
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_SETCURSEL, nCurrPos + 1, 0l);
break;
case ID_TPT_DELETE:
nCurrPos = SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_GETCURSEL, 0, 0L);
DeleteDemand (GetDlgItem (hDlg, ID_TPT_DEMLIST),
nCurrPos);
break;
case ID_TPT_ATTACH:
if (!WeightIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_WEIGHT));
break;
}
if (!RateIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_ARCHRATE));
break;
}
Records->GetSTC();
n = SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_GETSELITEMS, 254, (LONG)Items);
for (i = 0; i < n; i++)
{
SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_GETTEXT, Items[i], (LONG)sztmp);
int nNum = Records->GetNumberByName (sztmp);
Demands->AddArc (nCurrReq, nNum);
SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST,
LB_ADDSTRING, 0, (LONG) sztmp);
}
for (i = 0; i < n; i++)
SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_DELETESTRING, Items[i] - i, 0l);
Records->ReleaseSTC();
break;
case ID_TPT_DETACH:
if (!WeightIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_WEIGHT));
break;
}
if (!RateIsValid)
{
SetFocus (GetDlgItem (hDlg, ID_TPT_ARCHRATE));
break;
}
Records->GetSTC ();
if ((n = SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST,
LB_GETCURSEL, 0, 0l)) !=LB_ERR)
if (Demands->GetArcQuantity (nCurrReq) != 0)
{
int nNum = Demands->GetArcField (nCurrReq, n);
Demands->DeleteArc (nCurrReq, n);
int k = SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_GETCOUNT, 0, 0l);
for (int j = 0; j < k; j++)
{
SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_GETTEXT, j, (LONG) sztmp);
strtok (sztmp, "\3");
if (Records->GetNumberByName(sztmp) > nNum)
break;
}
(*Records)[nNum];
SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST,
LB_DELETESTRING, n, 0l);
SendDlgItemMessage (hDlg, ID_TPT_CHARLIST,
LB_INSERTSTRING, j,
(LONG) Records->GetFieldName());
}
Records->ReleaseSTC();
break;
case ID_TPT_DEMLIST:
switch (HIWORD(lParam))
{
case LBN_SELCHANGE:
nCurrReq = SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_GETCURSEL, 0, 0L);
UpdateReq (hDlg, nCurrReq, nCurrClass, nCurrArch = 0,
GetDlgItem (hDlg, ID_TPT_WEIGHT),
GetDlgItem (hDlg, ID_TPT_ARCHRATE),
GetDlgItem (hDlg, ID_TPT_DEMNAME),
ID_TPT_EXTRDEM,
GetDlgItem (hDlg, ID_TPT_ARCHLIST),
GetDlgItem (hDlg, ID_TPT_CHARLIST));
break;
default: return FALSE;
}
break;
case ID_TPT_DEMNAME:
switch (HIWORD(lParam))
{
char sz1[129];
char sz2[129];
int n;
case EN_CHANGE:
GetDlgItemText (hDlg, ID_TPT_DEMNAME, sz1, 128);
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST, LB_GETTEXT,
SendDlgItemMessage (hDlg,
ID_TPT_DEMLIST,
LB_GETCURSEL,
,0l),
(LONG) sz2);
if (strcmp (sz1, sz2))
EnableWindow (GetDlgItem (hDlg, ID_TPT_DELETE), FALSE);
else
EnableWindow (GetDlgItem (hDlg, ID_TPT_DELETE), TRUE);
break;
case EN_KILLFOCUS:
GetDlgItemText (hDlg, ID_TPT_DEMNAME, sz1, 128);
if (!strcmp (sz1, "")) break;
if ((n = SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_FINDSTRINGEXACT, -1,
(LPARAM) sz1)) != LB_ERR)
{
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_SETCURSEL, n, 0l);
SendMessage (hDlg, WM_COMMAND, ID_TPT_DEMLIST,
((LONG) LBN_SELCHANGE) << 16);
}
else
{
SendMessage (hDlg, WM_COMMAND, ID_TPT_ADD, 0l);
SendDlgItemMessage (hDlg, ID_TPT_DEMLIST,
LB_SETCURSEL,
SendDlgItemMessage (hDlg,
ID_TPT_DEMLIST,
LB_GETCURSEL,
, 0l) - 1,
l);
SendMessage (hDlg, WM_COMMAND, ID_TPT_DEMLIST,
((LONG) LBN_SELCHANGE) << 16);
}
break;
default: return FALSE;
}
break;
case ID_TPT_CLASSLIST:
switch (HIWORD(lParam))
{
nCurrClass = SendDlgItemMessage(hDlg, ID_TPT_CLASSLIST,
LB_GETCURSEL, 0, 0L);
UpdateAll (hDlg, nCurrReq, nCurrClass, nCurrArch,
GetDlgItem (hDlg, ID_TPT_WEIGHT),
GetDlgItem (hDlg, ID_TPT_ARCHRATE),
GetDlgItem (hDlg, ID_TPT_DEMNAME),
ID_TPT_EXTRDEM);
break;
default: return FALSE;
}
break;
case ID_TPT_ARCHLIST:
switch (HIWORD(lParam))
{
case LBN_SELCHANGE:
if (Demands->GetArcQuantity (nCurrReq) == 0)
break;
nCurrArch = SendDlgItemMessage(hDlg, ID_TPT_ARCHLIST,
LB_GETCURSEL, 0, 0L);
UpdateArch (nCurrReq, nCurrClass, nCurrArch,
GetDlgItem (hDlg,
ID_TPT_ARCHRATE));
break;
default: return FALSE;
}
break;
case ID_TPT_WEIGHT:
switch (HIWORD(lParam))
{
case EN_KILLFOCUS:
GetDlgItemText (hDlg, ID_TPT_WEIGHT, sztmp, 21);
char *end;
float wght = strtod (sztmp, &end);
if (*end != '\0')
{
WeightIsValid = FALSE;
break;
}
WeightIsValid = TRUE;
Demands->SetWeight (nCurrReq, nCurrClass, wght);
break;
default: return FALSE;
}
break;
case ID_TPT_ARCHRATE:
switch (HIWORD(lParam))
{
case EN_KILLFOCUS:
char sztmp2[129];
char sztmp1[129];
if (SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST, LB_GETTEXT,
nCurrArch, (LONG) sztmp2) == LB_ERR)
break;
if (!strcmp (sztmp2, "")) break;
strtok (sztmp2, "\3");
GetDlgItemText (hDlg, ID_TPT_ARCHRATE, sztmp, 21);
if (atof (sztmp) < 0) break;
char *end;
float wght = strtod (sztmp, &end);
if (*end != '\0')
{
RateIsValid = FALSE;
break;
}
RateIsValid = TRUE;
Demands->SetArcWeight
(nCurrReq, nCurrClass, nCurrArch,
wght);
sprintf (sztmp1, "%s\3%.2f", sztmp2, atof(sztmp));
SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST,
LB_DELETESTRING, nCurrArch, 0l);
SendDlgItemMessage (hDlg, ID_TPT_ARCHLIST,
LB_INSERTSTRING, nCurrArch,
(LONG) sztmp1);
break;
default: return FALSE;
}
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}
BOOL FAR PASCAL _export ClassesDlgProc
(HWND hDlg, UINT msg, WPARAM wParam, LONG lParam) (void) (Project.h Project.cpp)
BOOL FAR PASCAL _export ClassesDlgProc (HWND hDlg,
unsigned message,
WORD wParam,
LONG lParam)
{
TClass CurClass;
switch (message)
{
case WM_INITDIALOG:
for (int nI = 0; nI < clClasses->GetCount (); nI++)
{
(*clClasses)[nI];
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_ADDSTRING, 0, (LONG) clClasses->GetName());
}
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_ADDSTRING, 0, (LONG) "");
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_SETCURSEL, 0, 0L);
SendMessage (hDlg, WM_COMMAND, ID_CLAS_LISTBOX,
((LONG) LBN_SELCHANGE) << 16);
break;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
if (SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETCOUNT, 0, 0l) < 3)
{
char szRCSTR [100];
LoadString (hinstResource, STR34, szRCSTR, sizeof (szRCSTR));
MessageBox (hDlg,szRCSTR,
NULL,
MB_ICONEXCLAMATION | MB_OK);
break;
}
EndDialog (hDlg, TRUE);
break;
case IDCANCEL:
EndDialog (hDlg, FALSE);
break;
case ID_CLAS_ADD:
char sztmp[51];
char sz1[51];
int n;
GetDlgItemText (hDlg, ID_CLAS_CLASSNAME, sztmp, 50);
if (!strcmp (sztmp, "")) break;
if ((n = SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_FINDSTRINGEXACT, -1, (LONG)sztmp))
!= LB_ERR)
{
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_SETCURSEL,
n, 0l);
SendMessage (hDlg, WM_COMMAND, ID_CLAS_LISTBOX,
((LONG) LBN_SELCHANGE) << 16);
break;
}
n = SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETCURSEL, 0, 0l);
strcpy (CurClass.Name, sztmp);
CurClass.Number = -1;
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETTEXT, n, (LONG) sz1);
if (!strcmp(sz1, ""))
clClasses->AddClass (&CurClass);
else
{
(*clClasses)[n];
clClasses->Insert(&CurClass);
}
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_INSERTSTRING, n, (LONG) sztmp);
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_SETCURSEL,
n + 1, 0l);
SendMessage (hDlg, WM_COMMAND, ID_CLAS_LISTBOX,
((LONG) LBN_SELCHANGE) << 16);
break;
case ID_CLAS_DELETE:
n = SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETCURSEL, 0, 0l);
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETTEXT, n, (LONG)sz1);
if (!strcmp(sz1, ""))
break;
(*clClasses)[n];
clClasses->Delete();
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_DELETESTRING, n, (LONG) sztmp);
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_SETCURSEL,
n , 0l);
SendMessage (hDlg, WM_COMMAND, ID_CLAS_LISTBOX,
((LONG) LBN_SELCHANGE) << 16);
break;
case ID_CLAS_EDIT:
SendMessage (hDlg, WM_COMMAND, ID_CLAS_DELETE, 0L);
SendMessage (hDlg, WM_COMMAND, ID_CLAS_ADD, 0L);
break;
case ID_CLAS_LISTBOX:
switch (HIWORD(lParam))
{
case LBN_SELCHANGE:
SendDlgItemMessage (hDlg, ID_CLAS_LISTBOX,
LB_GETTEXT,
SendDlgItemMessage (hDlg,
ID_CLAS_LISTBOX,
LB_GETCURSEL,
, 0l),
(LONG) sztmp);
SetDlgItemText (hDlg, ID_CLAS_CLASSNAME, sztmp);
break;
default :return FALSE;
}
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}