what is the classname

G

Guest

Hi,

I want to post a message from another application to my C# application. It
works but I cannot fint the window if I fill in the class name. eg:

namespace SomeNameSpace
{
partial class Main: Form
{
Text = "this is the title";

and in the other program
ClassName := 'Main';
WindowTitle := 'this is the title';
Win := FindWindow(ClassName, WindowTitle);

does only work if I make ClassName := nil
 
M

Mattias Sjögren

I want to post a message from another application to my C# application. It
works but I cannot fint the window if I fill in the class name. eg:

The Win32 window class name isn't the same as your Form class name.



Mattias
 
G

Guest

OK thanks that explains wy I cannot find it with FindWindow. But how do I
find out what the classname is ?

rgds, Wilfried
 
W

Willy Denoyette [MVP]

By calling WIN32 API GetClassName (user32.dll) using the Handle returned by
FindWindow(Ex).

Willy.
 
G

Guest

the classname returns: "WindowsForms10.Window.8.app.0.bf7771"

question is: where does this come from ? I want to say to customars to
FindWindow with specific class and title, just as it is the case in win32
progrrams where the classname is the class name of the window (the form).

rgds, Wilfried
 
W

Willy Denoyette [MVP]

The class name is the name given by Windows Forms when it is registering the
"Window class" by calling Win32's RegisterClass(Ex), you have no way to
control this in .NET.

Not sure what you mean with your last sentence, there is no notion of a
"form" in Win32, there is only a Classname by which you register the class
(RegisterClass(Ex)) and CreateWindow.

Willy.
 
W

Willy Denoyette [MVP]

Sorry, when I said there is a way to control this, I meant no "easy way".
The NativeWindow class encapsulates this low level Window stuff, search the
MSDN doc's for more info and a sample.

Willy.
 
M

Mattias Sjögren

Sorry, when I said there is a way to control this, I meant no "easy way".
The NativeWindow class encapsulates this low level Window stuff, search the
MSDN doc's for more info and a sample.

And you can also override the CreateParams property of a Control or
Form. But that will only let you change the "Window" part of the whole
window class name.



Mattias
 
W

Willy Denoyette [MVP]

Mattias Sjögren said:
And you can also override the CreateParams property of a Control or
Form. But that will only let you change the "Window" part of the whole
window class name.

Mattias,

Same problem with the NativeWindow class, only a System class name (CONTROL)
is allowed as classname, and this also becomes a part of the whole window
class name, quite unusable IMO.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top