Sign in to follow this  

Windows Classes =(

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been looking over the Windows SDK documentation and it isn't very nice looking or nice to use =(. Anyways I have a question about Windows Classes: WNDCLASSEX: Class Name - I've read that this has to be unique for each class in a process, but other than that there's nothing, Can this be any string? Even gibberish? Does it have to follow rules like variable names? Also it gives these: Class Description Button The class for a button. ComboBox The class for a combo box. ... Are these to be put in the Class names? How do you use them? Finally: CreateWindow - What is a window? Is every button, scroll bar, etc a window? And how many windows can you have under a class? And also do window's class names have to be unique? *sigh* Windows programming is tireing... And thanks to anyone who just read through all that junk, even if you dont have anything to say. XD Thanks, Axi

Share this post


Link to post
Share on other sites
The windows class name is used by Windows and the programmer to identify what type of window you are creating. A class name must be unique within an instance of an application, but other applications or other instances of the same application can use the same class names.

As far as I know of, the class description is just an optional string that is used to give the programmer more information about the class.

Yes, everything is a window: the application window, the buttons, to even small things like tooltips. A lot of windows are composed of smaller windows. A scroll bar is a window but is composed of other windows (child windows) like buttons. The top arrow is a button window, the bottom arrow is a button window, and the stuff in between is probably composed of several different windows. Those all are combined to form a more useful window.

As for how many windows you can create of a certain class, I don't think there is any particular limit. Obviously, Windows cannot handle an infinite amount of windows, but the limit would probably be how many possible windows the OS can handle. I'm guessing that number of possible windows is represented by a 32-bit number, which means billions of them.

Windows programming can be tiring: I'll agree with you there. I almost gave up when I first started learning.

Share this post


Link to post
Share on other sites
Quote:
Original post by Axiverse
So how do you make scrollbars or buttons?


Set the classname to "button" and make the window a child of some other window.

there are predefined class names in windows for scrollbars too, i think they are named "vscrollbar" and "hscrollbar". There is a section at MSDN under the window class section.

Share this post


Link to post
Share on other sites
Quote:
Original post by Axiverse
Can this be any string? Even gibberish? Does it have to follow rules like variable names?
Yes, yes, no.

Quote:
Are these to be put in the Class names? How do you use them?
Yes, CreateWindow("BUTTON", ...).

Quote:
CreateWindow - What is a window? Is every button, scroll bar, etc a window? And how many windows can you have under a class? And also do window's class names have to be unique?
A window is a generic drawing area that encapsulates a certain functionality. Scrollbars are windows, too, as indicated by the SCROLLBAR window class. Window class names must be unique to the application, though some (such as BUTTON, SCROLLBAR, etc) are global. You can make your window class global by calling GlobalAddAtom on the ATOM returned by RegisterClass[Ex].

Share this post


Link to post
Share on other sites
Another short question:

I've been reading this http://www.gamedev.net/reference/articles/article1810.asp - Creating a Win32 Window Wrapper Class and it says "The CreateWindowEx function allows the passing of a (void) pointer to window creation data." How do you do this? I cant find any blank spaces in the WNDCLASSEX structures. Also it talks about storing a pointer in the window data, does that mean that i have to set int cbWndExtra to 4?

Also if you CreateWindow("BUTTON", ...) do you have to create a window class for that? Or is there one globally predefined?

Share this post


Link to post
Share on other sites
Quote:
The CreateWindowEx function allows the passing of a (void) pointer to window creation data. How do you do this?

The last argument to CreateWindowEx is a void *. Pass it in here. When you get the WM_NCCREATE and/or WM_CREATE message in the message handler, you can retrieve this pointer from the CREATESTRUCT structure passed in the lParam (CREATESTRUCT::lpCreateParams).

Quote:
Also it talks about storing a pointer in the window data, does that mean that i have to set int cbWndExtra to 4?

Yup. (Better yet, use sizeof(whatever*)). Then, to use this extra bit of memory allocated per-window, use:
GetWindowLong(hWnd, [offset in memory]);
SetWindowLong(hWnd, [offset in memory], [value]);

Quote:
Also if you CreateWindow("BUTTON", ...) do you have to create a window class for that? Or is there one globally predefined?

No, these are predefined and implemented by Windows. Check out the CreateWindow/CreateWindowEx docs in the MSDN for a list of some other common controls that are handled by Windows.

Share this post


Link to post
Share on other sites

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this