Menus  Menus is a feature which is common to almost every windows applications. It is the one of the most common user interface elements around.  Windows.

Slides:



Advertisements
Similar presentations
Instructors: Connie Hutchison & Christopher McCoy
Advertisements

Prof. Yitzchak Rosenthal
Mouse Tutorial for Win XP In this tutorial you will learn to: Move the mouse Click and double click Make selections Manage windows Use menus Click the.
Lesson 1 & 2 Review Lesson 1 & 2 Activities (Smart Notebook)
© The McGraw-Hill Companies, 2006 Chapter 18 Advanced graphics programming.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Creating Menu. Objectives Create a menu system for a form –Create a menu –Create a menu titles –Create a menu items –Create a submenu –Modify menu –Edit.
Chapter 8: String Manipulation
Programming with Microsoft Visual Basic th Edition
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
1 CA201 Word Application Increasing Efficiency Week # 13 By Tariq Ibn Aziz Dammam Community college.
Microsoft Windows Vista Chapter 1 Fundamentals of Using Microsoft Windows Vista.
Office 2013 and Windows 8: Essential Concepts and Skills Microsoft Access 2013.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Microsoft Windows 7 Part 1 Fundamentals of Using Windows 7.
Introduction to MS WORD.
Introduction To Microsoft Word C Apply intermediate skills in utilizing word processing software Word processing programs make the writing process.
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
XP New Perspectives on Windows XP Tutorial 1 Exploring the Basics.
Chapter 3 – Part 1 Word Processing Writer for Linux CMPF 112 : COMPUTING SKILLS.
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
Classic Controls Trần Anh Tuấn A. Week 1 How to create a MFC project in VS 6.0 How to create a MFC project in VS 6.0 Introduction to Classic Controls.
BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
XP New Perspectives on Microsoft Windows 2000 Professional Windows 2000 Tutorial 1 1 Microsoft Windows 2000 Professional Tutorial 1 – Exploring the Basics.
Introducing… Microsoft Windows VISTA Introducing… Microsoft Windows VISTA.
Exploring Windows and Essential Computing Concepts 1 Windows Desktop u Windows Basics u Icon u Start Button u My Computer u Network Neighborhood u Recycle.
Menu Messages  Besides the all-important WM_COMMAND message, window provides five other messages at various stages of menu selection:  WM_SYSCOMMAND.
Lecture 7 Menu, controls, scroll bars. Menu Menu item sends WM_COMMAND message to the application window Menu is attached to window when the window is.
SIMSWeb “Internet Remote Access” The most advanced central station software in the universe !
Engineering\CADD Systems Office CADD Manager's Series Customizing the Interface.
Visual Basic CDA College Limassol Campus Lecture:Pelekanou Olga Semester C Week - 1.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
CHAPTER:08 JAVA IDE PROGRAMMING-III Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Microsoft Office 2010 is the newest version of Microsoft Office, offering features that provide users with better functionality and easier ways to work.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
Catholic University College of Ghana Fiapre-Sunyani INFORMATION TECHNOLOGY I Audrey Asante, Faculty of ICST Graphic User Interface Tutorials and Documentation.
Windows Basics Computers 1. Windows Desktop What is the desktop? What is the desktop? –On-screen work area on which windows, icons, menus, and dialog.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
The WM_NCHITTEST Message  This is an internal message used by Windows for generating all the other mouse messages.  Though it almost never needs to be.
Introduction to OpenGL
Inserting an Image Using the WordPress media manager, it’s extremely simple to insert, align and link your individual images and image galleries. To insert.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Word 2010 © 2011 The McGraw-Hill Companies,
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
XP New Perspectives on Microsoft Windows XP Tutorial 1 1 Microsoft Windows XP Creating a Web Site Tutorial 1.
 The clipboard is a temporary storage area  The cut or copy commands place information on the CLIPBOARD  There are two types of clipboards: – System.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Building a User Interface with Forms
Windows Programming Lecture 09.
18 & 19.
Windows Programming Model
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Chapter 1: An Introduction to Visual Basic 2015
Microsoft Windows 2000 Professional
The program in traditional OS
Chapter 5 The MFC Collection Classes
Chapter 4 Menu and Chapter 6 File I/O
Prepare a DD Form 1081-Return
19.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
GUI Socket Application
Presentation transcript:

Menus  Menus is a feature which is common to almost every windows applications. It is the one of the most common user interface elements around.  Windows does most of the work involved in menu handling, including displaying the menu bar, displaying a drop-down menu when an item on a menu bar is clicked and notifying the application when a menu item is selected.  There are basically 3 types of menus in a windows application: a system menu, a popup menu and a drop-down menu.

Contd….  Most applications have a ‘system menu’ containing commands for restoring, moving, size, minimizing, maximizing and closing the window.  Another type of the menu is the ‘popup menu’ which can be popped up anywhere on the screen by clicking the right mouse button.  The third type of the menu is a ‘drop-down’ menu that appears as a submenu for the menu items in the menu bar at the top of the window.

Creating a Menu  There are three ways to create a menu. The easiest way is to create a menu template in your application’s ‘rc’ file using the resource editor.  Once this menu is created it can be loaded into your application’s window by spacifying the resource ID of the menu while creating the window.  Instead of specifying the resource ID while creating the window we may first create the window and then load the menu using CMenu::LoadMenu() function.

