|
please help!
i am working in a c# GDI+ application but i got a problem in producing a pure flickering free screen, i am drawing on a panel and am using the following way to double the buffer but no use!
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics g = e.Graphics;<br />
<br />
<br />
Graphics g = this.panel1.CreateGraphics();<br />
offScreenBitmap = new Bitmap(this.panel1.Width,this.panel1.Height);<br />
Graphics g2 = Graphics.FromImage(offScreenBitmap);<br />
Brush b = new SolidBrush(this.panel1.BackColor);<br />
<br />
g2.FillRectangle(b, new Rectangle(this.panel1.Location,this.panel1.Size));<br />
g2.SmoothingMode=SmoothingMode.AntiAlias;<br />
flowChart1.Draw(g2);<br />
<br />
g.DrawImage(offScreenBitmap, new Point(0,0));<br />
g2.Dispose();<br />
b.Dispose();<br />
<br />
}
but i still have flickering screen, where is the problem?
and i am trying the the following code to double the buffer
SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(ControlStyles.DoubleBuffer, true);<br />
SetStyle(ControlStyles.UserPaint, true);<br />
SetStyle(ControlStyles.ResizeRedraw, true);
but dose't work!
reply asap please!!
|
|
|
|
|
See-S wrote: Graphics g = this.panel1.CreateGraphics();
You should not have to Create the graphics. Rather handle the Paint event seperately.
|
|
|
|
|
You aren't using the Graphics object attached to the Panel's off-screen buffer because you're calling CreateGraphics() on the Panel. Use e.Graphics instead.
Josh
|
|
|
|
|
thanks leppie and Josh!
i see, but again it doesn't work.
but now i substituted a pictureBox for the panel and itworks well!
thanx
|
|
|
|
|
There is the thing: I need to create a Vitrual Drive wich is mapped into a file (an XML one).
This file needs to simulate a tree stucture from the disk.
Is there a .Net way to do this?
... Just asking
www.brusella.com.ar[^]
|
|
|
|
|
Gonzalo Brusella wrote: Is there a .Net way to do this?
No.
You can however make a container file, and a viewer for it, but this wont be viewable by Windows itself.
|
|
|
|
|
The only way is with IoCreateDevice and with C++??
Hmmmm... A LONG work waits me....
|
|
|
|
|
Gonzalo Brusella wrote: Hmmmm... A LONG work waits me....
I think so.
A while ago I tried the same, knowing already that it's not possible to do it in .NET, and since I'm not used to "classic" Win32 APIs, I simply gave up.
Anyway if you're going to do it, we'll all appreciate an article on that topic here at CP.
______________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] and the ScrewTurn Software experiment
|
|
|
|
|
Thanks to everyone who helped with my previous question. I soon realized, however, that what I really need to do is to be able to cast the type, such as:
- This code is hypothetical, as to not complicate things further, but the real object in the program I am working on is a crystal report, but I want the viewer to work with any crystal report without having to hard code the viewer each time I create a new report. But if someone was able to answer this question, I could take it from there.
object SomeFunction ()<br />
{<br />
return UnknownObject;<br />
}
Now, while I dont know exactly what type UnknownObject is, I am sure no matter what it has a method called, lets say, ClearNum() - ya, kind of stupid, but Im trying to keep it simple to try to avoid getting an overcomplicated answer.
So lets say I want to ClearNum() on the object regardless of what type of object it is.
How can I accomplish the following:
void OnFormClose ()<br />
{<br />
object o = SomeFunction();<br />
((o.GetType())o).ClearNum();
}
Thanks if anyone knows the answer It would help me be a much better programmer.
|
|
|
|
|
If the UnknownObject always has ClearNum() then it is likely that all objects returned by the SomeFunction might implement some interface or derive from a common base class. If so, you can catch the return value as that type and go from there. Else, use reflection to call ClearNum via a dynamic method invocation.
Josh
|
|
|
|
|
Thanks so much, It never occurred to me that I could use methods from the common base class once a new class was derived from it - that was a big help!
|
|
|
|
|
I have 2 questions regarding array manipulation:
1) which is the best way to reset an array if i initially declare as:
private byte[] array1 = new byte[0];
2) how to insert elements into array at a specified index e.g:
initial array = [1,2,3,4,5]
new array = [1,2,7,8,3,4,5]
Ragards,
Donkaiser
|
|
|
|
|
You can't insert elements into an array. It is immutable. Try an ArrayList instead. Once you've finished manipulating it, you can convert it back to an array if you want.
Kevin
|
|
|
|
|
so how do I convert my array into a list? and backward?
Thx
Donkaiser
|
|
|
|
|
ArrayList has a ToArray() method, and your array can be added one by one to a new ArrayList when you create it, or using the AddRange method
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
ArrayList list = new ArrayList( myArray );
int[] ia = list.ToArray( typeof(int) ) as int[];
|
|
|
|
|
while reconverting back to array of bytes i got an InvalidCastException error message:
"At least one element in the source array could not be cast down to the destination array type."
byte[] myArr = (byte[])myList.ToArray(typeof(byte));
why can't it cast every object to the specified byte type?
Donkaiser
|
|
|
|
|
There must be something in the ArrayList which is not a byte (or not able to be converted to a byte).
Josh
|
|
|
|
|
You are linkely adding ints to the Arraylist, make sure you cast them to byte before adding.
|
|
|
|
|
In answer to both questions, when you need to work with arrays dynamically, use collections (or in .NET2 List<> ).
The reasons
1) Collections can be cleared with a .Clear() method
2) Collections allow dynamically adding (.Add(value) ) and inserting (.Insert(index,value) ) new items.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Thank ya'll so much!
Donkaiser
|
|
|
|
|
Thanks you all,
It was kinda a pain to convert to list and back to array. so what i did was to write an algorithm for it.
int[] myarr;
int index;
in val;
for (int i= myarr.length-1; i > index ; i--)
{
myarr[ i ] = myarr[i-1]; // shift everything;
}
myarr[index] = val;
Well there's always a way to get around thing.
Donkaiser
|
|
|
|
|
I declared a property of type string. In one of my codes i am using the value of property and storing into a local string variable. But i am unable to use ToString(), IndexOf, ToUpper() etc methods of local string variable. Any reason, Help very urgent
thanks
san
|
|
|
|
|
kumar.bs wrote: But i am unable to use ToString(), IndexOf, ToUpper() etc methods of local string variable.
What do you mean by that? You should post the relevant code so that we can see the situation in context.
Josh
|
|
|
|
|
public string DisplayFormat { get, set };
string strDisplayFormat = DisplayFormat;
on strDisplayFormat variable , i could not able to use ToString(), IndexOf() methods
san
|
|
|
|