Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
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.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Wimba Pronto Office Hours of the ND University System April 2009.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
Intro to Windows Programming Basic Ideas. Program Entry Point Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
Child Window Controls Unit I Topic 5.
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area (an event) -- – Windows decodes HW signals.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
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.
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.
Lecture Two Event Handling Keyboard and Mouse Input.
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.
Server Core is the preferred deployment configuration.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
Winsock Programming Blocking and Asynchronous Sockets for Windows.
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.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
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.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Chapter 8 Dialog Boxes and Property Sheet. 2 Two kinds of dialog boxes Dialog boxes –Modal dialog When appear, it takes all ownership of input. It disables.
Modal Dialogs. What is a Modal Dialog? A modal dialog is a separate window that remains in focus until it is closed by the user. During this time the.
About Windows Jihoon.Yim About Windows 2 Desktop Window Application Windows Client & Nonclient Area Control and Dialog Boxes Desk Window.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
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.
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.
Object-Oriented Programming: Inheritance and Polymorphism.
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.
Learning Programming Windows API Morpheus Feb-28, 2008.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
W indows Programming Lecture 08. Brief History of Win Windows is announced 1984 Work begins on Word for Windows 1.0 November 1985: Windows 1.0.
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Windows Programming Lecture 11
Windows Programming Lecture 10.
Windows Programming Lecture 09.
Window.
18 & 19.
Windows Programming Model
Working with Dialogs and Controls
Dialog Boxes and Property Sheets
Queued and Nonqueued Messages
The program in traditional OS
Made by Aistė Augustinaitė Software Engineering 3 group
Dialogs.
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
28.
Windows Programming Lecture 13
Building a Win32API Application
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
21-22.
19.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
GUI Socket Application
Presentation transcript:

Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break ; } return 0 ;

BOOL CALLBACK About (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG : return TRUE ; case WM_COMMAND : switch (LOWORD (wParam)) { case IDOK : case IDCANCEL : EndDialog (hDlg, 0) ; return TRUE ; } break ; } return FALSE ; }

Modal dialog box Created using: –DialogBox, DialogBoxIndirect, DialogBoxParam, DialogBoxIndirectParam Disables dialog window owner until the dialog is closed Closed by the EndDialog function. Result of the DialogBox function is the argument passed to the EndDialog function

Dialog procedure Similar to window procedure Returns TRUE if it message was processed FALSE if not Does not call DefWindowProc Should not process WM_PAINT, WM_DESTROY messages Does not receive WM_CREATE, instead it receives WM_INITDIALOG message

WM_INITDIALOG WM_CREATE is sent to the window right after it has been created WM_INITDIALOG is sent to the dialog after all its controls have been created. In WM_INITDIALOG application can access controls, e.g.: –enable or disable controls –fill controls with data (e.g. ListBoxes) –set initial values of Edit controls –set initial state of checkboxes and radio buttons

Controls Controls are regular windows (child windows) –They have window handle and process messages like any other window –To get window handle for the control use GetDlgItem function HWND GetDlgItem(HWND hDlg, int itemId); itemId is the child window number. For dialogs created from resource template this will be the control id from the resource file - Any function that operates on window handle can be used on a control, e.g.: MoveWindow - move window on the screen ShowWindow - show / hide window EnableWindow - enable / disable window

Using controls To set/get text from EDIT control: –SetWindowText or SetDlgItemText –GetWindowText or GetDlgItemText To set/get checkbox and radio button selection: –CheckDlgButton –IsDlgButtonChecked To add elements to LISTBOX –Send LB_ADDSTRING message to add element to LISTBOX –Send LB_SETCURSEL message to select element in a LISTBOX

Using controls LISTBOX example: HWND hListWnd = GetDlgItem( hDlg, IDC_LIST ); SendMessage( hListWnd, LB_ADDSTRING, 0, (LPARAM)"item 1" ); SendMessage( hListWnd, LB_ADDSTRING, 0, (LPARAM)"item 2" ); SendMessage( hListWnd, LB_ADDSTRING, 0, (LPARAM)"item 3" ); SendMessage( hListWnd, LB_ADDSTRING, 0, (LPARAM)"item 4" ); SendMessage( hListWnd, LB_ADDSTRING, 0, (LPARAM)"item 5" ); SendMessage( hListWnd, LB_SETCURSEL, 2, 0 );

Dialog box is a regular window, so any function that operates on windows works for dialog boxes (e.g. MoveWindow) Area covered by controls is painted by controls. Dialog cannot paint over the area occupied by controls (usually dialog does not paint at all) If mouse cursor is over the control, the control handles mouse messages All keyboard messages are processed by the dialog and some of them are passed to controls Modal dialog box has its own message loop Dialog boxes

Modeless dialog boxes don’t disable parent window, so user can work in both windows To create modeless dialog box use: HWND CreateDialog(HINSTANCE hInstance, LPCSTR template, HWND parent, DLGPROC lpDialogFunc ); This function does not wait for the dialog box to close (it works like CreateWindow) The window must be destroyed using DestroyWindow function (don’t call EndDialog!) Modeless dialog boxes

Modeless dialog box requires change to the application message queue: while (GetMessage (&msg, NULL, 0, 0)) { if (hDlgModeless == 0 ¦¦ !IsDialogMessage (hDlgModeless, &msg)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } Modeless dialog boxes

IsDialogMessage – checks if message is intended for the dialog box and if so, processes the message –TAB key moves focus to the next group of controls –DOWN key moves focus to the next control in a group –ENTER key pushes the default pushbutton for the dialog IsDialogMessage can be used for any type of window IsDialogMessage