Contd….  Sometimes it is not possible to determine the menu’s contents until run-time.  In such cases menus can be created programmatically using functions like CreateMenu(), InsertMenu(), appendMenu(), etc., all of which are members of the MFC CMenu class. The functionality of creating and handling a menu has been implemented in this class.  The third and more difficult method of creating a menu is to fill a series of data structure defining the menu’s contents and then create the menu using CMenu::LoadMenuIndirect() function.

MENU-ALTERING FUNCTIONS  CreateMenu() :- Creates a new menu, ready to add items.  CreatePopupMenu():- Creates a new popup menu, ready to receive items.  SetMenu() :- Attaches menu to a window; often used with  LoadMenu():- to switch between several menus used by the program.  AppendMenu() :-Adds a new menu item or popup to the end of a menu.  InsertMenu():- Inserts a new menu item or popup into a menu/popup menu.  DeleteMenu():- Removes a menu item from a menu or popup menu.

Contd…  DestroyMenu() :-Deletes an entire menu, removing it from memory; only needed if the menu was loaded but not attached to a window.  DrawMenuBar() :-Draws the menu bar (in main menu area below window caption), making any changes visible.  LoadMenu() :- Loads a menu from the program's resource data, ready tos be attached to a Window with SetMenu().  EnableMenuItem():- is used to enable or disable a specified menu item in the menu: EnableMenuItem(hmenu, idEnableItem, ActionFlag);

Basic sequence 1.Use CreateMenu() to create a new, empty menu with which to start;returns a handle to the new menu. 2. Use AppendMenu() and/or InsertMenu() to add menu items as needed. 3. Use SetMenu() to attach the menu to a window, so it can be used.

Creating a menu Switch(message) { case: WM_CREATE: int hm; Hm=CreateMenu(); AppendMenu(hm, MF_STRING|MF_ENABLED)) } SetMenu(hwnd, hm);

Write a program to load a menu in a window #include #include "resource.h" class myframe:public CFrameWnd { public: myframe() { Create(0,"LoadMenu",WS_OVERLAPPEDWINDOW, rectDefault,0,MAKEINTRESOURCE(IDR_MENU1)); } };

class myapp:public CWinApp { public: int InitInstance() {myframe *p; p=new myframe; p->ShowWindow(3); m_pMainWnd=p; return 1; } }; myapp a;

Creating a popup menus  Building a popup menu is similar like creating the menu.  We just use the CreatePopupMenu() function instead CreateMenu().  We can organizing the items of the popup menu into the logical groups. This can be done by specifying the MF_SEPARATOR flag in an AppendMenu() call.  Having filled out our popup menu, we can display it and obtain user selections from it by calling the TrackPopupMenu() function.

Basic sequence  If the main menu contains popup menus, the popups are created separately, and then attached to the menu as follows: 1.Use CreatePopupMenu() to create a new, empty popup menu. Returns a handle to the popup menu. 2.Use AppendMenu() or InsertMenu() to add menu items to popup as needed. 3. Use AppendMenu() or InsertMenu() to add the finished popup menu to the main menu.

Creating the popup menu #include"resource.h" #include"afxwin.h" #include"windows.h" HWND hwnd; long WindowProc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp); int _stdcall WinMain(HINSTANCE h, HINSTANCE hp, char *r, int i) { MSG msg; WNDCLASS wc;s

if(!hp) { wc.style=CS_HREDDRAW|CS_VREDDRAW|CS_DBLCL KS; wc.lpfnWndProc=WindowProc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hInstance=h; wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_ BRUSH); wc.hCursor=NULL; wc.lpszClassName="my"; RegisterClass(&wc); }

hwndMainWindow=CreateWindow("my","hello",WS_OVERLAP PEDWINDOW,CW_USEDEFAULT,NULL,NULL,h,NULL); ShowWindow(hwndMainWindow,3); UpdateWindow(hwndMainWindow); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }

long WindowProc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) { static LPSTR lpszDinnerItem[]= { "soup", "salad","vegitable", "wine" }; #define DINNER_ITEM_COUNT(sizeof(lpszDinnerItem)/sizeof(LPSTR)) #define STATIC_COUNT 10 static HMENU hmenu; static HWND hwndbutton; static HWND hwndstatic(STATIC_COUNT); static int index=0; int i;

switch(message) { case WM_CREATE: hmenu=CreatePopupMenu(); for(i=0;i<DINNER_ITEM_COUNT;i++) {AppendMenu(hmenu,MF_STRING|MF_ENABLE,I,lpszDinnerItem s[i]); } #define BUTTON_ID 100 hwndbutton=CreateWindow("BUTTON","dinnermenu", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, hwnd,(HMENU)BUTTON_ID,h,0);

for(i=0;i<STATIC_COUNT;i++) { hwndstatic[i]=CreateWindow("STATIC","static menu",WS_CHILD|WS_VISIBLE,CW_USEDEFAULT,CW_ USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hw nd,(HMENU)i,h,NULL); randomize(); return 0;

case WM_COMMAND: if(wparam==BUTTON_ID) TrackPopupMenu(hmenu,0,random(GetSystemMetrics (SM_CXSCREEN)), random(GetSystemMetrics(SM_CYSCREEN)),0,hwnd,NULL); } case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wp,lp); }

Menu Messages