user156144
user156144

Reputation: 2295

winform friendly class name

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?

Upvotes: 11

Views: 3720

Answers (2)

Hans Passant
Hans Passant

Reputation: 941485

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.

Upvotes: 5

Jack
Jack

Reputation: 292

if you need friendly names for your controls use the Accessibility properties. that is the common way.

Upvotes: 0

Related Questions