Talk:Window class

Page contents not supported in other languages.
Source: Wikipedia, the free encyclopedia.

the OO dispute: are window classes OO ?

Ok tell me why "lthough a windows class bears some similarity to the concept of a class in object-oriented programming, the API of the Windows operating system does not follow the object-oriented paradigm."? The definition of OOP varies in an individual. I have to know what is your definition. -- Taku 12:45 19 May 2003 (UTC)

I don't know about Mintguy's definition, but IMHO the fundamental property of OOP is encapsulation: i.e. the concept of a method being part of a class. Windows classes may contain function pointers, but the functions they point to are not considered to be part of the class -- they are part of the main program. A "callback", in other words. I'll admit the difference is fairly abstract. -- Tim Starling 12:59 19 May 2003 (UTC)
Agree with Tim. Also Window classes only exist as a template for the construction of a window. The rest of the API does not follow OO principles. The use of the word class was an arbitrary choice of M$ it has nothing to do with OOP. Mintguy 14:57 19 May 2003 (UTC)

So how about code like CreateFile and CloseHandle? Isn't it object-oriented way at all? Anyway the trouble is apparent, that is, people have a different definition for OOP. In my understanding, encaplucation or inheritance is not essential in OOP. (Please don't yell. That's not my personal opinion but what I learned.) I believe OOP means in its essence abstraction by interaction among objects. In OOP, each object is created by some way including classes but not limited to classes so that it can send and receive messages to/from each other. And that is all. Inheritance or encapsulation is rather useful techniques heavily used in OOP but not things that make programming OOP. See the difference? I don't claim you are wrong nor admit I am wrong. I believe either definition coexists. So what should we do? Stick to people who claim. If ms claims the concept of window class is based on OOP, then admit it. (Yes, I have to show you evidence. Just a moment.) -- Taku 00:19 20 May 2003 (UTC)

Taku. It seems that your confusion is caused because you haven't been taught the difference between object-oriented programming and
object-based programming. Indeed I've just noticed the Wikipedia doesn't know the difference either. As OBD is a redirect. Something will have to be done about that. Mintguy
09:34 20 May 2003 (UTC)
Some CS professors I've talked to consider the difference not that fundamentally important, being more of an implementation issue than a conceptual issue. Others disagree. In any case, they're obviously very closely related ideas, implementing most of the same conceptual abstractions. --Delirium 01:14, Oct 25, 2003 (UTC)
Along these lines, not everyone agrees that C is fundamentally a "non-OOP" language. It is clearly not a language designed for OOP, but there are many who claim that it is possible to write object-oriented C code; e.g. [1] --Delirium 01:21, Oct 25, 2003 (UTC)
Most non-OO languages can be used to implement OO designs. I've been saying this for ages. C++ gives you clues on how to do this, because you if you look into the data structure of a C++ class object you discover the v-table and the this pointer. It's not hard to implement this in C and have every function take a pointer to the object you want to work on as the first parameter. This doesn't make C an OO language and more than it would if you did the same with procedural BASIC. C++ is far from a perfect example of an OO language, but it is what most people (relatively speaking) are familiar with. A better example of an OO language is Eifel where it's more difficult to break the encapsulation. Mintguy 23:46, 31 Oct 2003 (UTC)

I agree with you, Delirium and some disagree--the situation is disputed. I posted the article in

VfD. I don't think we can agree if window class is OOP or not but we don't have to agree. Knowing this, I have been trying to avoid engaging in the debate. I will move this kind of topic to a new article called dispute over the definition of object-oriented programming. The article is just a mere solution to harbor this sort of distracting debates from the general public who is interested in a class itself not the war among wikipedians. -- Taku
01:27, Oct 25, 2003 (UTC)

Some more research is warranted, but I think if it turns out there is a major dispute, an article covering it is a good idea. My anecdotal evidence is probably not good enough for an article though: hopefully we can find some published work espousing these various positions. --Delirium 02:08, Oct 25, 2003 (UTC)

Windows objects?

Notes for articles, interesting here as well: "When we speak of the Win32 architecture, we're not speaking of objects as they exist in object-oriented programming or COM. Objects have a totally different meaning in this context"[2].


Keep, and revert to an older version ?

Executive summary: it has been done

So please don't revert this article any more because of this discussion.

From
VfD

