|
Are you using TransparentBackground style? If so, overrice CreateParams, so if the window does need to recreate it self, it will do so properly.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Yes, I'm using the TransparentBackground style and I'll try your suggestion. This seems to be related to the CLR attaching the debug stuff to the program. It seems that in Windows 2000, when the debugger is running in the background the transparency is off, but if it isn't running the debugger, the transparency is on. I'll continue to investigate, unless somebody already knows the answer.
Thanks,
Joe
|
|
|
|
|
I have an inherited dialog, that wont fire the validating and validated events for the form, or the inherited yes no buttons. They do have causes validation set to true, in both the base class and the child class. I also have some other input fields that are not inherited from the base control and their validating and validated events are fired just fine. I tried manually hooking up the events from base class to inherited class, with no luck. Any suggestions?
Thanks,
Ryan
|
|
|
|
|
Overriding base class methods and not calling the base class's method will cause this.
override void OnValidate(EventArgs e)
{
base.OnValidate(e);
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I tried to make a private method virtual, and got the following error:
error CS0621: '***' : virtual or abstract members cannot be private
Is it really possible that private methods can not be virtual in C#, or I am making some terrible mistake here?
Thanks.
|
|
|
|
|
Look at the protected keyword...
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Use protected . Private members are only accessible to that class, so how can a derivate class override them?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Private members are only accessible to that class, so how can a derivate class override them?
What do you mean? Virtuality has nothing to do with access rights. In C++ it is perfectly legal (and useful) to override a virtual private function.
Anyway, after googling a little bit, I found out[^] that even CLR supports private virtual methods, and that this is a C# restriction
|
|
|
|
|
Exactly - because it doesn't make any sense. If you RTFD for the C# specification, you'd know this. And it does have to do with access rights because a private member cannot be accessed by either the base or derivative classes so it can't be overridden. Since it can't be overridden, there's no need to mark it virtual! It may be allowed in IL, but it certainly doesn't make sense and hence C# restricts it. This explanation is even given in the C# language documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
because a private member cannot be accessed by either the base or derivative classes so it can't be overridden.
I may be stupid, but why a method can't be overriden if it can not be accessed? What one has to do with another?
[edit]
BTW, take a look at this article[^] if you don't know why overriding private members is useful.
[/edit]
Also, I did read the C# language spec. but can't recall any mention of this. Would you tell me exactly where this was mentioned?
|
|
|
|
|
Okay, lets say for a second that C# allowed virtual on a private method. Fine.
A private method cannot be accessed (except through reflection) by neither the base class or any derivative classes. This means you can't override it because it can't even be seen by either of those classes.
And its not allowed in C# to use override on a method or property that isn't virtual .
If you read through the C# Language Specification[^] on MSDN it is mentioned (perhaps implied - it's been a long time). 3.5.1 states that privates are limited to the containing class only. The rest is mentioned in 10.2.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
A private method cannot be accessed (except through reflection) by neither the base class or any derivative classes. This means you can't override it because it can't even be seen by either of those classes.
Please read the article I left a link to.
|
|
|
|
|
Fine. Great. Even interesting! But that's C/C++. C# is a different language and .NET presents a somewhat different concept. So IL supports it virtual privates. Most languages don't. While the C# language supports most of the CLI features, many languages don't support even half of that.
If you want to know specifically why Microsoft choose not to support this construct, ask them.
As far as the C# compiler goes, virtual methods calls use the callvirt IL instruction. But the C# compiler doesn't allow access to private members so callvirt - as far as the C# compiler is concerned - can't call the private method. Maybe there is good reason for it, but - as I said - only the C# engineers can answer "why".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
To satisfy my own curiosity, I sat down and threw this together and you're right - it does work:
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:1:4322:0
}
.assembly Test
{
.ver 1:0:0:0
}
.module Test.exe
.class public auto ansi Test
{
.method public hidebysig static void Main() cil managed
{
.entrypoint
.maxstack 2
.locals init (class Test t)
newobj instance void Test2::.ctor()
stloc.0
ldloc.0
callvirt instance string Test::Print()
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig specialname instance void .ctor() cil managed
{
ret
}
.method private hidebysig virtual instance string Print() cil managed
{
.maxstack 1
ldstr "From Test (Private)"
ret
}
}
.class public auto ansi Test2 extends Test
{
.method public hidebysig specialname instance void .ctor() cil managed
{
ret
}
.method private hidebysig virtual instance string Print() cil managed
{
.maxstack 1
ldstr "From Test2 (Private)"
ret
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
A private method cannot be accessed (except through reflection) by neither the base class or any derivative classes. This means you can't override it because it can't even be seen by either of those classes.
You missed one VERY VERY important other method...
The fact that an enclosed class has access to all its contained class's members, thus infact allowing a private member to be theoritcally marked virtual and to be overriden if the enclosed class derives from it's contained class. Make sense?
class Test
{
virtual void TestMethod(){}
class Test2 : Test
{
override void TestMethod(){}
}
}
In my opinion this should be allowed!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I didn't miss nested class definitions, merely forgot them during this discussion.
If either of you want this supported by C#, why not email Microsoft? While they're adding functionality to to the language right now, it would be a good time.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Nahh i'm too lazy and my email is still broken.... anyways internal protected does enuf for me
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I need to send a file between a server and client machine, and although I assume I will need to use serialization I do not seem to be getting very far has anyone attempted this before?
|
|
|
|
|
Is it on the same network? Can't you use an UNC path and CopyFile?
|
|
|
|
|
No I need to send the whole file across the internet so it is not on a private network.
|
|
|
|
|
Hi I was wondering if anyone knew the best way of simply retrieving the IP address of the current computer? I have tried the System.Net namespace but found nothing useful.
|
|
|
|
|
Just use 127.0.0.1
It's actually a pretty tricky question. Networks come in all sorts of configurations, and you might even have more than one network card.
Something like the ipconfig program can give you your IP address, but that's not necessarily your IP to the outside world.
If you're using NAT, you'll have an IP that's in the private range (192.168... or 10... for instance). This won't be your IP address to the outside world, instead your NAT will actually be using this.
I'm not sure where the best place is to find all this stuff, but I think I'd start sniffing around WMI to see if it's any help.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
IPHostEntry hostInfo = Dns.GetHostByName(hostName);<br />
IPAddress[] address = hostInfo.AddressList;<br />
The address array will contains all the IP adresses of your computer.
|
|
|
|
|
I have a C# app with 4 forms with "TopMost = True"
When I perform a task Switch to another app,(using <alt> <tab>), these 4 forms remain on top of the application I switch to.
How can I either hide them and bring them back when I switch back to this app, or allow the other application to fall on top of these 4 forms?
Thank you in advance for any help!!
Ray Sotkiewicz
C# infant
|
|
|
|
|
Form.TopMost makes the Form a system modal window. It's supposed to be ontop of all other windows. If you only want it to be a top-level form for your application, then either set the Owner property of the child forms to the main form of your application, or call AddOwnedForm on the main form, passing the child forms as parameters. See the documentation for the Owner property and AddOwnedForm method in the Form documentation in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|