Thread: Windows window is object orientated

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002

    Windows window is object orientated


    I was just wondering if anyone could help me with the following question: How a window in the WIN32 API could be related to OO concepts.

    If you think that a window is not OO, that doesnt matter. I just need ideas how it can compare with OO. This is for a possible exam question that could occur.

    However, I have only been only been able to come up with the following relations shown below. If anyone could extend any of these that would be great, or provide any details that you think I have missed.

    Class - A window exposes properties and methods that can be set and retrieved by the programmer. E.g. the name of the window (lpszClassName) and the icon associated with the window (hIcon). Could be viewed as a class, however the properties are all public by default. Has WM_CREATE and WM_DESTROY messages, which could be viewed as very basic constructor and deconstructor calls.

    Inheritance - It is possible to inherit characteristics of other windows, but I am not sure as to how this takes place. Is this managed through the hWndParent parameter when you create the window?

    Polymorphism - In order for the window to respond to messages, the user must provide a basic message pump using a call-back method. As the implementation is not fixed, this could be related to polymorphism.

    Events - Windows messages could be contrasted to events that are exposed by components or objects.

    Thanks in advance for any advice.
    Be a leader and not a follower.

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    I agree with most of your post.

    Class - WNDCLASS

    Constructor - CreateWindow + WM_CREATE/WM_NCCREATE

    Destructor - DestroyWindow + WM_DESTROY/WM_NCDESTROY

    Methods - SendMessage()

    Inheritance/Polymorphism - SetWindowLong( hwnd, GWL_WNDPROC, NewWndProc )

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002

    Thanks for your message. So it is possible to create a new window based upon the characterisitics of an old window using the SetWindowLong function?
    Be a leader and not a follower.

  4. #4
    Registered User
    Join Date
    Aug 2003
    It's possible to have your new winproc handler call the old windproc handle for events not handled by the new handler.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  3. Get Window Zorder?
    By Aidman in forum Windows Programming
    Replies: 2
    Last Post: 05-21-2003, 06:25 AM
  4. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM
  5. g_hWndMain = hWnd;error C2065,C2440
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 12-09-2001, 03:36 PM