2

One of the parameters of the Win32 API function FindWindowEx is the Class Name of the window. For example, the Class Name of Microsoft Word is "OpusApp".

If I have developed my own application, what is going to be the Class Name of the windows of the app?

Can I set this Class Name to whatever I want?

CJ7
  • 22,579
  • 65
  • 193
  • 321
  • 1
    possible duplicate of [Registering a custom win32 window class from c#](http://stackoverflow.com/questions/128561/registering-a-custom-win32-window-class-from-c-sharp) – Sriram Sakthivel Nov 13 '13 at 07:39

1 Answers1

1

You didn't notice when you created your window, that you had to call RegisterClassEx (or plain RegisterClass)? ;)

Each window has a class. When you create your own, you specify its class.

*Edit: given your ambiguous tagging, I'm not really sure how you wrote your app. If you're using .NET then you obviously didn't have to manually call the C++ function RegisterClass.*

Regardless, when created, each window is associated with a "class", which describes certain common properties for all windows belonging to that class.

jalf
  • 243,077
  • 51
  • 345
  • 550
  • No, you don't have to do that when loading a `Form` in C#. Is the Class Name going to be name of the C# class of the form? – CJ7 Nov 13 '13 at 07:39
  • @CJ7 that is kind of relevant information that maybe should have been in the question. – jalf Nov 13 '13 at 07:40
  • @CJ7: most likely not. A quick search turned up [this](http://stackoverflow.com/questions/5476190/how-do-i-get-the-classname-of-the-active-window) and [this](http://social.msdn.microsoft.com/Forums/vstudio/en-US/410feea9-37e9-44af-8b84-cee6df4aee07/how-do-i-get-the-window-class-and-window-name-of-an-application-without-spy), [this](http://stackoverflow.com/questions/7395547/what-is-the-window-class-name-assigned-by-visual-studio-when-creating-net-form) and a couple of others. – jalf Nov 13 '13 at 08:25
  • If you have a handle to the window, you can get its class name fairly easily. (but if you already had the handle, you probably wouldn't need to call FindWindowEx. So the answer depends on your starting point. You can ask the OS for all windows belonging to the current process, or for the current foreground window, for example) – jalf Nov 13 '13 at 08:26