CHAPTER 19 BUILDING A BETTER WINDOW WITH (Web hosting isp)
CHAPTER 19 BUILDING A BETTER WINDOW WITH SYSTEM.WINDOWS.FORMS 615 namespace MyWindowsApp { public class MainWindow : Form { public MainWindow() { // Use inherited properties to set basic UI. Text = “My Fantastic Form”; Height = 300; Width = 500; BackColor = Color.LemonChiffon; Cursor = Cursors.Hand; } } public static class Program { static void Main(string[] args) { Application.Run(new MainWindow()); } } } Compile your application at this point, just to make sure you have not injected any typing errors: csc /target:winexe *.cs Responding to the MouseMove Event Next, you need to handle the MouseMove event. The goal is to display the current (x, y) location within the Form s caption area. All mouse-centric events (MouseMove, MouseUp, etc.) work in conjunction with the MouseEventHandler delegate, which can call any method matching the following signature: void MyMouseHandler(object sender, MouseEventArgs e); The incoming MouseEventArgs structure extends the general EventArgs base class by adding a number of members particular to the processing of mouse activity (see Table 19-6). Table 19-6. Properties of the MouseEventArgs Type Property Meaning in Life Button Gets which mouse button was pressed, as defined by the MouseButtons enumeration Clicks Gets the number of times the mouse button was pressed and released Delta Gets a signed count of the number of detents the mouse wheel has rotated X Gets the x-coordinate of a mouse click Y Gets the y-coordinate of a mouse click Here, then, is the updated MainForm class that handles the MouseMove event as intended: public class MainForm : Form { public MainForm() {
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.