|
Ah, yes. I do tend to forget quite often to call Dispose() on objects which support it. I have been making it a habit though, I am getting better. But that did not fix the flicker.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
you did postpone and hence reduce the number of FromHdc calls, as I suggested?
if so, is this actual code, or did you leave out some bits? you might choose to show the latest code again.
and what is inside OnNcPaint itself, that could be expensive (i.e. unnecessarily slow) too.
Now what exactly is flickering? the content of the form? the NC area?
You may have to look into the clearing of those areas, i.e. EraseBackground and such.
PS: I'll soon be off-line.
|
|
|
|
|
I did fix that as you suggested. And the flickering seems to be just a bit less, though nowhere near "reasonable" so to speak.
I actually have a lot going on in OnNcPaint. However, even if I remove everything and add a simple FillRectangle() for the caption/title area BY ITSELF, I still get the same flicker, except ONLY in the title area which is being drawn. It only flickers wherever I tell it to draw. So it definitely has something to do with the way it is drawing, not necessarily an expensive operation.
I am willing to take time on this. I have several custom controls which I am pleased with how they turned out. I figured Forms would be much more of a pain anyhow, haha. But I would sure love to figure it out.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Hi,
without knowing much more on your exact situation, this is all I can tell you about the subject:
1. some flickering is unavoidable; the annoyance of flickering is proportional to the time it takes from the start of EraseBackGround to the end of Paint itself, and inversionally proportional to the frequency of your Paint calls. That is why shortening EraseBackGround and/or Paint is beneficial.
2. you can use double-buffering, where an unseen bitmap is operated on, and when ready the area is bitblitted to the screen (this doesn't require an EraseBackGround); either organize that yourself, or have the Control (or Form) do it for you.
3. there are a number of articles on OnNcPaint here at CP; I suggest you use CP search to locate and then read some of them.
|
|
|
|
|
I am not sure if this helps; I used to suppress the OnPaintBackground method in such scenarios
You can try some thing like
protected override void OnPaintBackground(PaintEventArgs pevent)
{
}
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ?
am stuck in this code please somebody help me and correct it namespace a
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string s;
s = textBox1(textBox1.Text);
}
private void button1_Click(object sender, EventArgs e)
{
string s;
textBox1("1","2");
switch(s)
{
case "1":
{ Form2 f = new Form2();
f.Show();
}
}
}
}
}
|
|
|
|
|
|
i actually want that whatever user enters in the textbox and when click on the enter buttn , i must open the next forms , let suppose if the user enters "1" it must open the form 2, similarly if he enters "2" it should open form 3
|
|
|
|
|
|
thanx alot , and what is the purpose of combo box ?
|
|
|
|
|
|
could u please give me /provide me the correct version ? i would be really thankful to you .
|
|
|
|
|
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string s;
s=comboBox1.SelectedItem;
switch(s)
{
case "1":
Form2 f=new Form2();
f.Show();
break;
case"2":
Form3 a=new Form3();
a.Show();
break;
}
}
}
}
its giving me some error
|
|
|
|
|
Having read your original code, and the dialog between you and Colin (and admired Colin's patient responses), I want to offer you what I hope you will experience as constructive advice:
I believe you need to get a good book on C#, and really review the basics of the language Types, and, in WinForms, review the various common controls, like ComboBox, etc.
I'd suggest either the latest version of Jesse Liberty's 'Programming C#' (O'Reilly), and, for WinForms, I'd recommend the 2004 edition of Matthew MacDonald's "Pro .NET 2.0 Windows Forms and Custom Controls in C#" (APress) since I think Matthew has a certain "genius" for teaching and building slowly from fundamental concepts. There are, of course, other books on WinForms from Chris Sells (Addison-Wesley), Erik Brown (Manning).
In asking questions on CP, I'd suggest you begin the question with a clear statement of the context you are working in (WinForms ? WPF ? ASP.NET ?), and then a clear statement of what your goal is.
This goal statement can be very general: like: "I want to have a way at run-time in my WinForms application to select a certain type of Form to be created and shown."
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
I am using XDocument to build XML and writing it out using the Save method - I am having all hell on trying to get it to output a pound (£) sign. I have tried different encodings, tried using XmlWriter etc but nothing seems to work.
I have spent all morning reading articles (mainly others asking the same question with not really anything in the way of a reply which works) so how do I get a pound sign into XML? Currently the easiest option appears to be contacting the treasury and asking them to move to the dollar.
|
|
|
|
|
It's has been a while, but can you write out its unicode value of U+00A3?
|
|
|
|
|
I suppose so, do I have to check every single string built into the XML through XDocument and replace pound signs with that?
|
|
|
|
|
I'll see if I can find how we did it in my code base - it was a copy of years ago that I last worked on the xml generator
|
|
|
|
|
Thanks, any help will be much appreciated
|
|
|
|
|
I had a dig around and couldn't find anything in particular for £ signs - so I created this quick stub and it is working as expected for me
XmlDocument doc = new XmlDocument();
XmlNode node = doc.CreateNode(XmlNodeType.Element, "PoundTest", "Dummy");
node.InnerXml = "£";
doc.AppendChild(node);
doc.Save(@"c:\dummy.xml");
which outputs
<PoundTest xmlns="Dummy">£</PoundTest>
|
|
|
|
|
Hmm, the issues I am having are in an attribute and I am using XDocument rather than XmlDocument.
It's interesting yours works though
|
|
|
|
|
Sorry misread the XDocument bit, just added this to my original stub and it still works though
XmlAttribute elem = doc.CreateAttribute("PoundAttribute");
elem.Value = "£";
node.Attributes.Append(elem);
to give
<PoundTest PoundAttribute="£" xmlns="Dummy">£</PoundTest>
|
|
|
|
|
Thanks. Time to scrap XDocument then
|
|
|
|
|
Here you go
XDocument doc = new XDocument();
XElement node = new XElement("PoundTest", "");
XAttribute attrib = new XAttribute("PoundAttribute", "£");
node.Add(attrib);
doc.Add(node);
doc.Save(@"c:\dummy.xml");
which gives
<?xml version="1.0" encoding="utf-8" ?>
<PoundTest PoundAttribute="£" />
|
|
|
|
|
That works for me too.
Curiouser and curiouser.
Thanks for your help
|
|
|
|