Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClassName

Status
Not open for further replies.

0CODE

Programmer
Feb 8, 2004
63
CA
How do you set the ClassName for your application? I have this progam that when you place the mouse over the focused window it retreives the classname & windowtitle. Most programs have their set classnames appropriate to their program name. When I do this to my VB.Net apps i get something like "WindowsForms10.Ap1.8". How can I change this?

I did try something with me.createparams.classname but it did not work out and received an error. Any tips/help is appreciated. Thanks.
 
The form has a title, a name, and a filename.

The name (classname), you change via the form properties and yes the propertie is called name.
The formtitle is the textpropertie of the form.
And then you have the filname of the form. It's mostly the same name as the formname and ends with .vb. When you change the classname the filename will not change and this can lead to confussion.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
I know that. Please read carefully about what I am talking about.
 
The windows class name is assigned by the .NET runtime, and I don't think you can change it. At least, I haven't seen anything in the docs about changing it.

chrissie1 - he's talking about how in the Win32 world, each window that you create belongs to a class. For example, all the Visual Basic forms were of the class "ThunderForm" (a code name from the early days of VB). A window that is or contains a listbox would have a class name like "listbox".

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Yes you got the idea Chip. What makes me wonder is how every other program I have does have its custom names. If you would like me to provide a download link for the program that retreives this please tell me. As you can test the programs you have on your computer and see how it's all custom. Thanks for the reply.
 
No thanks. All the program is doing is calling the GetClassName Win32 API function:
MSDN said:
The GetClassName function retrieves the name of the class to which the specified window belongs.

Syntax

int GetClassName( HWND hWnd,
LPTSTR lpClassName,
int nMaxCount
);
Parameters

hWnd
[in] Handle to the window and, indirectly, the class to which the window belongs.
lpClassName
[out] Pointer to the buffer that is to receive the class name string.
nMaxCount
[in] Specifies the length, in TCHAR, of the buffer pointed to by the lpClassName parameter. The class name string is truncated if it is longer than the buffer and is always null-terminated.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
If you have Spy++ it does the same thing...
(came with previous versions of c++)

I made a program like this too in vb6... I used it to set the window's On Top, and transparency attributes...

check out thread222-852201

May I ask why you want to change the class name?

Most of the time, when applications show a different/unique class name, they were written in C++, which has more dirrect control over the application...

.Net (and even vb6 and previous versions) use standard classes which are handled by a system (DLLs) external from the program...

You, more or less, script it to draw the forms for you, which is what makes VB so easy to work with (compared to C++)

VB programs typically require a VB Runtime dll, and use the Windows Forms for the controls, etc...

So the class name for the forms generated by them are dictated by the dll that maintains them, avoiding the occurence of conficting class names...

You must also remember that .NET is supposed to be a platform independent system, to where programs will be able to run on various platforms with little or no porting, so the class naming is best left up to the JIT compiler, and probably should not be tampered with...

Good Luck,
Josh


Have Fun, Be Young... Code BASIC
-Josh

cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks for that, it wasn't much concern anyway I was just curious about it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top