Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
The LoadIcon() member function returns an HICON object that you can assign to the
hIcon member variable of your WNDCLASS object. Here is an example:
CMainFrame::CMainFrame()
{
WNDCLASS WndCls;
WndCls.style = CS_VREDRAW | CS_HREDRAW;
WndCls.lpfnWndProc = AfxWndProc;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = AfxGetInstanceHandle();
WndCls.hIcon = LoadIcon(NULL, IDI_WARNING);
}
You can also declare an HICON handle and initialize it with
CWinApp::LoadStandardIcon() method as follows:
AfxGetApp()->LoadStandardIcon(StdIcon);
A cursor is used to locate the position of the mouse pointer on a document or the screen.
To use a cursor, call the Win32 LoadCursor() function. Its syntax is:
HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName);
The hInstance argument is a handle to the file in which the cursor was created. This file is
usually stored in a library (DLL) of an executable program. If the cursor was created as
part of your application, you can use the hInstance of your application. If your are using
one of the below cursors, set this argument to NULL.
When Microsoft Windows installs, it also installs various standard cursors you can use in
your program. Each one of these cursors is recognized by an ID which is simply a
constant integers. The available cursors are:
ID Picture Description
IDC_APPSTARTING
Used to show that something undetermined is going on or the
application is not stable
IDC_ARROW
This standard arrow is the most commonly used cursor
IDC_CROSS The crosshair cursor is used in various circumstances such as drawing^
IDC_HAND
The Hand is standard only in Windows 2000. If you are using a
previous operating system and need this cursor, you may have to create
your own.
IDC_HELP The combined arrow and question mark cursor is used when providing
help on a specific item on a window object
IDC_IBEAM The I-beam cursor is used on text-based object to show the position of
the caret
IDC_ICON This cursor is not used anymore
IDC_NO This cursor can be used to indicate an unstable situation^
IDC_SIZE This cursor is not used anymore
IDC_SIZEALL The four arrow cursor pointing north, south, east, and west is highly
used to indicate that an object is selected or that it is ready to be moved
IDC_SIZENESW The northeast and southwest arrow cursor can be used when resizing an
object on both the length and the height
IDC_SIZENS
The north - south arrow pointing cursor can be used when shrinking or
heightening an object