Tuesday, July 15, 2014

Windows Programming 2nd Part

WNDCLASS

The WNDCLASS structure contains the window class attributes that are registered by the RegisterClass function.
typedef struct _WNDCLASS {
UINT style;
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS;


Members

lpfnWndProc
Points to the window procedure. For more information, see WindowProc.

cbClsExtra
Specifies the number of extra bytes to allocate following the window-class structure. The operating system initializes the bytes to zero.

cbWndExtra
Specifies the number of extra bytes to allocate following the window instance. The operating system initializes the bytes to zero. If an application uses the WNDCLASS structure to register a dialog box created by using the CLASS directive in the resource file, it must set this member to DLGWINDOWEXTRA.

hInstance
Identifies the instance that the window procedure of this class is within.

hIcon
Identifies the class icon. This member must be a handle of an icon resource. If this member is NULL, an application must draw an icon whenever the user minimizes the application's window.

hCursor
Identifies the class cursor. This member must be a handle of a cursor resource. If this member is NULL, an application must explicitly set the cursor shape whenever the mouse moves into the application's window.

hbrBackground
Identifies the class background brush. This member can be a handle to the physical brush to be used for painting the background, or it can be a color value. A color value must be one of the following standard system colors (the value 1 must be added to the chosen color). If a color value is given, you must convert it to one of the following HBRUSH types: 

COLOR_ACTIVEBORDER
COLOR_ACTIVECAPTION
COLOR_APPWORKSPACE
COLOR_BACKGROUND
COLOR_BTNFACE
COLOR_BTNSHADOW
COLOR_BTNTEXT
COLOR_CAPTIONTEXT
COLOR_GRAYTEXT
COLOR_HIGHLIGHT
COLOR_HIGHLIGHTTEXT
COLOR_INACTIVEBORDER
COLOR_INACTIVECAPTION
COLOR_MENU
COLOR_MENUTEXT
COLOR_SCROLLBAR
COLOR_WINDOW
COLOR_WINDOWFRAME
COLOR_WINDOWTEXT 

The operating system automatically deletes class background brushes when the class is freed. An application should not delete these brushes, because a class may be used by multiple instances of an application.
When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint function.

lpszMenuName
Points to a null-terminated character string that specifies the resource name of the class menu, as the name appears in the resource file. If you use an integer to identify the menu, use the MAKEINTRESOURCE macro. If this member is NULL, windows belonging to this class have no default menu.

lpszClassName
Points to a null-terminated string or is an atom. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be in the low-order word of lpszClassName; the high-order word must be zero. If lpszClassName is a string, it specifies the window class name.


Describe different types of menu in windows programming


A list of commands or options from which you can choose. Most applications now have a menu-driven component. You can choose an item from the menu by highlighting it and then pressing the Enter or Return key, or by simply pointing to the item with a mouse and clicking one of the mouse buttons.
The antithesis of a menu-driven program is a command-driven system, in which you must explicitly enter the command you want rather than choose from a list of possible commands. Menu-driven systems are simpler and easier to learn but are generally not as flexible as command-driven systems, which lend themselves more naturally to interaction with programs.

There are several different types of menus:

·  pop-up menu:A menu that appears temporarily when you click the mouse button on a selection. Once you make a selection from a pop-up menu, the menu usually disappears.

·  cascading menu: A submenu that opens when you select a choice from another menu.

·  pull-down menu :A special type of pop-up menu that appears directly beneath the command you selected.

·  moving-bar menu :A menu in which options are highlighted by a bar that you can move from one item to another. Most menus are moving-bar menus.

·  menu bar :A menu arranged horizontally. Each menu option is generally associated with another pull-down menu that appears when you make a selection.

·  tear-off menu : A pop-up menu that you can move around the screen like a window.

No comments:

Post a Comment