Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

Browse by Tags

All Tags » Graphics (GDI+) (RSS)


  • How can I sync system font changes?

    The following example explains how to correctly sync system font changes and make the dynamic change in your applciation. Hook UserPreferenceChanged Set the Form font again when this event is raised Unhook from UserPreferenceChanged in form's Dispose...
  • When I set the current cursor to the wait cursor, why does it revert before I want it to?

    I set the wait cursor using Cursor.Current = Cursors.WaitCursor;. Why does does it disappear before I want it to? Setting the Current property changes the cursor and stops the processing of mouse events. Setting the cursor back to Cursors.Default restarts...
  • How do I load and display a cursor from a resource manifest?

    System.IO.Stream stream = null; try { string curName = "WindowsApplication1.Cursor1.cur"; stream = GetType().Assembly.GetManifestResourceStream(curName); this.Cursor = new Cursor( stream ); } catch ( Exception ex ) { MessageBox.Show(ex.Message...
  • How do I convert a Cursor class to a cursor (.cur) file?

    protected void WriteCursorToFile( Cursor cursor, string fileName ) { TypeConverter converter = TypeDescriptor.GetConverter( typeof( Cursor ) ); byte[] blob = converter.ConvertTo( cursor, typeof( byte[] ) ) as byte[]; if ( blob == null ) { MessageBox.Show...
  • How do I suspend painting a form until all its controls are initialized?

    There is not currently a way to do this built into the framework, but WM_SETREDRAW will do what you're looking for. It can't be called recursively, so here's code for a property you can add to your form to handle it. A VB sample is also available...
  • How do I draw a line to replace the functionality of VB6's Line command?

    Try this code: Dim g as Graphics g = frmMain.CreateGraphics() g.DrawLine(Pens.Black, new Point(0,0), _ new Point(frmMain.ClientRectangle.Width), frmMain.ClientRectangle.Height) g.Dispose() This should draw a line from the upper left to the bottom right...
  • What are some best practices for drawing and painting in Window Forms?

    Check out Painting techniques using Windows Forms for the Microsoft .NET Framework by Fred Balsiger on WindowsForms.net . It is a good basic discussion of how to get the best performance from Windows Forms drawing. His hints include leveraging the power...
  • How do I capture a bitmap of a form?

    You can P/Invoke the BitBlt function from gdi32.dll to handle this problem. using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Windows.Forms; class CustomForm : Form { [ DllImport( "gdi32...