|
Hi,
first of all when you implement a Dispose method you should implement the IDisposable interface (this interface is declaring void Dispose() ).
In your case you do not need any Dipose at all. The garbage collector will do all the needed work. Dispose is primarily needed to release unmanaged or very big resources. As you only have one long field there is absolutely nothing you could release.
And have a look at rhis article[^]. Its a good introduction.
|
|
|
|
|
Hi,
thank you for the answer. I looked those article and I'm wandering how can be img object set to null after being disposed (destroyed) in the Dispose(bool) method, and where is the code for that dispose?
if (img != null)
{
img.Dispose();
img=null;
}
So if my tought is write this code "img.Dispose();" doesnt destroy the object, just free the resource he occuped? And the code for dispose an Image object in in that Image class and how does it look this piece of code? So you can't dispose an object who have the reference to a variable.
Is it always when you want to dispose an object the "final" call to an System class?
Matej
|
|
|
|
|
You have to understand that you are working within a managed environment. Calling Dispose explicitely tells the image to release its resources immediately. Nevetheless the reference to it is still there. And even if you set all references to null the object will still remain in memory until the garbage collector makes his next round and destroys it. In case of the image (and most other objects) the finalizer will call Dispose if you haven't done so before. So there is no big need to call dispose. Its just a bit cleaner and gives you more control on when the resources are freed because the garbage collector is working unregulary and unpredictable.
|
|
|
|
|
It's true that you don't need to do any disposing on this example. But if you insist you could try forcing the Garbage Collector to realease all resources that are no longer used: "GC.Collect()".
Do your best to be the best
|
|
|
|
|
Hello!!
I made a control which contains a RichTextBox and2 buttons.
One button open a text file and the other save a text file:
//---OPEN
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Text files (*.txt)|*.txt";
if (open.ShowDialog() == DialogResult.OK)
richTextBox1.LoadFile(open.FileName);
//---SAVE
SaveFileDialog save = new SaveFileDialog();
save.Filter = "Text files (*.txt)|*.txt";
if (save.ShowDialog() == DialogResult.OK)
richTextBox1.saveFile(save.FileName);
And i want to host the control in Internet Explorer.
Then i create an html file:
RichTextBox Control
<object id="RichTextBoxControl1"
classid="http:RichTextBoxControl.dll#RichTextBoxControl.RichTextBoxCtl"
height="500" width="500" viewastext="">
And i Configure the Virtual Directory.
I open the html page and i can see the control but when i want to open a text file an exception appears:
System.Security.SecurityException: 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Also i configure the permissions in the .NET Framework 2.0 Configuration but the same exception appears.
Somebody knows if i am missing something.
Regards,
Alberto Martinez
|
|
|
|
|
Trust you havenot forgotton that Javascript and VBScript are unable to access your hard drive from a web page without using an Active X Control.
Please read the ENTIRE thread starting with [^]
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I have Windows Control Library (derived from Control).
I wish my own custom type editor to allow the user to select something. I already made it (2 classes - one derived from System.Windows.Forms.UserControl, second from System.Drawing.Design.UITypeEditor.
In first of these I overriden OnPaint method and set Region property.
In second, I overriden:
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)<br />
{<br />
return UITypeEditorEditStyle.DropDown;<br />
}<br />
<br />
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)<br />
{<br />
return 0;
}
In the class derived from control I set a property:
[Category("Shape"), Description("Color at center")]<br />
[BrowsableAttribute(true)]<br />
[EditorAttribute(typeof(ShapePicker), typeof(System.Drawing.Design.UITypeEditor))]<br />
public int CenterColor<br />
{<br />
get { return 3; }<br />
set<br />
{ MessageBox.Show(value.ToString()); }<br />
}<br />
}
When I create a Win Project and put this WCL on the form, all goes well, the property is shown. But when I click on that property`s ellipse (for the custrom type editor to be opened), nothing is being shown. It looks as if the EditValue method is being called immediately after opening this custrom type editor.
---------------------------------------------------------------------------------
Could you please tell me why is that? Why I canon choise anything from this custorm type editor?
thank you very much for any help
|
|
|
|
|
Sometimes (less that 1% of the calls) I am getting “System.Runtime.Remoting.RemotingException: Port is Busy: All pipe instances are busy” on remote method invocation when using IpcChannal.
Has anybody experienced the same problem?
Suggested solutions?
|
|
|
|
|
How can I display the animation on the win form like that of MSN messenger, which is displayed when we click the login button?
By simply placing an animated gif file on the win form, it starts animating, even in design mode.
But, I want to display it for some button's click event, like exactly that of MSN messenger. Any idea?
|
|
|
|
|
Use a timer, when it ticks show the "next" image in an image sequence.
:josh:
My WPF Blog[^]
|
|
|
|
|
thank you :josh: for the reply.
The messenger animation may be like what you've said. But, I have a single animated gif file, whose animation is on its own. Do u have any solution for this scenerio?
|
|
|
|
|
sinanju wrote: But, I want to display it for some button's click event, like exactly that of MSN messenger. Any idea?
They are done in Macromedia Flash.
|
|
|
|
|
Thank you leppie, for you reply.
Here how can i manage to display it, some threading will do the trick, so that i can move the form around while the animation is on?
|
|
|
|
|
I've searched a link
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=530668&SiteID=1
It seems to me relevant, I'll try it later.
|
|
|
|
|
Hi the NewbProgrammer is back!
Im making a simple for a video game. What this program has is a lable in which the current time is displayed using DateTime.Now.ToString();. How do i get it to auto update. Thank you for taking the time to read this.
|
|
|
|
|
Create a Timer with and interval of 1000ms.
Sample
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use a System.Windows.Forms.Timer, hook the Tick event, in there set the label's text.
:josh:
My WPF Blog[^]
|
|
|
|
|
Redraw the time. In fact you probably don't need a label for it either. Graphics.DrawString might consume less resources than a label.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks a lot you guys it was really helpful
MWA HAHAHAHA I AM A NOOB AND WE NOOBS WILL KILL YOU ALL. JK
|
|
|
|
|
I have this RichTextBox. At some point, the RichTextBox might have a little image in it. When the image is selected, the myRichTextBox.Copy() method doesn't properly copy the image data to the clipboard. I know this because MS Paint complains when I try to paste it therein.
Can someone please show me how to get a selected image (in a RichTextBox) copied properly to the clipboard? I assume I'll have to use the Clipboard class, right? I'm not sure how...
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hi,
Anyone know how to create a .NET form control with MAC style.
Here is a sample what I mean: http://www.econtechvn.com/en/macuisuite_detail.htm but is has to be bought. I'm looking for any code or free resources to help me acomplish it myself
-- modified at 13:36 Tuesday 18th July, 2006
|
|
|
|
|
Override OnPaint. That's what I would do...
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Buying a 3rd party UI set will almost certainly cost less than writing the same controls yourself.
|
|
|
|
|
dan neely wrote: Buying a 3rd party UI set will almost certainly cost less than writing the same controls yourself.
I agree. Especially if you're going into it with no idea of if/how it can be done.
:josh:
My WPF Blog[^]
|
|
|
|
|
Thanks for your comment, but still I want to do it myself, I'm almost intermediate in C# I could be able to get through of it. plus once I had seen an article with source code on the web but I forgot the address at this time and I went no where by searching the web.
Please for those who know anything about the soulution let me know.
Thanks.
-- modified at 14:22 Tuesday 18th July, 2006
|
|
|
|