![]() |
|
|
Ambitious students should try to implement a basic version of Assignment No. 1 we did in Visual Basic. Some parts of that are quite a challenge, while others are easy. Document your program above and beyond the documentation inserted by Visual C++ to show that you understand what it’s doing.
Change the icon in the About dialog box to something other than the default. Change the code to display your name and your program's title and perhaps some other information that one sees in typical About dialog boxes.
Add any original features that you can. Be sure to make me aware of these via a note when you hand in your program or e-mail so that I look for them and give you the credit you deserve. There are a number of interesting controls that are new with Windows 95 in Kruglinski's Example EX06B.
Like the last assignment, this assignment will be graded in a criterion-referenced manner. That is, you get points for each feature that your program implements with little subjective grading on my part. See the grading information sheet for a list of the things I’m looking for.
Note that this technique draws pictures on static controls (labels in Visual Basic). You must first create a static control in AppStudio as Kruglinski does on p. 131. Then replace parts of the code you’ll find there with what you see below. If you want to draw directly on the dialog box background, you have to do even more work.
void CEx06aDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
////////////////////////////////////////////////////////////////////////////////
// added by JMH 10/24/95, devised by JMH and HE, 7/95
// the following code displays a bitmap in a static control
// ref. Kruglinski pp. 132 and 183
// get a pointer to the dialog box static (label) control
// created in App Studio -- this is the control that will
// contain the bitmap
CWnd* pWnd = GetDlgItem(IDC_BITMAP_JESSE);
// get a device context for the control into which we will
// draw
CDC* pControlDC = pWnd->GetDC() ;
// invalidate the control and update its window so that it
// will be redrawn
pWnd->Invalidate() ;
pWnd->UpdateWindow() ;
// create a new device context for the display memory that
// will hold the bitmap and a new bitmap item into which
// we will load the bitmap we created in App Studio
CDC* pDisplayMemDC = new CDC ;
CBitmap* pBitmap = new CBitmap ;
// load the bitmap into memory
pBitmap->LoadBitmap(IDB_BITMAP_JESSE) ;
// make the device context of the display memory compatible
// with that of the control in which the bitmap will be
// displayed
pDisplayMemDC->CreateCompatibleDC(pControlDC) ;
// select the bitmap as an object so that it can be copied
// into the control
pDisplayMemDC->SelectObject(pBitmap) ;
// copy the bitmap bit by bit into the control's display
// memory
pControlDC->BitBlt(0,0, 100,100, pDisplayMemDC, 0,0, SRCCOPY) ;
// destruct and deallocate the memory for the items created
// with "new"
delete pDisplayMemDC;
delete pBitmap;
// release the control's device context - this is critical
// to avoid memory leaks!
pWnd->ReleaseDC(pControlDC) ;
////////////////////////////////////////////////////////////////////////////////
// Do not call CDialog::OnPaint() for painting messages
} // void CEx06aDialog::OnPaint()
Mark your name clearly on the diskette and label it "91.353 Assignment No. 4."
Hand in your diskette at the beginning of class on the day it is due.
| Criteria | Possible
Points |
Your
Score |
| Documentation and Formatting
added by you, not inserted by VC++! |
2 | |
| Functionality
- contains Kruglinski’s controls - contains additional controls - initializes dialog box data beyond Kruglinski - retrieves dialog box data - performs data validation beyond Kruglinski - has new icon in about box - view responds to other events other than OnLButtonDown - implements a second dialog box - has additional original features point these out so I notice them |
1 2 2 2
1
3
|
| Please send
comments and suggestions to the Booksite
Director
Last Updated: 12 March 2000 |