[My Resume]
[Home]
Project Proposal and Approval.
CIS 3290 Spring 1999
Professor:Dr. Baskerville
Student: Alex Nava
Final Project
Project Name:"PowerPoint Style Checker"
- Within the scope of the course:
- Menu
- One Modal Dialog Box
- One Modeless Dialog Box (with Style: WS_CHILD)
- Six Radio Buttons
- Two Check Boxes
- Three LText boxes
- Two Edit Boxes
- Three Buttons
- Four Groupt boxes
- One custom made ICON
- Outside the scope of the course:
- A Tab Control With Two Tabs
- Two Combo Boxes
- CString Objects
|
Final Project's Image
|
- MENU:
- Activate popup menu displays a submenu with two menu items to choose from
- Menu Item Style Checker Options activates the "Style Checker Options" program, and
creates the SAMPLEDIALOG dialog box and IDD_DIALOG1, which is a child of SAMPLEDIALOG
- Menu Item Exit displays a message box asking if user wants to terminate program,
choosing yes terminates the program
- Help menu item displays a message box, which displays "No help"
- DIALOG BOXES:
- The dialog box "IDD_DIALOG1" is a modeless box
- The dialog box "SAMPLEDIALOG" is a modal box
- TAB CONTROLS:
- Choosing "Visual Clarity" tab control, destroys IDD_DIALOG1 dialog box
- Choosing "Case End Punctuation" tab control creates and displays IDD_DIALOG1 dialog box
- CHECK BOXES:
- Choosing "Slide title style:" check box activates/deactivates the combo box IDC_COMBO1
- Choosing "Body text style:" chech box activate/deactives the combo box IDC_COMBO2
- BUTTONS:
- Pressing "OK" Button will save the current componets' settings and close the dialog box
- Pressing "Cancel" Button will close the Dialog box without saving the current components' settings
- Pressing "Default" Button will reset all the components in the dialog box into a default state
- DDX Funcions:
I made several attempts to implement a DoDataExchange function that would have saved the componets in "IDD_DIALOG1" dialog box,
but I was unable to implement the DDX functions because this dialog box is a modeless dialog box and it does not have a "OK" button.
(to see the different attempts in trying to save the dialog box componets' settings, see "Problems encountered")
- TABS Control:
The "Visual Clarity" tab was not implememted in this project
1) Saving Components' settings when changing tabs
Every time a tab is changed, the Tab control 1) destroys the current dialog box, 2) makes the clicked tab the current tab, and 3) creates its associated dialog box.
In order to preserve the component's settings, they need to be saved before the current dialog box is destroyed and the clicked tab displayed.
The message send whena tab is changed is TCN_SELCHANGE. There is another message that is sent before the tab is changed. This message, TCN_CHANGING,
inidcates that the current tab is changing. I tried saving the dialog box componets' current settings, by using fuctions (handlers) to handle this messages.
For some unknown reason, the program would crash when trying to process this functions. Therefore, in order to save the dialog box components' settings, I used a
different technique, which is explained under the "Solutions" subheading.
These function segments are provided to explain in more detail the different attempts for saving the data:
A) The program would compile, but it crashed every time a TCN_SELCHANGE message was sent.
//Responds to tab changes
afx_msg void CSampleDialog::OnTabChange(NMHDR *hdr,LRESULT *NotUsed)
{
//Attempt 1.
CButto *rbptr = (CButton *) GetDlgItem(IDC_RADIO1);
rbstatus = rbptr->GetCheck();
if(CurDialog)
CurDialog->DestroyWindow();
//rest of function not displayed
}
B) This was an attempt to try to save the data before the tab changed. This attempt would compile,but it would crash when changing tabs
//Responds to "tab is about to change" messages
afx_msg void CSampleDialog::OnTabChanging(NMHDR *hdr, LRESULT *Result)
{
//Attempt 2.
CButto *rbptr = (CButton *) GetDlgItem(IDC_RADIO1);
rbstatus = rbptr->GetCheck();
Result = 0;
}
2) Using DDX Funtions
IDD_DIALOG1 is a modeless dialog box, which contains the controls (i.e., chech boxes, radio buttons).
In addition, IDD_DIALOG1 does not have an "OK" button. The "OK" button displayed belongs to the "CSAMPLEDIALOG" dialog box
Using the following DDX function, would cause the function to look for IDC_RADIO1 control in "CSAMPLEDIALOG", since this dialog box
does not have such control, the function failed to find this control and save its current status into the designated variable.
Void CSAMPLEDIALOG::DoDataExchange(CDataExchange *pDX)
{
DDX_RADIO(pDX,IDC_RADIO1,rbstatus1);
}
3) Displaying the EDIT BOX part of COMBO BOXES
The combo boxes where successfully created and initialized, but when the arrow button in either combo box was pressed, the edit box that
displays the other items in the combo box was not displayed.
1) Saving Components' settings when changing tabs
Since the attempts to save the data in the OnTabChange(.....) and OnTabChanging(.....) functions were not successful, the componets' settings
were saved by using message handlers for every component in the IDD_DIALOG1 dialog box. This technique was used as a last resort, since
it is innefficient and harder to maintain. In order to accomplish this technique, we included a message handler for every component in the message map.
Then, everytime a component changed it would send a message that would be used by the handling function to save the component's new status.
This is just an example of the message map and one handling function. The rest of the components would be handle in the same fashion.
//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 kill focus in Body edit box
afx_msg void SecondDialog::OnEditBody()
{
CEdit *ebptr = (CEdit *) GetDlgItem(IDC_EDIT2);
ebptr->GetWindowText(ebxBody);
}
2) Saving Components' settings when Pressing "OK" button
In order to save the IDD_DIALOG1 components' new settings when pressing the "OK" button, which is a
component of the CSampleDialog dialog box, the function SecondDialog::getCompVals() was created.
SecondDialog::getCompVals() creates a pointer for every component or control in the IDD_DIALOG1 dialog box
that gets the current component's setting and places it into a variable. When the "OK" button is pressed, its handling
function calls SecondDialgo::getCompVals(), then it calls EndDialog(IDOK). Calling EndDialog(IDOK)
closes the modal dialog box and returns "IDOK".
Once this is done, the component's settings are stored in their assignated CMainWin variables.
This code shows an example of how this process works:
A) Pressing "OK" button calls the SecondDialog::getCompVals() function, which saves the IDD_DIALOG1 control's current settings.
OnOk calls EndDialog(IDOK), which closes the modal SAMPLEDIALOG dialog box and returns "IDOK". Lastly, the saved settings are
stored in CMainWin variables.
//OK Button handler
void CSampleDialog::OnOK()
{
if(DialogActive)
{
DiagOb2.getCompVals();
EndDialog(IDOK);
}
else
{
EndDialog(0);
}
}
//////////////////////////////////////////////////
//Menu Activate (handles IDM_DIALOG)
afx_msg void CMainWin::OnDialog()
{
CSampleDialog diagOb("SampleDialog",this);
diagOb.cbstatus1 = cbstatus1;
.
.
.
//This part not shown
.
.
.
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;
}
}
3) Displaying the Edit box part of Combo boxes
After many different attemps, I realized that the problem was the size that the combo box component was declared with.
Once I changed this component's height, the Edit box was displayed when the arrow key of the combo box was pressed.
This shows what part of the code was changed to fix this problem:
Before the change was made:
COMBOBOX IDC_COMBO1,158,18,105,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
After the change was made:
COMBOBOX IDC_COMBO2,157,36,106,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
Important Features in the Source Code:
|
dialog.h
- class CSampleDialog declares a CTabCtrl object "m_Tab" used in BOOL CSampleDialog::OnInitDialog()
to create a tab control
myDialog.cpp
- Initialization of combo boxes uses global variables
- CMainWin::CMainWin(LPCSTR ClassName) initializes variables that will be used to initalize IDD_DIALOG1 controls
- CMainWin::OnDialog() creates modal dialog box and initializes the variables and saves the variables
initialize the IDD_DIALOG dialog box's controls
- CSampleDialog::OnInitDialog() creates a tab control with two tabs, and it also creates the IDD_DIALOG1 modeless dialog box
- CSampleDialog::OnOK() calls DiagOb2.getCompVals() to save IDD_DIALOG1 control's current settings. It also closes the modal dialog box
- CSampleDialog::OnTabChange(NMHDR *hdr,LRESULT *NotUsed) handles the tab selections.
- SecondDialog::OnInitDialog() initializes the components used in IDD_DIALOG1 dialog box
- SecondDialog::getCompVals() obtains the current state of the components used in IDD_DIALOG1 dialgo box
- SecondDialog::pageDefault() sets the components used in IDD_DIALOG1 dialog box into a default state
- CApp::InitInstance() registers a window and loads a standard cursor and a custom Icon
- DialogActive is used to control the creation of the modeless dialog box SAMPLEDIALOG
[Home]