Chapter 18: Progress-Based Controls Visual C++ and MFC Fundamentals
DlgWidth = GetSystemMetrics(SM_CXSCREEN);
DlgHeight = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(&wndTopMost, 0, 0, DlgWidth, DlgHeight,
SWP_SHOWWINDOW);
ShowCursor(FALSE);
srand((unsigned)time(NULL));
SetTimer(1, 200, 0);
return TRUE; // return TRUE unless you set the focus to a control
}
- Test the application and return to MSVC
18.1.4..The Tick Counter.................................................................................
The Win32 library provides a special function used to count a specific number of lapses
that have occurred since you started your computer. This information or counter is
available through the GetTickCount() function. Its syntax is:
DWORD GetTickCount(VOID);
This function takes no argument. If it succeeds in performing its operation, which it
usually does, it provides the number of milliseconds that have elapsed since you started
your computer. Just like the timer control, what you do with the result of this function is
up to you and it can be used in various circumstances. For example, computer games and
simulations make great use of this function.
After retrieving the value that this function provides, you can display it in a text-based
control.
Practical Learning: Counting the Computer's Ticks
- Start a new MFC Application named TickCounter
- Create it as Dialog Based with no About Box
- Change the design of the IDR_MAINFRAME icon as follows: