BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
Advertisements

Computer Graphics1 Windows NT Graphics Interface.
QT – Introduction C++ GUI Programming with Qt 4 Blanchette and Summerfield, Ch. 1 Miller, 2004.
The Web Warrior Guide to Web Design Technologies
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
Cmput Lecture 8 Department of Computing Science University of Alberta ©Duane Szafron 2000 Revised 1/26/00 The Java Memory Model.
IN-LAB # 1 - GETTING STARTED - BUT FIRST: 1.Project ideas - watch the scope!!! 2.Check accounts 3. Either myself or the TA need to check you off BEFORE.
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
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)
Chapter 7: Sub and Function Procedures
1 CSC 221: Computer Programming I Fall 2004 Objects and classes: a first pass  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Win32 API Programming Event-driven, graphics oriented Example: User clicks mouse over a program’s window area (an event) -- – Windows decodes HW signals.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Using Visual Basic for Applications (VBA) – Project 8.
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.
Further games and graphics concepts COSE50581 Introduction to Module and Recap Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
RIGHT Mouse Button Formatting Cut Copy Paste Save LEFT Mouse Button MAIN BUTTON Single clicks Double clicks Drag Highlight.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
XP New Perspectives on Windows 2000 Professional Windows 2000 Tutorial 2 1 Microsoft Windows 2000 Professional Tutorial 2 – Working With Files.
1 CSC 221: Computer Programming I Spring 2008 Objects and classes: a broad view  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Concurrent Programming and Threads Threads Blocking a User Interface.
Presentation Outline Introduction Painting and Repainting GDI.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Bitmap (Chapter 15).
Registering a window class Windows allows many styles of window to be created. To tell Windows to create a window as you want it you need to define a class.
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,
Creating a DirectX Project A DirectPLay Chat Program.
1 Programming and Software Engineering. 2 Software Development We can define two main classes of software: User-written software solve a particular problem,
Application software- programs that let you do things What are some computer programs that you or your parents use on the computer?
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.
Learning Programming Windows API Morpheus Feb-28, 2008.
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
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.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Presentation Outline Introduction Painting and Repainting GDI.
Windows Programming Lecture 10.
Visual Programming Lecture 1 & 2
An Introduction to Computers and Visual Basic
Windows Programming Lecture 09.
Window.
Windows Programming Model
An Introduction to Computers and Visual Basic
Microsoft Windows 2000 Professional
Queued and Nonqueued Messages
The program in traditional OS
Windows Programming Lecture 12
Windows Programming Lecture 13
Building a Win32API Application
An Introduction to Computers and Visual Basic
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
GUI Socket Application
Presentation transcript:

BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.

BZUPAGES.COM  Window is the rectangular area that a particular program occupies on the screen.  Single program can create many windows, usually the program has a single main or top- level window.  From the programmer’s perspective, a window is an object that receives and processes messages.

BZUPAGES.COM  Most messages come from Windows, but a window can also send itself a message.  A window is one program can send a message to a window in another program.  This can be visualized as a type of electronic mail system in which windows can communicate with each other.  These messages are put into a loop called as Message Queue.  Two kinds of message queues are  System Queue  Application Queue

BZUPAGES.COM  System Queue: There will be only one queue available for windows. Whenever an event occurs through a hardware the event name will be put into this queue in the name of a message.  Application Queue: Every application has its own queue. This queue gets messages from the System Queue.

BZUPAGES.COM  Finally the message goes to the message loop. This message loop gets the message from Application Queue and translates it into Windows character message and sends it to the appropriate Windows procedure.

BZUPAGES.COM

#include Int _stdcall WinMain(HINSTANCE i,HINSTANCE j,char *k,int l) { HWND h; h=CreateWindow(“BUTTON”,”PressMe”,WS_OVERL APPEDWINDOW,10,10,150,100,0,0,I,0); ShowWindow(h,l); MessageBox(0,”BS-IT 5th”,”Computer”,0); return(0); }

BZUPAGES.COM  A window is always created based on a window class.  The window is created using the CreateWindow function.  Here HWND is the handle to the window. HWND:  Each window has a handle which is the pointer to the window code in the memory.  this handle is called HWND.  Whenever a window is created using CreateWindow() function of SDK, it returns this pointer “hwnd” which points to the window code in the memory.

