Download presentation
Presentation is loading. Please wait.
1
Mouse event handling Mouse events( delegates EventHandler, event arguments EventArgs) MouseEnter: raised if the mouse cursor enters the area of the control MoueLeave: raised if the mouse cursor leaves the area of control
2
Mouse events(delegates MouseEventHandler, event arguments MouseEventArgs) MouseDown:raised if the mouse button is pressed while its cursor is over the area of the control MouseHover:Raised if the mouse cursor hovers over the eara of the control MouseMove: Raised if the mouse cursor is moved while in the area of the control MouseUp: Raised if the mouse button is released when the cursor is over the area of the control
3
MouseEventArgs properties Button: Mouse button that was pressed(left, right, middle or none) Clicks: the number of times the mouse button (either mouse button) was clicked X: the x-coordinate of the event, relative to the control Y: the y-coordinate of the event, relative to control
4
Graphics Create a Graphics class object and use it to draw on the form Graphics *graphic = CreateGraphics(); Method FillEllipse draws a circle graphics->FillEllipse(new SolidBrush(Color::BlueViolet), e->X,e->Y,4,4);
5
Assignment Extend the example to include options for changing the the size and color of the lines drawn Create a drawing area Hint: Have variables to keep track of the currently selected size(int ) and color( Color object ). Set them using the eventhandlers for the radio buttons. For the color, use the various Color constants ( such as Color::Blue). When responsding to the mouse moves, simply use the size and color variables to determine the proper size and color
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.