A1806A16 Wndassignment 3
A1806A16 Wndassignment 3
Ans:- DestroyMenu() :- During the WM_DESTROY message, NOPOPUPS sets the program's
menu to the Main menu and destroys the File and Edit menus with calls to DestroyMenu. The
Main menu is destroyed automatically when the window is destroyed.
DeleteMenu :-Deletes an item from the specified menu. If the menu item opens a menu or
submenu, this function destroys the handle to the menu or submenu and frees the memory
used by the menu or submenu.
Ans:- WM_COMMAND. This message indicates that the user has chosen an enabled menu
item from your window's menu.
Ans:- CreateMenu Creates a menu. The menu is initially empty, but it can be filled with menu items
by using the InsertMenuItem, AppendMenu, and InsertMenu functions.
AppendMenu Appends a new item to the end of the specified menu bar, drop-down menu,
submenu, or shortcut menu. You can use this function to specify the content, appearance, and
behavior of the menu item.
CheckMenuItem Sets the state of the specified menu item's check-mark attribute to either selected
or clear.
CreatePopupMenu Creates a drop-down menu, submenu, or shortcut menu. The menu is
initially empty. You can insert or append menu items by using the InsertMenuItem function.
You can also use the InsertMenu function to insert menu items and the AppendMenu
function to append menu items.
Defining a menu in a program's resource script is usually the easiest way to add a menu in
your window, but it's not the only way. You can dispense with the resource script and create a
menu entirely within your program by using two
functions called CreateMenu and AppendMenu. After you finish defining the menu, you can
pass the menu handle to CreateWindow or use SetMenu to set the window's menu. Here's
how it's done. CreateMenu simply returns a handle to a new menu:
hMenu = CreateMenu () ;
The menu is initially empty. AppendMenu inserts items into the menu. You must obtain a
different menu handle for the top-level menu item and for each popup. The popups are
constructed separately; the popup menu handles arethen inserted into the top-level menu. The
code shown in Figure 10-7 creates a menu in this fashion; in fact, it is the same menu that I
used in the MENUDEMO program. For illustrative simplicity, the code uses ASCII character
strings.
4:-Suppose we click on upper left corner of the whole screen, it means we aren’t restricting on
the client area, we are clicking on non-client area’s upper left corner, elaborate the action taken
by windows. Also, elaborate the things necessary for attaching that function in your window.
Ans:-
The user can open the window menu by clicking the application icon on the title bar or by
right-clicking anywhere on the title bar or Alt+ Spacebar can be used.
Example : Notepad Application
System menus can be attached to program window by including WS_SYSMENU
window style when calling CreateWindow().
WS_SYSMENU is a part of WS_OVERLAPPED WINDOW. So system menu will
be added automatically to your program if you use WS_OVERLAPPEDWINDOW
style.
You can explicitly add WS_SYSMENU to child and popup windows.
The Window menu provides a standard set of menu items that the user can choose to
change a window's size or position, or close the application.
Items on the window menu can be added, deleted, and modified, but most applications
just use the standard set of menu items.
It returns the handle of a window’s system menu. Then you can operate on the menu.
Syntax:
hmenu= GetSystemMenu(hwnd,FALSE );
OR
GetSystemMenu(hwnd,TRUE );
5:-Suppose two instances of same window application or different window applications are opened,
one is in active state and the other is in inactive state. Now, if we shift from one instance into the
other with the help of mouse, elaborate the actions taken and the messages generated by the
windows.?
Ans:-