Monday, 15 July 2013

c# - Should I dispose of the old font when changing the font of a control? -


C #, Windows Forms App

We are again scanning our application and I also change the awesome default font used in the old one, so I thought I wanted to change the font of all the controls when I loaded the form. I will call the following function.

Internal Static Zero SetFonts (Control Control) {font oldFont = control.Font; If (oldFont.Name! = GlobalFontName) {string familyName = GlobalFontName; Font new font = new system Dropping Font (family name, old font size, old font style, graphics count.point, 0); Control.Font = newFont; //oldFont.Dispose (); } Foreach (control child control in. Controls) SetFonts (child); } I thought that it will put resources down if I settle the old font after reassigning the control with the new one, but when I close the form I have a control Access violation exception is obtained from a set of third party controls If I comment on the "old fonts.despot ()" line, then I get no exception.

Is this a bug of third party control set or should it be expected?
Memory wise, can not I clear the old fonts clear (AP runs on kiosk for 12 hours + day)?

Do not dissect the old font, it is the control function whose font Additionally, use tools such as GDIView to monitor your handles (such as fonts).


No comments:

Post a Comment