Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 5: The Document/View Architecture Visual C++ and MFC Fundamentals


}

BOOL CExerciseApp::InitInstance()
{
m_pMainWnd = new CMainFrame ;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}

CExerciseApp theApp;


  1. Test the application and return to MSVC


4.4.3 The Key Up Effect...............................................................................


When we think of the keyboard, the first thing that comes in mind might refer to typing,
which consists of pressing a key and releasing it immediately. As this is done, a key is
pressed down and brought back up. When the user is releasing a key a WM_KEYUP
message is sent. Its syntax is:

afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);

The first argument, nChar, is the code of the key that was pressed.
The second argument, nRepCnt, specifies the number of times counted repeatedly as the
key was held down.
The nFlags argument specifies the scan code, extended-key flag, context code, previous
key-state flag, and transition-state flag.

4.5 Mouse Messages...........................................................................................


4.5.1 Introduction...........................................................................................


The mouse is another object that is attached to the computer allowing the user to interact
with the machine. The mouse and the keyboard can each accomplish some tasks that are
not normally available on the other and both can accomplish some tasks the same way.

The mouse is equipped with two, three, or more buttons. When a mouse has two buttons,
one is usually located on the left and the other is located on the right. When a mouse has
three buttons, one is in the middle of the other two. The mouse is used to select a point or
position on the screen. Once the user has located an item, which could also be an empty
space, a letter or a word, he or she would position the mouse pointer on it. To actually use
the mouse, the user would press either the left, the middle (if any), or the right button. If
the user presses the left button once, this action is called Click. If the user presses the
right mouse button, the action is referred to as Right-Click. If the user presses the left
button twice and very fast, the action is called Double-Click.

4.5.2 Mouse-Down Messages......................................................................

Free download pdf