Why does adding images to an ImageList in the designer cause them to lose their alpha channel?
Looks like the ImageList editor loses the transparency when it does some internal copy/clone of the images. However, it seems that it does work when you add the images in code to the ImageList. One workaround (not so tidy) is to add the images to the ImageList in the design time (so that your design-time will be closer to the runtime) and then clear that ImageList and refill it with the images again, in code. Take a look at this faq on how to add images to your project and retrieve them programatically during runtime. Adding image files to a project as an embedded resource and retrieving them programatically.
What’s new in the 1.1 framework?
This MSDN article by Chris Sells provides a good introduction to the 1.1 framework: http://msdn.microsoft.com/msdnmag/issues/03/03/WindowsForms/default.aspx For a list of breaking changes in 1.1: http://www.gotdotnet.com/team/changeinfo/default.aspx We will include more information here that is not covered in the above article. Please email any more info. you have to [email protected] After preliminary testing, it seems like the reordering of tab pages in the TabControl by the design time seems to be fixed. Why do I have to use the STAThread attribute for my main method in my app.? What are some common gotchas while trying to embed a Windows Forms Control in IE?
How do I listen to the screen resolution change in my control?
You should override WndProc in your control/form and listen to the WM_DISPLAYCHANGE message. Refer to this faq a WndProc override sample: How do I listen to windows messages in my Control?
How can the child controls be created in server controls?
Child controls can be created by overridding the CreateChildControl method as below using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebCustomControl1 { [DefaultProperty(“Text”)] [ToolboxData(“<{0}:WebCustomControl1 runat=server> </{0}:WebCustomControl1>”)] public class WebCustomControl1 : WebControl { public TextBox txtname = new TextBox(); public TextBox txtnum = new TextBox(); [Bindable(true)] [Category(“Appearance”)] [DefaultValue(“”)] [Localizable(true)] public string Text { get { String s = (String)ViewState[“Text”]; return ((s == null) ? String.Empty : s); } set { ViewState[“Text”] = value; } } protected override void CreateChildControls() { Controls.Add(new LiteralControl(“Name: “)); Controls.Add(txtname); txtname.Text = “”; txtname.ToolTip = “Enter a Username”; txtname.Attributes.Add(“autocomplete”, “off”); Controls.Add(new LiteralControl(“</br>”)); Controls.Add(new LiteralControl(“EmpNo: “)); this.txtnum = new TextBox(); Controls.Add(txtnum); txtnum.Text = “”; txtnum.ToolTip = “Enter a Username”; txtnum.Attributes.Add(“autocomplete”, “off”); Controls.Add(new LiteralControl(“</br>”)); } protected override void RenderContents(HtmlTextWriter writer) { this.EnsureChildControls(); this.RenderChildren(writer); } } }
How can I stamp some text on an image?
The DrawingVisual can be used with a ‘BitmapImage’ instance and then rendered using ‘RenderBitmap’ class for creating custom rendered images. If text needs to be added, then use the ‘FomattedText’ instance. The following code snippet shows how to render an image with a text. [C#] BitmapImage bitImage = new BitmapImage() { UriSource = new Uri(@’C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg’, UriKind.Relative), DecodePixelWidth = 200, DecodePixelHeight = 200 }; FormattedText text = new FormattedText(‘Winter’, new CultureInfo(‘en-us’), FlowDirection.RightToLeft, new Typeface(‘Calibri’, FontStyles.Normal, FontWeights.Normal, new FontStretch()), this.FontSize, Brushes.White); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawImage(bitImage, new Rect(0, 0, bitImagebi.Width, bitImagebi.Height)); drawingContext.DrawText(text, new Point(bitImage.Height / 2, 0)); drawingContext.Close(); RenderTargetBitmap renderBmap = new RenderTargetBitmap(bitImage.PixelWidth, bitImage.PixelHeight, 96, 96, PixelFormats.Pbgra32); renderBmap.Render(drawingVisual); // Encoding the RenderBitmapTarget as a PNG file. PngBitmapEncoder png = new PngBitmapEncoder(); png.Frames.Add(BitmapFrame.Create(rtb)); using (Stream stm = File.Create(‘new.png’)) { png.Save(stm); }