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.

Slides:



Advertisements
Similar presentations
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Advertisements

What is a Dialog box? A Dialog box is a window or “form” that contains other child windows or “controls” that have a specific appearances and pre-defined.
Using Macros and Visual Basic for Applications (VBA) with Excel
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Introduction To Form Builder
1 Chapter 5: Introduction To Form Builder. 2 Forms  Why Do We Use Form Builder?  Why Don’t We Use SQL Only?!
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.
Child Window Controls Unit I Topic 5.
PYP002 Intro.to Computer Science Microsoft Word1 Lab 07 Creating Documents with Efficiency and Consistency.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
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.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Basic WPF Controls Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
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.
Working with option button, check box, and list box controls Visual Basic for Applications 13.
XP New Perspectives on Microsoft Windows 2000 Professional Windows 2000 Tutorial 1 1 Microsoft Windows 2000 Professional Tutorial 1 – Exploring the Basics.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Chapter 7 Controls.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Menu Messages  Besides the all-important WM_COMMAND message, window provides five other messages at various stages of menu selection:  WM_SYSCOMMAND.
Chapter 7 Controls. Scroll bar control 3 Scroll bar control (1/3) Scroll bar codes (interfaces)
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Chapter 7 Controls. 2 Introduction (1/4) Control –Special kind of window –Designed to convey information to the user or to acquire input –Reduce the tedium.
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.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Chapter 7 Controls. List box control 3 List Box Control(1/8) Listbox control: –Display lists of text strings called items –Optionally sort the items.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
1 Chapter 6: Creating Oracle Data Block Forms. 2 Forms  Application with a graphical user interface that looks like a paper form  Used to insert, update,
Menu & Clipboard Menu Cut / Copy / Paste. Menus Created in the Menu Editor Can contain menu titles, menu items, separator bars, submenu titles, and submenu.
Excel Tutorial 8 Developing an Excel Application
Graphical User Interface
Chapter 2: The Visual Studio .NET Development Environment
Windows Programming Lecture 11
Creating LOVs and Editors
Windows Programming Lecture 09.
Using Procedures and Exception Handling
Microsoft Excel 2003 Illustrated Complete
Microsoft Windows 2000 Professional
COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often.
Windows Programming Lecture 12
CIS 16 Application Development Programming with Visual Basic
Building a Win32API Application
Windows Programming Lecture 15
Web Development Using ASP .NET
21-22.
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2011
Lab 07 Creating Documents with Efficiency and Consistency
Presentation transcript:

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 created Menu can be created using Visual C++ Resource Editor Menu can be modified at run time: –Items can be disabled, enabled, checked (EnableMenuItem, CheckMenuItem, CheckMenuRadioItem) –Items can be added and removed as required (AppendMenu, DeleteMenu, RemoveMenu) –Menu item can be modified (ModifyMenu)

WM_COMMAND handler: case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; }

Menu functions: –LoadMenu – load menu from resources –GetMenu – get menu handle from window handle –GetSystemMenu – get handle to system menu (menu that has Minimize, Restore, Close commands) –SetMenu – set (or replace) window menu –CreateMenu, CreatePopupMenu – create dynamically new menu instead of loading it from resources –TrackPopupMenu, TrackPopupMenuEx – display and track poupu menu on the screen

Menu functions (cont): –GetMenuItemCount – returns number of items in the specified menu –GetMenuItemID – get menu item ID (command ID assigned to that menu item) –GetMenuItemInfo – get information about menu item –GetMenuState – get state of the menu item (if it is checked, disabled, grayed etc.) –GetMenuString – get menu item string

Menu functions (cont): –InsertMenuItem – insert new menu item or sub-menu to the menu –AppendMenu – add new item or sub-menu at the end of the menu –CheckMenuItem – add or remove check mark from menu item –CheckMenuRadioItem – position check mark on a group of menu items –SetMenuItemInfo – modify menu item –RemoveMenu – remove menu item or detach sub- menu from the specified menu

WM_COMMAND message wParam –The high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero. –The low-order word specifies the identifier of the menu item, control, or accelerator. lParam –Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.

