|
Ouh, then I totally misunderstood your question
What you want to do sounds pretty complex and I don't know an easy solution for this.
Try posting this again with the better specification of your question, so maybe someone else can help you.
www.troschuetz.de
|
|
|
|
|
|
Just saying hello, or did you forget your question?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi!
... An uncomfortable silence ensues ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a dual monitor setup and when I make a RichTextBox control spawn onto both screens and have the font size bigger then 12 I get flickering whenever there is an update coming to the screen. Since this is a trading app and there are quite a few updates a second it can be very rough of your eyes. Is there a way to get rid of the flicker ? Double buffering perhaps ? I've tried updating my video card drivers to no avail. Thanks in advance...
-Peter
|
|
|
|
|
There are several articles dealing with double buffering here on Code Project, which can be easily found by using the article search.
Also there were some posting on flickering and double buffering in this forum earlier today. Use the Next link to get to them.
www.troschuetz.de
|
|
|
|
|
There is a command u can pinvoke to "freeze" painting, that mite help. Sorry I cannot recall it off the top of my head.
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi there,
I'm in a bad situation I think.
I have to do something according to what icon has been set in my notifyicon1.
this is the way I have added the icon to the notifyIcon.
notifyIcon1.Icon = new Icon(GetType(),"red.ico");
I have to fire an event only when the icon is different from red.ico,
How can i do this?
The solution might be simple, but I just can't figure it out
looking forward to your response.
regards
Christian
|
|
|
|
|
The icon should only be used to show the user a status of an internal variable, not as a method of passing data from one part of your program to another. If the icon is red, it's because something else in your application set it that way. A better solution would be to set up a property in your app that sets a value that can be used elsewhere in your app and at the same time changes the icon to reflect the value of that property.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Store another variable elsewhere which tells you which icon is selected. This will also protect you against changes to the icon name, how it's stored, etc.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I have been trying to scrape Web pages with code that includes the use of HttpWebRequest, then HttpWebResponse, and initially I am just sending the results to the console to be examined. Much sample code I have seen touts HttpWebRequest->HttpWebResponse as a quick, easy way to retrieve HTML from the internet.
What I have found is that this code retrieves only a certain amount of HTML at the beginning of each page, but not the whole thing (sometimes missing the code I need). Can anyone explain why this is? What sort of additional code would I add to repeat the request for data at the stopping point in order to get the rest of the page?
BluDvl90
|
|
|
|
|
This could be many things, such as not buffering the output correctly (never read-in the whole page at once - that's a bad idea) or using the wrong Encoding if you are buffering the whole output page.
Lets say you do buffer the whole page:
byte[] buffer = new byte[response.ContentLength];
response.Read(buffer, 0, buffer.Length); And then you use the wrong Encoding to read it. Lets say a Unicode (1-4 bytes per character) character set is returned but you assume ASCII:
string s = Encoding.ASCII.GetString(buffer); Only part of the page would be read because ASCII is 1 byte per character.
Instead, use the HttpWebResponse.ContentEncoding to get the right Encoding class:
Encoding enc = Encoding.GetEncoding(response.ContentEncoding);
string s = enc.GetString(buffer);
The easiest way is to create a StreamReader over the output using the right encoding. This will take care of any problems with buffering, even if you were to use StreamReader.ReadToEnd :
Encoding enc = Encoding.GetEncoding(response.ContentEncoding);
StreamReader reader = new StreamReader(response.GetResponseStream(), enc);
string line = null;
do
{
line = reader.ReadLine();
Console.WriteLine(line);
} while (line != null);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Plz how do I invoke the shell command to run a DOS executable in C#
Tanx
|
|
|
|
|
To start another process from within C# you can used the Process[^] class.
You can use Process.Start(); [^] to start a specific command.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
|
My first CP question! Gosh!
This problem is driving me crazy because there is an itch in my brain saying that there has to be *some* way of doing it.
I have base class A, I derive Class B from class A.
Now in class A I have a method that I wish to output the type of the class that the current instance is.
Note: I can't use typeof(this) since I want to be able to use this with versions of A and/or B that include static members.
e.g.
public class A
{
A()
{
}
public static PrintType()
{
System.Type myType = System.Reflection.MethodBase.GetCurrentMethod().ReflectedType;
Debug.Print(myType.ToString());
}
}
public B : A
{
}
B.PrintType() should, in theory print B as the type... but it always prints A...
This is driving me crazy.. I'm sure there has to be some way for the base class to find out if a method is being called from a derived class in a way that's compatible with using statics (going the other way is a breeze) but I just can't seem to put my finger on it.
Any help greatly appreciated.
Thanks
joev
|
|
|
|
|
Just use this.GetType , which will give you the Type for the current instance. Compile and try the following example:
using System;
public class A
{
static void Main()
{
A a = new A();
Console.WriteLine(a.GetType());
a = new B();
Console.WriteLine(a.GetType());
}
}
public class B : A
{
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok,
To explain again, because I've obviously not been properly clear.
1. I am not *instansiating* Class B from A. I am trying to find the Type of object while calling a method from A that has not been overridden by derived class B.
e.g. If I call A.PrintType() I should get A, if I call B.PrintType(), without implementing PrintType() in the derived class B - i.e. I'm falling back to A.PrintType(), I want to get "B" as the output.
2. The solution must allow for use with statics... "this.GetType()" is right out.
I've been fiddling with all sorts of System.Reflection bits without success
Any other ideas?
Cheers.
Joe.
|
|
|
|
|
And as I've just realised, this isn't possible at all with static members.
The compiler only emits the static member of the base class.
So therefore
B.PrintType()
is actually mapped directly to
A.PrintType()
in my example. Therefore PrintType can never know that it is being called from derived class B.
DOH. Back to the drawingboard.
Thanks anyway.
joe.
|
|
|
|
|
You should read a little more about polymorphism. Even if B doesn't override PrintType , this is still an instance of B .
Just modify the sample and you'll see:
using System;
public class A
{
static void Main()
{
A a = new A();
a.PrintType();
a = new B();
a.PrintType();
}
protected void PrintType()
{
Console.WriteLine(this.GetType());
}
}
public class B : A
{
} For statics, there is no this reference so you can't do it this way. It's this (which is implicit, so you don't need to type this ) that is the correct Type.
Statics are defined on a particular Type and even if you used StackTrace you would see the static member called on the defining Type. Reflection won't help.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You should read a little more about polymorphism. Even if B doesn't override PrintType, this is still an instance of B.
Sorry, I'm well aware of how polymorphism works thank you.
I was aware that your sample would work. My point was, it didn't answer my immediate question.
As I pointed out (and you subsequently re-iterated), of course what I was looking to do would not work in the context of statics since they are emitted once in the context of the declaring class.
I will instead approach the problem from a different angle.
Thanks
joev.
|
|
|
|
|
Hey there!
I have a problem with a Dialog in a textBox
I want to mark special lines in a different color. Is that possible or do i have to take a listBox? And if, then how is the code for changing single lines color!?
thanks
|
|
|
|
|
For a listbox, the color is for all text within the context. So that won't accomplish what you want to do. The textBox is the same. I would think that what you want to work with is a RichTextBox as your vehicle for text display. Then to set color your would do the following:
myRTB.Text = "some text\n\nsome more text\n"
myRTB.SelectedColor = Color.Red;
myRTB.SelectedText+= "colored text";
myRTB.Text += "end of message.\n"
I am just doing this off by memory, so you may need to do a bit of peeking at the Intellisense to get the correct selected field names.
|
|
|
|
|
thanks a lot
|
|
|
|
|
I want to make a DLL (interface) of which many implementations are possible. Now after I create the class file do I have to compile,
and do I have give the using namespace in the beginning
and can I have the interface & it's implementation in the same project, or should it be different projects.
Thanx.
MaXx
|
|
|
|