|
|
Day 1 | Day 2 | Day 3 | Day 4 | Day 5 | Day 6 | Day 7 |
Day 8 | Day 9 | Day 10 | Day 11 | Day 12 | Day 13 | Day 14 |
Day 15 | Day 16 | Day 17 | Day 18 | Day 19 | Day 20 | Day 21 |
Add a second button to the About window in your application. Have the button display a different message from the one on the first window.
1: void CDay2Dlg::OnDfltmsg() 2: { 3: // TODO: Add your control notification handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Set the message to a default message 10: m_strMessage = "Enter a message here"; 11: 12: // Update the screen 13: UpdateData(FALSE); 14: 15: /////////////////////// 16: // MY CODE ENDS HERE 17: ///////////////////////
18: }
1: void CDay2Dlg::OnCkenblpgm() 2: { 3: // TODO: Add your control notification handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Get the current values from the screen 10: UpdateData(TRUE); 11: 12: // Is the Enable Program Action check box checked? 13: if (m_bEnablePgm == TRUE) 14: { 15: // Yes, so enable all controls that have anything 16: // to do with running a program 17: GetDlgItem(IDC_PROGTORUN)->EnableWindow(TRUE); 18: GetDlgItem(IDC_RUNPGM)->EnableWindow(TRUE); 19: GetDlgItem(IDC_STATICPGM)->EnableWindow(TRUE); 20: } 21: else 22: { 23: // No, so disable all controls that have anything 24: // to do with running a program 25: GetDlgItem(IDC_PROGTORUN)->EnableWindow(FALSE); 26: GetDlgItem(IDC_RUNPGM)->EnableWindow(FALSE); 27: GetDlgItem(IDC_STATICPGM)->EnableWindow(FALSE); 28: } 29: 30: /////////////////////// 31: // MY CODE ENDS HERE 32: /////////////////////// 33: } 34: 35: void CDay2Dlg::OnCkshwpgm() 36: { 37: // TODO: Add your control notification handler code here 38: 39: /////////////////////// 40: // MY CODE STARTS HERE 41: /////////////////////// 42: 43: // Get the current values from the screen 44: UpdateData(TRUE); 45: 46: // Is the Show Program Action check box checked? 47: if (m_bShowPgm == TRUE) 48: { 49: // Yes, so show all controls that have anything 50: // to do with running a program 51: GetDlgItem(IDC_PROGTORUN)->ShowWindow(TRUE); 52: GetDlgItem(IDC_RUNPGM)->ShowWindow(TRUE); 53: GetDlgItem(IDC_STATICPGM)->ShowWindow(TRUE); 54: } 55: else 56: { 57: // No, so hide all controls that have anything 58: // to do with running a program 59: GetDlgItem(IDC_PROGTORUN)->ShowWindow(FALSE); 60: GetDlgItem(IDC_RUNPGM)->ShowWindow(FALSE); 61: GetDlgItem(IDC_STATICPGM)->ShowWindow(FALSE); 62: } 63: 64: /////////////////////// 65: // MY CODE ENDS HERE 66: ///////////////////////
67: }
1: void CDay2Dlg::OnRunpgm() 2: { 3: // TODO: Add your control notification handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Get the current values from the screen 10: UpdateData(TRUE); 11: 12: // Declare a local variable for holding the program name 13: CString strPgmName; 14: 15: // Copy the program name to the local variable 16: strPgmName = m_strProgToRun; 17: 18: // Make the program name all uppercase 19: strPgmName.MakeUpper(); 20: 21: // Did the user select to run the Paint program? 22: if (strPgmName == "PAINT") 23: // Yes, run the Paint program 24: WinExec("pbrush.exe", SW_SHOW); 25: 26: // Did the user select to run the Notepad program? 27: if (strPgmName == "NOTEPAD") 28: // Yes, run the Notepad program 29: WinExec("notepad.exe", SW_SHOW); 30: 31: // Did the user select to run the Solitaire program? 32: if (strPgmName == "SOLITAIRE") 33: // Yes, run the Solitaire program 34: WinExec("sol.exe", SW_SHOW); 35: 36: // Run any other program name typed into the combo box 37: if ((strPgmName != "PAINT") && (strPgmName != "NOTEPAD") && 38: (strPgmName != "SOLITAIRE")) 39: // Yes, run the program typed into the combo box 40: WinExec(strPgmName, SW_SHOW); 41: 42: /////////////////////// 43: // MY CODE ENDS HERE 44: ///////////////////////
45: }
((nFlags & MK_LBUTTON) == MK_LBUTTON)
1: void CMouseDlg::OnRButtonDown(UINT nFlags, CPoint point) 2: { 3: // TODO: Add your message handler code here and/or call default 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Set the current point as the starting point 10: m_iPrevX = point.x; 11: m_iPrevY = point.y; 12: 13: /////////////////////// 14: // MY CODE ENDS HERE 15: /////////////////////// 16: 17: CDialog::OnRButtonDown(nFlags, point);
18: }
1: void CMouseDlg::OnMouseMove(UINT nFlags, CPoint point) 2: { 3: // TODO: Add your message handler code here and/or call default 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Check to see if the left mouse button is down 10: if ((nFlags & MK_LBUTTON) == MK_LBUTTON) 11: { 12: // Get the Device Context 13: CClientDC dc(this); 14: 15: // Create a new pen 16: CPen lpen(PS_SOLID, 16, RGB(255, 0, 0)); 17: 18: // Use the new pen 19: dc.SelectObject(&lpen); 20: 21: // Draw a line from the previous point to the current point 22: dc.MoveTo(m_iPrevX, m_iPrevY); 23: dc.LineTo(point.x, point.y); 24: 25: // Save the current point as the previous point 26: m_iPrevX = point.x; 27: m_iPrevY = point.y; 28: } 29: 30: // Check to see if the right mouse button is down 31: if ((nFlags & MK_RBUTTON) == MK_RBUTTON) 32: { 33: // Get the Device Context 34: CClientDC rdc(this); 35: 36: // Create a new pen 37: CPen rpen(PS_SOLID, 16, RGB(0, 0, 255)); 38: 39: // Use the new pen 40: rdc.SelectObject(&rpen); 41: 42: // Draw a line from the previous point to the current point 43: rdc.MoveTo(m_iPrevX, m_iPrevY); 44: rdc.LineTo(point.x, point.y); 45: 46: // Save the current point as the previous point 47: m_iPrevX = point.x; 48: m_iPrevY = point.y; 49: } 50: 51: /////////////////////// 52: // MY CODE ENDS HERE 53: /////////////////////// 54: 55: CDialog::OnMouseMove(nFlags, point);
56: }
void CMouseDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default /////////////////////// // MY CODE STARTS HERE /////////////////////// char lsChar; // The current character being pressed HCURSOR lhCursor; // The handle to the cursor to be displayed // Convert the key pressed to a character lsChar = char(nChar); // Is the character "A" if (lsChar == `A') { // Load the arrow cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "B" if (lsChar == `B') { // Load the I beam cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_IBEAM); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "C" if (lsChar == `C') { // Load the hourglass cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "D" if (lsChar == `D') { // Load the cross hair cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_CROSS); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "E" if (lsChar == `E') { // Load the up arrow cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_UPARROW); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "F" if (lsChar == `F') { // Load the size cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEALL); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "G" if (lsChar == `G') { // Load the up/right-down/left size cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "H" if (lsChar == `H') { // Load the up/left-down/right size cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENESW); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "I" if (lsChar == `I') { // Load the left-right size cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "J" if (lsChar == `J') { // Load the up-down size cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } if (lsChar == `K') { // Load the no cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_NO); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } if (lsChar == `L') { // Load the app starting cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } if (lsChar == `M') { // Load the help cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_HELP); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); } // Is the character "X" if (lsChar == `X') { // Load the arrow cursor lhCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); // Set the cursor flag m_bCursor = TRUE; // Set the screen cursor SetCursor(lhCursor); // Exit the application OnOK(); } /////////////////////// // MY CODE ENDS HERE /////////////////////// CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
/////////////////////////////////////////////////////////////////////// CTimersDlg dialog #define ID_CLOCK_TIMER 1 #define ID_COUNT_TIMER 2 class CTimersDlg : public CDialog { . . .
Update your application so that when the counter timer is started, the clock timer is reset to run at the same interval as the counter timer. When the counter timer is stopped, return the clock timer to a one-second interval.
To change the interval at which a timer is running, you need to first stop the timer and then restart it, as in Listing B.6.
1: void CTimersDlg::OnStarttime() 2: { 3: // TODO: Add your control notification handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Update the variables 10: UpdateData(TRUE); 11: 12: // Initialize the count 13: m_iCount = 0; 14: // Format the count for displaying 15: m_sCount.Format("%d", m_iCount); 16: 17: // Update the dialog 18: UpdateData(FALSE); 19: // Start the timer 20: SetTimer(ID_COUNT_TIMER, m_iInterval, NULL); 21: 22: // Stop the clock timer 23: KillTimer(ID_CLOCK_TIMER); 24: // Restart the clock timer with the counter interval 25: SetTimer(ID_CLOCK_TIMER, m_iInterval, NULL); 26: 27: // Enable the Stop Timer button 28: m_cStopTime.EnableWindow(TRUE); 29: // Disable the Start Timer button 30: m_cStartTime.EnableWindow(FALSE); 31: 32: /////////////////////// 33: // MY CODE ENDS HERE 34: /////////////////////// 35: } 36: 37: void CTimersDlg::OnStoptimer() 38: { 39: // TODO: Add your control notification handler code here 40: 41: /////////////////////// 42: // MY CODE STARTS HERE 43: /////////////////////// 44: 45: // Stop the timer 46: KillTimer(ID_COUNT_TIMER); 47: 48: // Stop the clock timer 49: KillTimer(ID_CLOCK_TIMER); 50: // Restart the clock timer with 1 second interval 51: SetTimer(ID_CLOCK_TIMER, 1000, NULL); 52: 53: // Disable the Stop Timer button 54: m_cStopTime.EnableWindow(FALSE); 55: // Enable the Start Timer button 56: m_cStartTime.EnableWindow(TRUE); 57: 58: /////////////////////// 59: // MY CODE ENDS HERE 60: ///////////////////////
61: }
CFileDialog m_ldFile(FALSE);
void CDialogsDlg::OnFileopen() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// CFileDialog m_ldFile(TRUE); // Show the File open dialog and capture the result if (m_ldFile.DoModal() == IDOK) { // Get the filename selected m_sResults = m_ldFile.GetPathName(); // Update the dialog UpdateData(FALSE); } /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CMsgDlg::OnYesno() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Ask the user m_iYesNo = MessageBox("Choose Yes or No", "Yes or No", ÂMB_YESNO); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CDialogsDlg::OnYesno() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // What did the user answer switch (m_dMsgDlg.m_iYesNo) { case IDYES: // Did the user answer YES? m_sResults = "Yes!"; break; case IDNO: // Did the user answer NO? m_sResults = "No!"; break;
}
// Update the dialog UpdateData(FALSE); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here and/or call Âdefault /////////////////////// // MY CODE STARTS HERE /////////////////////// // Declare local variables CMenu *m_lMenu; // A pointer to the menu CPoint m_pPoint; // A copy of the mouse position // Copy the mouse position to a local variable m_pPoint = point; // Convert the position to a screen position ClientToScreen(&m_pPoint); // Get a pointer to the window menu m_lMenu - GetMenu(); // Get a pointer to the first submenu m_lMenu = m_lMenu->GetSubMenu(1); // Show the Pop-up Menu m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, m_pPoint.x, m_pPoint.y, this, NULL); /////////////////////// // MY CODE ENDS HERE /////////////////////// CDialog::OnRButtonDown(nFlags, point);
}
void CDay7Dlg::OnCbusetext() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Update the variables with the dialog controls UpdateData(TRUE); // Using the font name for the font sample? if (!m_bUseText) // Using the font name m_strDisplayText = m_strFontName; else // Using the entered text m_strDisplayText = m_strSampText; // Update the dialog UpdateData(FALSE); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
BOOL CDay7Dlg::OnInitDialog() { CDialog::OnInitDialog(); . . . // TODO: Add extra initialization here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Fill the font list box FillFontList(); // Initialize the text to be entered m_strSampText = "Testing"; // Copy the text to the font sample area m_strDisplayText = m_strSampText; // Initialize the check box m_bUseText = TRUE; // Update the dialog UpdateData(FALSE); /////////////////////// // MY CODE ENDS HERE /////////////////////// return TRUE; // return TRUE unless you set the focus // to a control
}
void CDay7Dlg::OnSelchangeLfonts() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Update the variables with the dialog controls UpdateData(TRUE); // Using the font name for the font sample? if (!m_bUseText) { // Copy the font name to the font sample m_strDisplayText = m_strFontName; // Update the dialog with the variables UpdateData(FALSE); } // Set the font for the sample SetMyFont(); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CDay7Dlg::OnChangeEsamptext() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the // CDialog::OnInitialUpdate() // function and call CRichEditCrtl().SetEventMask() // with the EN_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Update the variables with the dialog controls UpdateData(TRUE); // Using the text for the font sample? if (m_bUseText) { // Copy the current text to the font sample m_strDisplayText = m_strSampText; // Update the dialog with the variables UpdateData(FALSE); } /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CDay7Dlg::OnCbitalic() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Update the variables with the dialog controls UpdateData(TRUE); // Set the font for the sample SetMyFont(); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
void CDay7Dlg::SetMyFont() { CRect rRect; // The rectangle of the display area int iHeight; // The height of the display area int iItalic = 0; // Italicize the font? // Has a font been selected? if (m_strFontName != "") { // Get the dimensions of the font sample display area m_ctlDisplayText.GetWindowRect(&rRect); // Calculate the area height iHeight = rRect.top - rRect.bottom; // Make sure the height is positive if (iHeight < 0) iHeight = 0 - iHeight; // Should the font be italicized? If (m_bItalic) iItalic = 1; // Create the font to be used m_fSampFont.CreateFont((iHeight - 5), 0, 0, 0, FW_NORMAL, iItalic, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, m_strFontName); // Set the font for the sample display area m_ctlDisplayText.SetFont(&m_fSampFont); }
}
1: void CPaintDlg::OnSize(UINT nType, int cx, int cy) 2: { 3: CDialog::OnSize(nType, cx, cy); 4: 5: // TODO: Add your message handler code here 6: // Redraw the window 7: Invalidate();
8:}
1: void CPaintDlg::DrawRegion(CPaintDC *pdc, int iColor, int iTool, int ÂiShape) 2: { 3: // Declare and create the pens . . . 19: CBrush lVertBrush(HS_VERTICAL, m_crColors[iColor]); 20: CBrush lNullBrush(RGB(192, 192, 192)); 21: 22: CBitmap lBitmap; 23: lBitmap.LoadBitmap(IDB_BITMAPBRUSH); 24: CBrush lBitmapBrush(&lBitmap); 25: 26: // Calculate the size of the drawing regions 27: CRect lRect; 28: GetClientRect(lRect); . . . 37: int i; 38: // Loop through all of the brushes and pens 39: for (i = 0; i < 8; i++) 40: { 41: switch (i) 42: { . . . 103: pdc->SelectObject(&lVertBrush); 104: break; 105: case 7: // Null - Bitmap 106: // Determine the location for this figure. 107: lDrawRect.left = lDrawRect.left + liHorz; 108: lDrawRect.right = lDrawRect.left + liWidth; 109: // Select the appropriate pen and brush 110: pdc->SelectObject(&lNullPen); 111: pdc->SelectObject(&lBitmapBrush); 112: break; 113: } 114: // Which tool are we using? . . . 126: pdc->SelectObject(lOldBrush); 127: pdc->SelectObject(lOldPen);
128:}
Modify the application so that the user can double-click a column header and make it the first column in the grid.
Using the Class Wizard, add a function to the DblClick event message for the grid control.
Edit the function in exercise 1 to add the following code:
void CActiveXDlg::OnDblClickMsfgrid() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Did the user click on a data row and not the // header row? if (m_ctlFGrid.GetMouseRow() != 0) { // If so, then zero out the column variable // and exit m_iMouseCol = 0; return; } // Save the column clicked on m_iMouseCol = m_ctlFGrid.GetMouseCol(); // If the selected column was the first column, // there's nothing to do if (m_iMouseCol == 0) return; // Turn the control redraw off m_ctlFGrid.SetRedraw(FALSE); // Change the selected column position m_ctlFGrid.SetColPosition(m_iMouseCol, 0); // Resort the grid DoSort(); // Turn redraw back on m_ctlFGrid.SetRedraw(TRUE); /////////////////////// // MY CODE ENDS HERE ///////////////////////
}
Add another pull-down menu to control the width of the pen used for drawing. Give it the following settings:
Menu Entry | Width Setting |
Very Thin | 1 |
Thin | 8 |
Medium | 16 |
Thick | 24 |
Very Thick | 32 |
Follow these steps:
1: CLine::CLine(CPoint ptFrom, CPoint ptTo, COLORREF crColor, UINT nWidth) 2: { 3: //Initialize the from and to points 4: m_ptFrom = ptFrom; 5: m_ptTo = ptTo; 6: m_crColor = crColor; 7: m_nWidth = nWidth;
8: }
1: void CLine::Draw(CDC * pDC) 2: { 3: // Create a pen 4: CPen lpen (PS_SOLID, m_nWidth, m_crColor); 5: 6: // Set the new pen as the drawing object 7: CPen* pOldPen = pDC->SelectObject(&lpen); 8: // Draw the line 9: pDC->MoveTo(m_ptFrom); 10: pDC->LineTo(m_ptTo); 11: // Reset the previous pen 12: pDC->SelectObject(pOldPen);
13: }
1: void CLine::Serialize(CArchive &ar) 2: { 3: CObject::Serialize(ar); 4: 5: if (ar.IsStoring()) 6: ar << m_ptFrom << m_ptTo << (DWORD) m_crColor << m_nWidth; 7: else 8: ar >> m_ptFrom >> m_ptTo >> (DWORD) m_crColor >> m_nWidth;
9: }
1: BOOL CDay10Doc::OnNewDocument() 2: { 3: if (!CDocument::OnNewDocument()) 4: return FALSE; 5: 6: // TODO: add reinitialization code here 7: // (SDI documents will reuse this document) 8: 9: /////////////////////// 10: // MY CODE STARTS HERE 11: /////////////////////// 12: 13: // Initialize the color to black 14: m_nColor = ID_COLOR_BLACK - ID_COLOR_BLACK; 15: // Initialize the width to thin 16: m_nWidth = ID_WIDTH_VTHIN - ID_WIDTH_VTHIN; 17: 18: /////////////////////// 19: // MY CODE ENDS HERE 20: /////////////////////// 21: 22: return TRUE;
23: }
1: CLine * CDay10Doc::AddLine(CPoint ptFrom, CPoint ptTo) 2: { 3: static UINT nWidths[5] = { 1, 8, 16, 24, 32}; 4: 5: // Create a new CLine object 6: CLine *pLine = new CLine(ptFrom, ptTo, Âm_crColors[m_nColor], nWidths[m_nWidth]); 7: try 8: { 9: // Add the new line to the object array 10: m_oaLines.Add(pLine); 11: // Mark the document as dirty 12: SetModifiedFlag(); 13: } 14: // Did we run into a memory exception? 15: catch (CMemoryException* perr) 16: { 17: // Display a message for the user, giving him or her the 18: // bad news 19: AfxMessageBox("Out of memory", MB_ICONSTOP | MB_OK); 20: // Did we create a line object? 21: if (pLine) 22: { 23: // Delete it 24: delete pLine; 25: pLine = NULL; 26: } 27: // Delete the exception object 28: perr->Delete(); 29: } 30: return pLine;
31: }
1: UINT CDay10Doc::GetWidth() 2: { 3: // Return the current width 4: return ID_WIDTH_VTHIN + m_nWidth;
5: }
Object | Property | Setting |
Menu Entry | ID | ID_WIDTH_VTHIN |
Caption | &Very Thin | |
Menu Entry | ID | ID_WIDTH_THIN |
Caption | Thi&n | |
Menu Entry | ID | ID_WIDTH_MEDIUM |
Caption | &Medium | |
Menu Entry | ID | ID_WIDTH_THICK |
Caption | Thic&k | |
Menu Entry | ID | ID_WIDTH_VTHICK |
Caption | Very &Thick |
1: void CDay10Doc::OnWidthVthin() 2: { 3: // TODO: Add your command handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Set the current width to Very Thin 10: m_nColor = ID_WIDTH_VTHIN - ID_WIDTH_VTHIN; 11: 12: /////////////////////// 13: // MY CODE ENDS HERE 14: /////////////////////// 15: } 16: 17: void CDay10Doc::OnUpdateWidthVthin(CCmdUI* pCmdUI) 18: { 19: // TODO: Add your command update UI handler code here 20: 21: /////////////////////// 22: // MY CODE STARTS HERE 23: /////////////////////// 24: 25: // Determine if the Very Thin menu entry should be checked 26: pCmdUI->SetCheck(GetWidth() == ID_WIDTH_VTHIN ? 1 : 0); 27: 28: /////////////////////// 29: // MY CODE ENDS HERE 30: ///////////////////////
31: }
1: void CDay10Doc::OnWidthThin() 2: { 3: // TODO: Add your command handler code here 4: 5: /////////////////////// 6: // MY CODE STARTS HERE 7: /////////////////////// 8: 9: // Set the current width to Thin 10: m_nColor = ID_WIDTH_THIN - ID_WIDTH_VTHIN; 11: 12: /////////////////////// 13: // MY CODE ENDS HERE 14: /////////////////////// 15: } 16: 17: void CDay10Doc::OnUpdateWidthThin(CCmdUI* pCmdUI) 18: { 19: // TODO: Add your command update UI handler code here 20: 21: /////////////////////// 22: // MY CODE STARTS HERE 23: /////////////////////// 24: 25: // Determine if the Thin menu entry should be checked 26: pCmdUI->SetCheck(GetWidth() == ID_WIDTH_THIN ? 1 : 0); 27: 28: /////////////////////// 29: // MY CODE ENDS HERE 30: ///////////////////////
31: }
© Copyright, Macmillan Computer Publishing. All rights reserved.