--FvdP 22:40, 30 Oct 2003 (UTC)

Removed from
VfD

I removed this from VfD as it had been there six days and there were enough votes to keep it. Someone who knows more about this article than I do should revert to an earlier version as suggested above. Angela 05:32, Oct 31, 2003 (UTC)

There's no longer a need to revert IMO. The last version (which is mine) is satisfying to me. The above comments from VfD all were written before that version and hence are obsolete. (Which does not say these people would agree with the current version, though Taku probably does.) --

FvdP 18:31, 31 Oct 2003 (UTC)

I agree with the current version. I mean is there any objection to the article now? -- Taku 19:00, Oct 31, 2003 (UTC)

Remember: do not revert to an older version because of the above discussion. It's been done already. --FvdP


The "technical details" section

minimal requirements (OS versions)

Just about facts, isn't it too much detailed to discuss minimal requirements? I don't see they can be relevent to people other than windows programmers. -- Taku 02:47, Oct 28, 2003 (UTC)

Documenting versions is useful to track the history of the evolution of Windows APIs. Windows is important enough to give some details of when things happened in that OS. Citing sources is just good practice. One for window classes before NT3.1 is [3], which is also an intersting history of Windows programming article.

C struct definitions: to include or not to include ?

I have moved the following section because I think it is too detailed. I don't think we really have to show actual definition of struct. Sure, in math articles, it is normal to give definitions but definitions like struct in C cannot be so useful to the general public. -- Taku 23:03, Oct 30, 2003 (UTC)

I had made modifs to them. I'm adding them here in italics after the modified paragraphs. --FvdP 23:21, 30 Oct 2003 (UTC)

In Microsoft Windows programming a window class is a structure declared using

struct as WNDCLASS or WNDCLASSEX and holds a set of attributes which the system uses to create a process-specific process-specific window class[4][5]
:

In the C language a window class is defined as either of the two following struct
typedef struct {
    UINT style;              // Type of window- button, combo box etc.
    WNDPROC lpfnWndProc;     // a function Windows calls back to handle messages to the window
    int cbClsExtra;          // any extra bytes wanted after the structure
    int cbWndExtra;          // DLGWINDOWEXTRA if a dialog box will be used
    HINSTANCE hInstance;     // handle to the instance containing the window procedure for the class
    HICON hIcon;             // handle to the class icon
    HCURSOR hCursor;         // handle to the class cursor
    HBRUSH hbrBackground;    // handle to class background brush
    LPCTSTR lpszMenuName;    // pointer to resource name of the class menu
    LPCTSTR lpszClassName;   // pointer to null-terminated string or an atom
} WNDCLASS, *PWNDCLASS;

or

typedef struct {
    UINT cbSize;
    UINT style;
    WNDPROC lpfnWndProc;
    int cbClsExtra;
    int cbWndExtra;
    HINSTANCE hInstance;
    HICON hIcon;
    HCURSOR hCursor;
    HBRUSH hbrBackground;
    LPCTSTR lpszMenuName;
    LPCTSTR lpszClassName;
    HICON hIconSm;
} WNDCLASSEX, *PWNDCLASSEX;

The program creating the new window class sets the values in the structure and then passes it, by pointer, to the operating system via a call to the RegisterClass or RegisterClassEx function.

The program creating the new window class sets the values in the structure and then passes it, by pointer, to the operating system via a call to the RegisterClass or RegisterClassEx function. (The 'Ex' function accepts the 'EX' struct.)

Although window classes were present in Windows 3.x series, the minimum operating system versions for RegisterClassEx are Windows 95 or Windows NT 3.1. These window classes were not present in Windows versions 1.0 through 3.11 (Windows for Workgroups)[6].

no bare C structs please

The bare definition of a window class as C struct is totally uninteresting. There are the MS docs for those who want that information. It becomes interesting only when there are some comments to it. I'm not sure the current comments (in the version I reintroduced) are enough to justify the inclusion of the C struct definitions. So as far as I am concerned, feel free the C struct defs them and event the whole "technical details" section if you want. But please, if you reintroduce the C struct version, DO NOT reintroduce only the bare definitions. --FvdP 18:53, 18 Nov 2003 (UTC)

I restored bare structs only because there seem some people who like to see them. Detailed discussion is completely overlapped with the summary we already have. -- Taku 21:15, Nov 18, 2003 (UTC)