Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

winform friendly class name

Tags:

c#

winforms

I have a c# winform application that when used spy++, gives "WindowsForms10.Window.8.app.0.33c0d9d" as class name. Is there a way to change that to something more friendly?

like image 557
user156144 Avatar asked May 30 '10 07:05

user156144


People also ask

Is WinForm obsolete?

Win Form has been used to develop many applications. Because of its high age (born in 2003), WinForm was officially declared dead by Microsoft in 2014. However, Win Form is still alive and well.

How do you find the class name for a reflection?

Getting class name using reflection If you want to get the class name using the instance of the Class. As you can see using the method getName() gives you the fully qualified name whereas getSimpleName() method gives you only the class name.

Is it worth to learn WinForms?

Familiarity with WinForms will help you. Legacy applications will use them, and if you work in a microsoft shop, you will come across legacy applications. You should also learn something newer, because that's just part of being a programmer. The things you know now are just the foundation for what you will know.


1 Answers

There isn't. The last hex number is the hash code of the AppDomain that owns the window. The digit before that starts at 0 but increases if other windows were created with the same class name. The number before that is the value of the class style. Clearly you can only guess this name correctly if you have insider knowledge of variables whose value is only accessible inside the process.

Nor can you change it. You'd override the window's CreateParams property but setting the ClassName property will make Windows Forms look for an existing window class with that name. And fail to find it, bombing your program.

Nor can you override it. The logic is built into a private method of the NativeWindow class. Clearly this was not designed to make it easy to use FindWindowEx().

As long as changing the source code is an option, there are far better ways to setup an inter-process communication beyond using Windows messages. Named pipes, sockets, Remoting, WCF.

like image 60
Hans Passant Avatar answered Oct 03 '22 12:10

Hans Passant