Controls Control - child window that specializes in some task, e.g.: –button control - can be pressed –list control - presents list of values –edit control - allows user to enter some text Control must have parent window (because it is a child window) Control notifies its parent when important event occurs, e.g. –button control notifies parent when it is pressed –list control notifies parent when selection changes –edit control notifies parent every time the text inside the control changes

Controls Notifications by controls are done using SendMessage function Standard (predefined) controls send WM_COMMAND as the notification message

Predefined controls BUTTON – button control. This includes: –push buttons –checkboxes –radio buttons LISTBOX – list control COMBOBOX – drop down list control EDIT – edit control (for editing text) STATIC – static text (usually label for other control) RichEdit, RICHEDIT_CLASS – rich edit control SCROLLBAR – scroll bar control

Creating predefined control HWND hWndButton = CreateWindowEx( 0, // extended style "BUTTON", // predefined class name "Button text",// button text WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// style 100, 100,// position 70, 30,// size hWndParent,// parent window (HMENU)102,// control identifier hInstance,// instance hande NULL );

WM_COMMAND messages sent by this button will have: –lParam == hWndButton –LOWORD( wParam ) == 102 // (control id) –HIWORD( wParam ) == notification code, e.g.: BN_CLICKED - button was clicked BN_DOUBLECLICKED BN_KILLFOCUS BN_SETFOCUS

Customizing predefined controls To customize predefined control: –Use one of predefined styles for that control (when creating control), e.g: buttons - BS_PUSHBUTTON, BS_RADIOBUTTON edit controls - ES_READONLY, ES_UPPERCASE –Send message to the control, e.g. list boxes - LB_ADDSTRING, LB_RESETCONTENT edit controls - EM_GETLINE, EM_GETLINECOUNT, EM_GETSEL

HWND hWndListBox = CreateWindowEx( 0, "LISTBOX",// class name "",// window title WS_CHILD | WS_VISIBLE,// style 100, 100,// position 170, 150,// size hWndParent,// parent window handle (HMENU)103,// control identifier hInstance,// instance handle NULL ); SendMessage( hWndListBox, LB_ADDSTRING, 0, (LPARAM)"First Item" ); SendMessage( hWndListBox, LB_ADDSTRING, 0, (LPARAM)"Second Item" ); SendMessage( hWndListBox, LB_SETCURSEL, 1, 0 );

Can be created in two ways: –as a scroll bar attached to a window (standard scroll bar) –as a control using „SCROLLBAR” class Standard scroll bar is created automatically and: –it is automatically resized/moved when the window is resized –it is created on non-client area of the window –it does not have window handle Scroll bar control must be: –manually created, moved and resized –it does have normal window handle –it is created on its parent window client area Scroll bars

To create window with scroll bars: hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); SCROLLINFO si; si.cbSize = sizeof( si ); si.fMask = SIF_ALL; si.nMin = 0;// minimum scrollbar position si.nMax = 100;// maximum scrollbar position si.nPos = 50;// current scrollbar position si.nPage = 10;// page size SetScrollInfo( hWnd, SB_HORZ, &si, false ); Standard scroll bar

// horizontal scroll bar CreateWindow( "SCROLLBAR", "", WS_CHILD | WS_VISIBLE, 30, 50, 100, 20, hWnd, (HMENU)100, hInstance, NULL ); // vertical scroll bar CreateWindow( "SCROLLBAR", "", WS_CHILD | WS_VISIBLE | SBS_VERT, 30, 80, 20, 100, hWnd, (HMENU)101, hInstance, NULL ); Scroll bar controls

Scroll bar sends WM_HSCROLL or WM_VSCROLL messages wParam can take one of the following values: SB_ENDSCROLL SB_LEFT SB_RIGHT SB_LINELEFT SB_LINERIGHT SB_PAGELEFT SB_PAGERIGHT SB_THUMBPOSITION SB_THUMBTRACK lParam handle to the scroll bar control (or NULL) Scroll bar messages

Application is responsible for: Setting scroll bar sizes (SetScrollInfo function) Handling scroll bar messages (e.g. WM_HSCROLL) application should move scrollbar position (using SetScrollInfo or SetScrollPos) remember current scrollbar position in some variable invalidate the window Drawing window content scrolled by scrollbar position Application can scroll window content using ScrollWindow, ScrollWindowEx or ScrollDC functions and then invalidate only portion of the window Handling scroll bars