BZUPAGES.COM CreateWindow(“BUTTON”,”PressMe”,WS_OVE RLAPPEDWINDOW,10,10,150,100,0,0,0); Parameters: 1. First parameter passed to Create() is the name of the window class. 2. The Second parameter indicates the text that is going to appear on the button surface. 3. The third parameter specifies the window style. 4. The next four parameters specify the window’s initial position and size.(x,y,width,height) 5. The next three parameters specify the handles to the parent window, the menu and application instance. 6. The last parameter contains the extra informations.

BZUPAGES.COM  The next function call  ShowWindow(hWND,nCmdShow);  hWnd  is the handle to the window.  nCmdShow  specifies how the window is to be displayed and is passed to WinMain as the argument.

BZUPAGES.COM  How do I get several windows on the screen?

BZUPAGES.COM  To create and display a window the following steps are to be followed.  Set up the window class  Register the window class  Create the window  Display the window  Paint the client area of the window.

BZUPAGES.COM

#include long _stdcall myfunc(HWND,UINT,UINT,long); WNDCLASS a; int _stdcall WinMain(HINSTANCE i,HINSTANCE j,char *k,int l) { HWND h; MSG m; a.hInstance=i; a.lpszClassName="sadaf"; a.lpfnWndProc=myfunc; RegisterClass(&a); h=CreateWindow("sadaf","title",WS_OVERLAPPEDWINDOW,20,20,300, 200,0,0,i,0); ShowWindow(h,l); while(GetMessage(&m,0,0,0)) DispatchMessage(&m); return 0; } long _stdcall myfunc(HWND w, UINT x, UINT y, long z) { switch(x) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(w,x,y,z); } return 0; }

BZUPAGES.COM  The WNDCLASS has 10 fields 1. Wndclass.style = CS_VREDRAW | CS_HREDRAW Specifies the style of the window. 2. Wndclass.lpfnWndProc = (WNDPROC); Specifies the message handling function of the window. 3. Wndclass.cbClsExtra = 0; reserve the some extra space at the end of the copy of the window class structure that the window stores. 4. Wndclass.cbWndExtra = 0; reserves some extra space at the end of all data structure for windows based on this class. 5. Wndclass.hInstance=hInstance; is the instance handle of the program. This is passed to the program as a parameter to WinMain.

BZUPAGES.COM 6. Wndclass.hCursor = LoadCursor (Null, IDC_ARROW); specifies the shape the mouse cursor will take when it is positioned over the client area of our window. 7. Wndclass.hIcon=LoadIcon(Null, IDI_APPLICATION0); Specifies the icon associated with a window. The icon will be displayed when the window is minimized. 8. Wndclass.lpszMenuName = Null; is the name of the menu associated with our field. 9. Wndclass.hbrBackground= GetStockObject(WHITE_BRUSH); spcifies the brush to be used when a window needs to be painted.The program specifies a White Brush. 10. Wndclass.lpszClassName=“keybuttclass” contains the name of the window class.

BZUPAGES.COM  After filling up the WNDCLASS struct, register the class with RegisterClass(&wndclass);

BZUPAGES.COM  Once the window class is registered, WinMain() calls the CreateWindow() function to create the application’s window.  Then GetMessage() function extracts messages from the message queue of our applications.  DispatchMessage( ) function dispatches the messages received to our window procedure, myfunc().

BZUPAGES.COM  Messages can be handles by our window procedure. If we don’t want to handle them then they should be passed on the default window procedure by calling the DefWindowProc( ) function.  WM_DESTROY message is generated when we close the window. ◦ When we receives this message the loop will be terminated.

BZUPAGES.COM 1. Draw a flowchart of Windows 3.1 Architecture and Windows 95 Applications. 2. Draw a simple flowchart of Windows program. 3. List out the Windows Type Styles that uses in CreateWindow( ) function.(atleast 15) 4. Explain in brief API. 5. Explain the various steps to create and display a window. 6. Write a program to display “Hello” at any place where I click with the left mouse button in the window?

BZUPAGES.COM Dated: