Download presentation
Presentation is loading. Please wait.
Published byArthur Holland Modified over 9 years ago
1
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler
2
Who’s in charge Here? The Computer ▫Many text-based console applications Computer says: “Enter username: “ Choices ▫Enter a username ▫Stop the program The User ▫Event-driven/Graphical applications Computer responds to what the user does (events): Click a button Type a command Drag an icon
3
Event-driven Programming Desktop Programming ▫Windows Programming ▫X Window Programming (linux) Mobile Programming ▫Android Programming ▫iPhone Programming Web Programming ▫ASP.NET ▫JavaScript
4
Events (Messages) Mouse Clicks Mouse Movements Keyboard events (a character is pressed) Timer events (timer expires) Windows Events (e.g., a window gets/loses focus) System events (e.g., system shutdown)
5
Events are Described in Messages Messages have a unique identifier (message number) Message can carry parameters – for example: ▫Cursor coordinates on a mouse click ▫The object that caused the message to be sent ▫The character that was typed ▫The mouse button that was pressed
6
Messages Enter a Message Queue Third Message Second Message First Message Are Processed by a Message Loop
7
Message Loop While the program is still running (no quit message) ▫Read a message from the message queue ▫Decode the message ▫Invoke the functions that have been associated with that message
8
Associating Functions with Messages C/C++ Function Pointers ▫Point to functions called “callbacks” C# Delegates ▫Safer types of function pointers
9
Function Pointers in C++ Functions that return pointers ▫A function that returns a char* char* functionThatReturnsAPointer(int x); Pointers to functions ▫A pointer to a function that returns a char* char* (*ptrName)(int x);
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.