How can I load an embedded rich text file into a richtextbox
You use the LoadFile method of the RichTextBox, passing it a streamreader based on the resource. So include your RTF file as an embedded resource in your project, say RTFText.rtf. Then load your richtextbox with code such as Stream stream = this.GetType().Assembly.GetManifestResourceStream(‘MyNameSpace.RTFText.rtf’); if (stream != null) { StreamReader sr = new StreamReader(stream); richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText); sr.Close(); } Here is a VB snippet. Depending on your default namespace settings, you may not need explicit reference to the namespace in the GetManifestResourceStream argument. Dim stream As Stream = Me.GetType().Assembly.GetManifestResourceStream(‘MyNameSpace.RTFText.rtf’) If Not (stream Is Nothing) Then Dim sr As New StreamReader(stream) richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText) sr.Close() End If
How do I check the state of the virtual keys, Caps lock for example?
If the Control.ModifierKeys doesn’t address your issue, then use Platform Invoke and call GetKeyState directly. Declare this class first: [ ComVisibleAttribute(false), SuppressUnmanagedCodeSecurityAttribute() ] internal class NativeMethods { [DllImport(‘user32.dll’, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] public static extern short GetKeyState(int keyCode); public static int HIWORD(int n) { return ((n >> 16) & 0xffff/*=~0x0000*/); } public static int LOWORD(int n) { return (n & 0xffff/*=~0x0000*/); } } Then when you want to check if Caps is down or ON, call: short state = NativeMethods.GetKeyState(0x14 /*VK_CAPTIAL*/); bool capsKeyDown = NativeMethods.HIWORD(state); bool capsKeyON = NativeMethods.LOWORD(state);
How can I have a form with no title bar, but yet keep the resizing borders
Set your form’s Text and ControlBox properties. myForm.Text = ”; myForm.ControlBox = false;
How do I set the company name that is returned by System.Windows.Forms.Application.CompanyName
This is an assembly attribute. The VS development environment sets it in the AssemblyInfo.cs (vb) file. If you open that file, you will see a block of assembly attributes that you can set, including company and version numbers. [assembly: AssemblyCompany(‘Syncfusion, Inc.’)]
How can I draw outside my WIndow
You have to get a handle to the desktop and draw on the desktop. This means that whatever you draw will not be automatically refreshed when another window is dragged over it. [DllImport(‘User32.dll’)] public extern static System.IntPtr GetDC(System.IntPtr hWnd); private void button1_Click(object sender, System.EventArgs e) { System.IntPtr DesktopHandle = GetDC(System.IntPtr.Zero); Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle); g.FillRectangle(new SolidBrush(Color.Red),0,0,100,100); } from a microsoft.public.dotnet.framework.windowsforms posting by Lion Shi (MS)