Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
heightening an object
IDC_SIZENWSE (^)
The northwest - southeast arrow pointing cursor can be used when
resizing an object on both the length and the height
IDC_SIZEWE The west - east arrow pointing cursor can be used when narrowing or
enlarging an object
IDC_UPARROW The vertical arrow cursor can be used to indicate the presence of the
mouse or the caret
IDC_WAIT
The Hourglass cursor is usually used to indicate that a window or the
application is not ready
To use one of these cursors, if you are creating an MFC application, you can call the
CWinApp::LoadCursor() method to assign one of the above standard cursors to your
application. This method comes in two versions as follows:
HCURSOR LoadCursor(LPCTSTR lpszResourceName) const;
HCURSOR LoadCursor(UINT nIDResource) const;
The cursor can be specified using its name, which would be a null-terminated string
passed as lpszResourceName. If you had designed your cursor and gave it an ID, you can
pass this identifier to the LoadCursor() method.
The LoadCursor() member function returns an HCURSOR value. You can assign it to the
hCursor member variable of your WNDCLASS object. Here is an example:
CMainFrame::CMainFrame()
{
// Declare a window class variable
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));
WndCls.hCursor = LoadCursor(NULL, IDC_CROSS);
}
You can also call the CWinApp::LoadStandardCursor() method using the AfxGetApp()
function. Its syntax is:
HCURSOR LoadStandardCursor(LPCTSTR lpszCursorName) const;
To paint the work area of the window, you must specify what color will be used to fill it.
This color is created as an HBRUSH and assigned to the hbrBackground member
variable of your WNDCLASS object. The color you are using must be a valid HBRUSH
or you can cast a known color to HBRUSH. The Win32 library defines a series of colors
known as stock objects. To use one of these colors, call the GetStockObject() function.
For example, to paint the windows background in black, you can pass the
BLACK_BRUSH constant to the GetStockObject() function, cast it to HBRUSH and
assign the result to hbrBackground.
In addition to the stock objects, the Microsoft Windows operating system provides a
series of colors for its own internal use. These are the colors used to paint the borders of
frames, buttons, scroll bars, title bars, text, etc. The colors are named (you should be able
to predict their appearance or role from their name):