jondinham
jondinham

Reputation: 8511

What is the window class name assigned by Visual Studio when creating .NET form?

As in VC++ when creating a window we need to create a window class and use RegisterClass or RegisterClassEx to register. But in .NET we don't have this step.

So I wonder what the default window class name assigned by Visual Studio when creating a form?

As I've tracked out, the window class name assigned by Visual Studio is somewhat similar to this:
WindowsForms10.Window.8.app.0.1ca0192_r13_ad1

I want to change this default window class name, any idea?

Upvotes: 8

Views: 4008

Answers (1)

Hans Passant
Hans Passant

Reputation: 941237

Window class names are automatically generated. You cannot change them, even though CreateParams lets you set the ClassName property. Nor can an external program ever guess the auto-generated name correctly, part of it is generated from AppDomain.CurrentDomain.GetHashCode().

You'll need another way to identify the window. Not much available, but you could pinvoke SetProp() to associate an arbitrary string to a window. And test if it is present with GetProp(). The SDK article is here.

Upvotes: 6

Related Questions