How can I get just the extension of a file from the complete path string?
Use FileInfo. Instantiate a FileInfo object with the full path as constructor arg. Then simply call FileInfo.Extension and you will get just the extension of the file. FileInfo finfo = new FileInfo(strFileName); Console.WriteLine(finfo.Extension);
How can I get just the name of a file from the complete path string?
Use FileInfo. Instantiate a FileInfo object with the full path as constructor arg. Then simply call FileInfo.Name and you will get just the name of the file. FileInfo finfo = new FileInfo(strFileName); Console.WriteLine(finfo.Name);
How can I determine if a mouse button is pressed and moving over my form
Catch the form’s MouseMove event which is called when the mouse moves over the form. To determine if a button is pressed during the move, check the event arg’s Button property. The code below draw’s a line on the form as the mouse moves over it. The line is red when the left button is pressed, white when the right button is pressed and blue when no button is pressed. private Point _point = new Point(-1, -1); …. private void InitializeComponent() { // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 273); this.Name = ‘Form1’; this.Text = ‘Form1’; this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); } …. private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if(_point.X == -1) _point = new Point(e.X, e.Y); Color c; if(e.Button == MouseButtons.Left) c = Color.Red; else if(e.Button == MouseButtons.Right) c = Color.White; else if(e.Button == MouseButtons.None) c = Color.Blue; else c = this.BackColor; Point p = new Point(e.X,e.Y); Graphics g = Graphics.FromHwnd(this.Handle); Pen pen = new Pen(c,1); g.DrawLine(pen,_point,p); _point = p; pen.Dispose(); }
How can I graphically set the tab order for controls on a form
While MFC programmer’s have had this feature available in earlier versions of Visual Studio, VB programmers have not. To display tab orders on the active design mode Form, select the View | Tab Order menu item. Then click the numbers on each control to reset their tab order.
How do the Win32 System Colors map to the colors provided by System.Drawing.SystemColors?
The following table lists all Win32 System Colors and the corresponding name in System.Drawing.SystemColors type: GetSysColor(n) SystemColors. COLOR_ACTIVEBORDER ActiveBorder COLOR_ACTIVECAPTION ActiveCaption COLOR_CAPTIONTEXT ActiveCaptionText COLOR_APPWORKSPACE AppWorkspace COLOR_3DFACE Control COLOR_3DSHADOW ControlDark COLOR_3DDKSHADOW ControlDarkDark COLOR_3DLIGHT ControlLight COLOR_3DHIGHLIGHT ControlLightLight COLOR_BTNTEXT ControlText COLOR_DESKTOP Desktop COLOR_GRAYTEXT GrayText COLOR_HIGHLIGHT Highlight COLOR_HIGHLIGHTTEXT HighlightText COLOR_HIGHLIGHT HotTrack COLOR_INACTIVEBORDER InactiveBorder COLOR_INACTIVECAPTION InactiveCaption COLOR_INACTIVECAPTIONTEXT InactiveCaptionText COLOR_INFOBK Info COLOR_INFOTEXT InfoText COLOR_MENU Menu COLOR_MENUTEXT MenuText COLOR_SCROLLBAR ScrollBar COLOR_WINDOW Window COLOR_WINDOWFRAME WindowFrame COLOR_WINDOWTEXT WindowText COLOR_3DHILIGHT ControlLightLight COLOR_BTNHIGHLIGHT ControlLightLight COLOR_BTNHILIGHT ControlLightLight COLOR_BACKGROUND Desktop