General Information for COP4226
-
If you added addresses to the aul-cop4226 mailing lists, then they were
accidentally removed. Your FIU e-mail addresses are still on the lists, but
any new addresses were clobbered on 10/6/2002.
-
FAQ
-
General course info
-
Exam Information will be posted here prior to exams. Check the syllabus for
exam dates.
-
Assignments will be posted here
-
Submitting Homework
Online. When you are asked for a username and password, use your solix
username with cop4226 as the password.
-
Tutorial 1. Remember that tutorials are
extra credit. If you don't want to do it, then don't!
-
Tutorial 2. \Remember that tutorials are
extra credit. If you don't want to do it, then don't!
-
Homework 1. This one is required. Start
now!
-
I have made an executable image of the homework available for you to run:
hw1.exe.
-
I have created a mailing list on www.cs.fiu.edu for this class. Your FIU
e-mail address is already on the list. To retrieve your password for access
to the list, go to the following link, scroll to the bottom, enter your FIU
e-mail address in the box for Edit Options and submit it. The next page has
a button for retrieving your password. Do not change your password to your
regular FIU password, as the mailing list passwords are not encrypted.
You may add more than one address to the list. When adding a new e-mail,
be sure to follow the instructions about placing 'confirm ######' in the
body o fhte text. If you only reply, it might not work. This is a moderated
list, so only messages that I approve will be sent to you. I will sell your
e-mail address to whomever wants to buy it (just kidding).
-
The discussion group at cs.fiu.edu and the Yahoo group are no longer supported.
-
Tutorial 3. Remember that tutorials are
extra credit. If you don't want to do it, then don't! (But I can't believe
you wouldn't do them.)
-
Tutorial 4. Remember that tutorials are
extra credit. If you don't want to do it, then don't! (But I can't believe
you wouldn't do them.)
-
If you use the technique I explained in class for ensuring that the Apply
button works properly on the FontSize page, there will still be a flaw.
I had originally solved the problem using a different technique, that did
not involve the class wizard. I tested the code and it worked. I then realized
I could implement the code using the class wizard, but didn't test the new
solution thoroughly. Another example for software engineering!
There is no way to test the state of the modified flag. If we knew it, then
we could make the apply button work properly using the class wizard.
The solution is to set the modified to true, except for the Set and Kill
focus commands. Using the class wizard does not do this: first it is set
to true in OnCommand, then it is set to false in the FontSize page's OnSetFocus
and OnKillFocus handlers.
The way to fix this is to forget about the OnSetFocus and OnKillFocus handlers
in the FontSize page, and to do all the testing in OnCommand. The way to
do this is to extract the high word from wParam and testing that it is not
EN_SETFOCUS nor EN_KILLFOCUS. Only set the modified flag if it is neither
of these. Extract the high word from wParam with the macro HIWORD(wParam).
Please implement this solution.
-
Homework 4
Back to Index
HOW TO change the name of the
WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE message handler functions.
-
Use Class Wizard to create the normal message handlers.
-
Open the .h file for your view.
-
Find the Message Map area for these messages. They will be in grey.
-
Copy the declarations of the normal message handlers down a few lines : after
the
//}}AFX_MSG
and before the
DECLARE_MESSAGE_MAP()
-
Rename the declarations so that they include your user id.
-
Run Class Wizard and delete the message maps for these messages: WM_LBUTTONDOWN,
WM_LBUTTONUP, and WM_MOUSEMOVE.
-
Open the .cpp file for our view. Between the comments
//}}AFX_MSG_MAP
// Standard printing
-
Add the following declarations. Replace the OnLButtonDown, OnLButtonUp and
OnMouseMove names with names that include your user ID. Here is an example
that uses my user ID.
{ WM_MOUSEMOVE, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnMouseMove_downeyt },
{ WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnLButtonDown_downeyt },
{ WM_LBUTTONUP, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(UINT, CPoint))&OnLButtonUp_downeyt },
-
Find the old message handler function definitions and add your user id to
the names.
Back to Index
When working with GDI objects, you cannot destroy them if they are still
attached to the device context. Suppose you wanted to reuse the same font
again and again, instead of using several different font objects. The goal
would be to reduce the load on system resources. The following code has the
exact opposite effect. If you were to continually redraw a program that contains
this code, then eventually you would run out of fonts.
CFont fontTest;
fontTest.CreateFont(-500,0,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
CFont* pFontOld = (CFont*) pDC->SelectObject(&fontTest);
pDC->TextOut(0,0,"Hello");
fontTest.DeleteObject();
fontTest.CreateFont(-500,0,-900,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
pDC->SelectObject(&fontTest);
pDC->TextOut(15000,-25000,"World");
pDC->SelectObject(pFontOld);
The reason is that the call to DeleteObject is unable to delete the GDI object
because it is still attached to the device context. It appears that the delete
worked, because you will be able to create a new font using fontTest. Only
the CFont object has been deleted. Think of the CFont object as having a
pointer to a GDI object in it. The CFont is destroyed, but the GDI object
is not released because it is still attached to the device context. When
the next call to SelectObject succeeds, there is a GDI font object that did
not get destoyed. Eventually, the application will be unable to create new
fonts.
It is possible to fix this problem by detaching the GDI object from the device
context before deleting the CFont object.
CFont fontTest;
fontTest.CreateFont(-500,0,0,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
CFont* pFontOld = (CFont*) pDC->SelectObject(&fontTest);
pDC->TextOut(0,0,"Hello");
pDC->SelectObject(pFontOld);
fontTest.DeleteObject();
fontTest.CreateFont(-500,0,-900,0,400,FALSE,FALSE,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,"Arial");
pDC->SelectObject(&fontTest);
pDC->TextOut(15000,-25000,"World");
pDC->SelectObject(pFontOld);
You could acheive the same effect by removing the last line of code from
this example.
All GDI objects will exhibit this behavior, so remember to detach them from
the device context before destroying them, or letting them go out of scope.
Back to Index
You are visitor number
to visit this page since 5/5/02.