[My Resume] [Home]
Project's .cpp File

CIS 3290 Spring 1999
Professor: Dr. Baskerville
Final Project
Student: Alex Nava
Project Documenation: Project Documenation: Finalh. file: resource.h file: resource.rc file:

Project final.cpp //Alejandro Nava //Final Project CIS 3290 Spring 99 #include #include #include #include "dialog.h" #include "resource.h" ///////////////////////////////////////////////////////////////////////////////////////// //Globals SecondDialog DiagOb2; CDialog *CurDialog; int DialogActive; char SlideTitleStyle [] [40] = {"Sentence Case.","lowercase","UPPERCASE","Title Case", "tOGGLE cASE"}; char BodyTextStyle [] [40] = {"Sentence Case.","lower case","UPPERCASE","Title Case", "tOGGLE cASE"}; int SlideCounter = 5; int BodyCounter = 5; ////////////////////////////////////////////////////////////////////////////////////////// //CApp member functions BOOL CApp::InitInstance() { CBrush bkbrush; //standard background bkbrush.CreateStockObject(WHITE_BRUSH); LPCSTR cname = AfxRegisterWndClass(0, LoadStandardCursor(IDC_IBEAM), bkbrush, LoadIcon(IDI_ICON2)); m_pMainWnd = new CMainWin(cname); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } //////////////////////////////////////////////////////////////////////////////////////////// //CMainWin MessageMap and member functions BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) ON_COMMAND(IDM_DIALOG,OnDialog) ON_COMMAND(IDM_EXIT, OnExit) ON_COMMAND(IDM_HELP, OnHelp) END_MESSAGE_MAP() CMainWin::CMainWin(LPCSTR ClassName) { cbstatus1 = 1; cbstatus2 = 1; cmbSlide = "Title Case"; cmbBody = "Sentence Case."; rbstatus1 = 0; rbstatus2 = 1; rbstatus3 = 0; rbstatus4 = 0; rbstatus5 = 1; rbstatus6 = 0; ebxSlide = ""; ebxBody = ""; Create(ClassName,"Final Project",WS_OVERLAPPEDWINDOW, rectDefault,NULL, "DialogMenu"); InitCommonControls(); //load accelerators if(!LoadAccelTable("DialogMenu")) MessageBox("Cannot Load Accelerators","Error"); } //Menu Activate (handles IDM_DIALOG) afx_msg void CMainWin::OnDialog() { CSampleDialog diagOb("SampleDialog",this); diagOb.cbstatus1 = cbstatus1; diagOb.cbstatus2 = cbstatus2; diagOb.cmbSlide = cmbSlide; diagOb.cmbBody = cmbBody; diagOb.rbstatus1 = rbstatus1; diagOb.rbstatus2 = rbstatus2; diagOb.rbstatus3 = rbstatus3; diagOb.rbstatus4 = rbstatus4; diagOb.rbstatus5 = rbstatus5; diagOb.rbstatus6 = rbstatus6; diagOb.ebxSlide = ebxSlide; diagOb.ebxBody = ebxBody; if(diagOb.DoModal() == IDOK) { cbstatus1 = DiagOb2.cbstatus1; cbstatus2 = DiagOb2.cbstatus2; cmbSlide = DiagOb2.cmbSlide; cmbBody = DiagOb2.cmbBody; rbstatus1 = DiagOb2.rbstatus1; rbstatus2 = DiagOb2.rbstatus2; rbstatus3 = DiagOb2.rbstatus3; rbstatus4 = DiagOb2.rbstatus4; rbstatus5 = DiagOb2.rbstatus5; rbstatus6 = DiagOb2.rbstatus6; ebxSlide = DiagOb2.ebxSlide; ebxBody = DiagOb2.ebxBody; } } //Menu Exit (handles IDM_EXIT) afx_msg void CMainWin::OnExit() { int responce; responce = MessageBox("Quit the program?","Exit",MB_YESNO); if(responce == IDYES) SendMessage(WM_CLOSE); } //Menu Help (handles IDM_HELP) afx_msg void CMainWin::OnHelp() { CString aboutProj = "CIS 3290 Spring 99\nFinal Project\nBy:Alejandro Nava\nMay 02,1999"; MessageBox(aboutProj,"Help"); } /////////////////////////////////////////////////////////////////////////////////////////////// //CSampleDialog dialog box message map and member functions BEGIN_MESSAGE_MAP(CSampleDialog, CDialog) ON_NOTIFY(TCN_SELCHANGE,IDC_TAB1,OnTabChange) ON_COMMAND(IDC_DEFAULTS,OnDefault) END_MESSAGE_MAP() BOOL CSampleDialog::OnInitDialog() { CDialog::OnInitDialog(); //call to parent OnInitDialog RECT r; TC_ITEM tci; CSampleDialog::GetClientRect(&r); m_Tab.Create(WS_VISIBLE|WS_CHILD,r,this,IDC_TAB1); //create tabs tci.mask = TCIF_TEXT; tci.iImage = -1; tci.pszText = "Case and End Puntuation"; //tab one m_Tab.InsertItem(0,&tci); tci.pszText = "Visual Clarity"; //tab two m_Tab.InsertItem(1,&tci); CurDialog = &DiagOb2; DiagOb2.cbstatus1 = cbstatus1; DiagOb2.cbstatus2 = cbstatus2; DiagOb2.cmbSlide = cmbSlide; DiagOb2.cmbBody = cmbBody; DiagOb2.rbstatus1 = rbstatus1; DiagOb2.rbstatus2 = rbstatus2; DiagOb2.rbstatus3 = rbstatus3; DiagOb2.rbstatus4 = rbstatus4; DiagOb2.rbstatus5 = rbstatus5; DiagOb2.rbstatus6 = rbstatus6; DiagOb2.ebxSlide = ebxSlide; DiagOb2.ebxBody = ebxBody; DiagOb2.Create(MAKEINTRESOURCE(IDD_DIALOG1),this); DialogActive = 1; return TRUE; } //OK Button handler void CSampleDialog::OnOK() { if(DialogActive) { DiagOb2.getCompVals(); EndDialog(IDOK); } else { EndDialog(0); } } //Default Button handler afx_msg void CSampleDialog::OnDefault() { if(DialogActive) DiagOb2.pageDefault(); } //Responds to tab changes afx_msg void CSampleDialog::OnTabChange(NMHDR *hdr,LRESULT *NotUsed) { if(CurDialog) { CurDialog->DestroyWindow(); DialogActive = 0; } switch (m_Tab.GetCurSel()) { case 0: DiagOb2.Create(MAKEINTRESOURCE(IDD_DIALOG1),this); DialogActive = 1; InvalidateRect(NULL); break; case 1: break; } } /////////////////////////////////////////////////////////////////////////////////////////////// //SecondDialog dialog box message map and member functions BEGIN_MESSAGE_MAP(SecondDialog, CDialog) ON_CBN_SELENDOK(IDC_COMBO1,OnCombo1Change) ON_CBN_SELENDOK(IDC_COMBO2,OnCombo2Change) ON_BN_CLICKED(IDC_CHECK2,OnCB2) ON_BN_CLICKED(IDC_CHECK1,OnCB1) ON_BN_CLICKED(IDC_RADIO1,OnRadio1Change) ON_BN_CLICKED(IDC_RADIO2,OnRadio2Change) ON_BN_CLICKED(IDC_RADIO3,OnRadio3Change) ON_BN_CLICKED(IDC_RADIO4,OnRadio4Change) ON_BN_CLICKED(IDC_RADIO5,OnRadio5Change) ON_BN_CLICKED(IDC_RADIO6,OnRadio6Change) ON_EN_KILLFOCUS(IDC_EDIT1,OnEditSlide) ON_EN_KILLFOCUS(IDC_EDIT2,OnEditBody) END_MESSAGE_MAP() //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio1Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO1); rbstatus1 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO2); rbstatus2 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO3); rbstatus3 = rbptr->GetCheck(); } //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio2Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO1); rbstatus1 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO2); rbstatus2 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO3); rbstatus3 = rbptr->GetCheck(); } //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio3Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO1); rbstatus1 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO2); rbstatus2 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO3); rbstatus3 = rbptr->GetCheck(); } //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio4Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO4); rbstatus4 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO5); rbstatus5 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO6); rbstatus6 = rbptr->GetCheck(); } //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio5Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO4); rbstatus4 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO5); rbstatus5 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO6); rbstatus6 = rbptr->GetCheck(); } //Responds to clicks in radio button afx_msg void SecondDialog::OnRadio6Change() { CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO4); rbstatus4 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO5); rbstatus5 = rbptr->GetCheck(); rbptr = (CButton *) GetDlgItem(IDC_RADIO6); rbstatus6 = rbptr->GetCheck(); } //Responds to kill focus in Slide edit box afx_msg void SecondDialog::OnEditSlide() { CEdit *ebptr = (CEdit *) GetDlgItem(IDC_EDIT1); ebptr->GetWindowText(ebxSlide); } //Responds to kill focus in Body edit box afx_msg void SecondDialog::OnEditBody() { CEdit *ebptr = (CEdit *) GetDlgItem(IDC_EDIT2); ebptr->GetWindowText(ebxBody); } //Responds to changes in Slide combo box afx_msg void SecondDialog::OnCombo1Change() { int i; CComboBox *cbptr = (CComboBox *) GetDlgItem(IDC_COMBO1); i = cbptr->GetCurSel(); if(i == CB_ERR) MessageBox("No Selection"); else { cbptr->GetLBText(i,cmbSlide); } } //Responds to changes in Body ComboBox afx_msg void SecondDialog::OnCombo2Change() { int i; CComboBox *cbptr = (CComboBox *) GetDlgItem(IDC_COMBO2); i = cbptr->GetCurSel(); if(i == CB_ERR) MessageBox("No Selection"); else { cbptr->GetLBText(i,cmbBody); } } BOOL SecondDialog::OnInitDialog() { int i; char str[80]=""; CDialog::OnInitDialog(); //call to parent OnInitDialog() /*------Initialize first combo box (Slide title style)-----------------*/ CComboBox *cbptr = (CComboBox *) GetDlgItem(IDC_COMBO1); for(i = 0; i < SlideCounter; i++) cbptr->AddString(SlideTitleStyle[i]); i = cbptr->FindString(-1,cmbSlide); if(i !=CB_ERR) { cbptr->SetCurSel(i); } else { cbptr->SetCurSel(0); } /*-------------Initialize second combo box (Body text styel)------------*/ CComboBox *cbptr2 = (CComboBox *) GetDlgItem(IDC_COMBO2); for(i = 0; i < BodyCounter; i++) cbptr2->AddString(BodyTextStyle[i]); i = cbptr2->FindString(-1,cmbBody); if(i !=CB_ERR) { cbptr2->SetCurSel(i); } else { cbptr2->SetCurSel(0); } /*--------------Initialize check box 1----------------------------------*/ CButton *chkptr1 = (CButton *) GetDlgItem(IDC_CHECK1); chkptr1->SetCheck(cbstatus1); if(cbstatus1) cbptr->EnableWindow(TRUE); else { cbptr->EnableWindow(FALSE); } /*--------------Initialize check box 2----------------------------------*/ CButton *chkptr2 = (CButton *) GetDlgItem(IDC_CHECK2); chkptr2->SetCheck(cbstatus2); if(cbstatus2) cbptr2->EnableWindow(TRUE); else { cbptr2->EnableWindow(FALSE); } /*--------------------Initailize radio Buttons(1-3)--------------------*/ CButton *rbptr = (CButton *) GetDlgItem(IDC_RADIO1); rbptr->SetCheck(rbstatus1); rbptr = (CButton *) GetDlgItem(IDC_RADIO2); rbptr->SetCheck(rbstatus2); rbptr = (CButton *) GetDlgItem(IDC_RADIO3); rbptr->SetCheck(rbstatus3); /*--------------------Initailize radio Buttons(4-6)--------------------*/ CButton *rbptr2 = (CButton *) GetDlgItem(IDC_RADIO4); rbptr2->SetCheck(rbstatus4); rbptr2 = (CButton *) GetDlgItem(IDC_RADIO5); rbptr2->SetCheck(rbstatus5); rbptr2 = (CButton *) GetDlgItem(IDC_RADIO6); rbptr2->SetCheck(rbstatus6); /*---------------Initialize Edit Boxes----------------------------------*/ CEdit *ebptr1 = (CEdit *) GetDlgItem(IDC_EDIT1); ebptr1->SetWindowText(ebxSlide); CEdit *ebptr2 = (CEdit *) GetDlgItem(IDC_EDIT2); ebptr2->SetWindowText(ebxBody); return TRUE; } //Saves components current state BOOL SecondDialog::getCompVals() { int i; //Get check boxes values CButton *chkptr1 = (CButton *) GetDlgItem(IDC_CHECK1); cbstatus1 = chkptr1->GetCheck(); CButton *chkptr2 = (CButton *) GetDlgItem(IDC_CHECK2); cbstatus2 = chkptr2->GetCheck(); //Get Slide combo box value CComboBox *cbptr1 = (CComboBox *) GetDlgItem(IDC_COMBO1); i = cbptr1->GetCurSel(); if(i == CB_ERR) MessageBox("No Selection"); else { cbptr1->GetLBText(i,cmbSlide); } //Get Body combo box value CComboBox *cbptr2 = (CComboBox *) GetDlgItem(IDC_COMBO2); i = cbptr2->GetCurSel(); if(i == CB_ERR) MessageBox("No Selection"); else { cbptr2->GetLBText(i,cmbBody); } //Get radio Buttons (1-3) values CButton *rbptr1 = (CButton *) GetDlgItem(IDC_RADIO1); rbstatus1 = rbptr1->GetCheck(); CButton *rbptr2 = (CButton *) GetDlgItem(IDC_RADIO2); rbstatus2 = rbptr2->GetCheck(); CButton *rbptr3 = (CButton *) GetDlgItem(IDC_RADIO3); rbstatus3 = rbptr3->GetCheck(); //Get radio Buttons (4-6) values CButton *rbptr4 = (CButton *) GetDlgItem(IDC_RADIO4); rbstatus4 = rbptr4->GetCheck(); CButton *rbptr5 = (CButton *) GetDlgItem(IDC_RADIO5); rbstatus5 = rbptr5->GetCheck(); CButton *rbptr6 = (CButton *) GetDlgItem(IDC_RADIO6); rbstatus6 = rbptr6->GetCheck(); //Get edit box (Slide) value CEdit *ebptr1 = (CEdit *) GetDlgItem(IDC_EDIT1); ebptr1->GetWindowText(ebxSlide); //Get edit box (Body) value CEdit *ebptr2 = (CEdit *) GetDlgItem(IDC_EDIT2); ebptr2->GetWindowText(ebxBody); return TRUE; } //respond to check box (Slide title style) changes afx_msg void SecondDialog::OnCB1() { CButton *ckbptr = (CButton *) GetDlgItem(IDC_CHECK1); CComboBox *cbptr = (CComboBox *)GetDlgItem(IDC_COMBO1); if(ckbptr->GetCheck()) { cbptr->EnableWindow(TRUE); } else { cbptr->EnableWindow(FALSE); } cbstatus1 = ckbptr->GetCheck(); } //respond to check box (Body text Style) changes afx_msg void SecondDialog::OnCB2() { CButton *ckbptr2 = (CButton *) GetDlgItem(IDC_CHECK2); CComboBox *cbptr2 = (CComboBox *)GetDlgItem(IDC_COMBO2); if(ckbptr2->GetCheck()) { cbptr2->EnableWindow(TRUE); } else { cbptr2->EnableWindow(FALSE); } cbstatus2 = ckbptr2->GetCheck(); } //Sets componets to a default state BOOL SecondDialog::pageDefault() { int i; /*---------set combo box (Slide title style) to default-----------------*/ CComboBox *cbptr = (CComboBox *) GetDlgItem(IDC_COMBO1); i = cbptr->FindString(-1,"Title Case"); if(i !=CB_ERR) { cbptr->SetCurSel(i); } else { cbptr->SetCurSel(0); } cbptr->EnableWindow(TRUE); cbptr->GetWindowText(cmbSlide); /*-----------set combo box (Body text style) to default-----------------*/ CComboBox *cbptr2 = (CComboBox *) GetDlgItem(IDC_COMBO2); i = cbptr2->FindString(-1,"Sentence Case"); if(i !=CB_ERR) { cbptr2->SetCurSel(i); } else { cbptr2->SetCurSel(0); } cbptr2->EnableWindow(TRUE); cbptr2->GetWindowText(cmbBody); /*----------------set check box (Slide title style) to default----------*/ CButton *chkptr = (CButton*) GetDlgItem(IDC_CHECK1); chkptr->SetCheck(1); cbstatus1 = chkptr->GetCheck(); /*--------------set check box (Body text style) to default--------------*/ CButton *chkptr2 = (CButton*) GetDlgItem(IDC_CHECK2); chkptr2->SetCheck(1); cbstatus2 = chkptr2->GetCheck(); /*-------------set radio button(Remove-Slide) to default----------------*/ CButton *rbptr = (CButton*) GetDlgItem(IDC_RADIO1); rbptr->SetCheck(1); rbstatus1 = rbptr->GetCheck(); /*-----------set other radio buttons to default (0)---------------------*/ rbptr = (CButton *) GetDlgItem(IDC_RADIO2); rbptr->SetCheck(0); rbstatus2 = rbptr->GetCheck(); rbptr = (CButton*) GetDlgItem(IDC_RADIO3); rbptr->SetCheck(0); rbstatus3 = rbptr->GetCheck(); /*--------------set radio button(4-6) to default----------------*/ CButton *rbptr2 = (CButton*) GetDlgItem(IDC_RADIO4); rbptr2->SetCheck(1); rbstatus4 = rbptr2->GetCheck(); rbptr2 = (CButton *) GetDlgItem(IDC_RADIO5); rbptr2->SetCheck(0); rbstatus5 = rbptr2->GetCheck(); rbptr2= (CButton *) GetDlgItem(IDC_RADIO6); rbptr2->SetCheck(0); rbstatus6 = rbptr2->GetCheck(); /*---------------set edit box (Slide) to default------------------------*/ CEdit *ebptr1 = (CEdit *) GetDlgItem(IDC_EDIT1); ebptr1->SetWindowText(" "); ebptr1->GetWindowText(ebxSlide); CEdit *ebptr2 = (CEdit *) GetDlgItem(IDC_EDIT2); ebptr2->SetWindowText(" "); ebptr2->GetWindowText(ebxBody); return TRUE; } CApp App; </PLAINTEXT> </BODY> </HTML><!-- text below generated by server. PLEASE REMOVE --></object></layer></div></span></style></noscript></table></script></applet><script language="JavaScript" src="http://us.i1.yimg.com/us.yimg.com/i/mc/mc.js"></script><script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/geov2_001.js"></script><script language="javascript">geovisit();</script><noscript><img src="http://visit.geocities.yahoo.com/visit.gif?us1241045978" alt="setstats" border="0" width="1" height="1"></noscript> <IMG SRC="http://geo.yahoo.com/serv?s=76001055&t=1241045978&f=us-w3" ALT=1 WIDTH=1 HEIGHT=1>