Announcement

Collapse
No announcement yet.

UnRegistering a Class ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • UnRegistering a Class ??

    I need some info about UnRegistering a Window Class:

    (1) Can you use UnRegisterClass to unregister a class created with RegisterClassEx ?

    The MS Docs seem to imply only a Class created with RegisterClass can be unRegistered.

    (2) If I want to UnRegister a Window class, "before" my application Terminates (it may have dozens of windows created and destroyed), where would I do it ? Can it be done when the %WM_DESTROY message is processed ?

    (3) Are there any advantages to using RegisterClass over RegisterClassEx ?

    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

  • #2
    lpClassName
    [in] Pointer to a null-terminated string or a class atom.
    If lpClassName is a string, it specifies the window class name.
    This class name must have been registered by a previous call to the
    RegisterClass or RegisterClassEx function.
    System classes, such as dialog box controls, cannot be unregistered.
    If this parameter is an atom, it must be a class atom created by a
    previous call to the RegisterClass or RegisterClassEx function.
    The atom must be in the low-order word of lpClassName;
    the high-order word must be zero.

    hInstance
    [in] Handle to the instance of the module that created the class.

    -------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Comment


    • #3
      Thanks Fred;

      That answers one question .

      The win API help file and MSDN CD I have are older and do NOT mention RegisterClassEx like the quote above does.

      Now the questions is "can" I Unregister the Class of a Window when the windows %WM_DESTROY message is being processed or must it some how be after (not sure how I would do that) ?


      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        I can't seem the get the UnregisterClass function to succeed.

        I wait until the window is destroyed and then try to Unregister the class, but the function always fails.

        Does the function actually work ?

        Has anybody used it with success ?

        The MS docs just make mention of classes being destroyed when the app terminates. I have yet to see actual code (C) which uses the unregisterclass function.
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment


        • #5
          Does this help?
          Return Values
          If the function succeeds, the return value is nonzero.

          If the class could not be found or if a window still exists that was
          created with the class, the return value is zero. To get extended error
          information, call GetLastError.


          Remarks
          Before calling this function, an application must destroy all windows
          created with the specified class.

          All window classes that an application registers are unregistered when it
          terminates.

          Class atoms are special atoms returned only by RegisterClass and
          RegisterClassEx.

          Windows 95:
          All window classes registered by a .dll are unregistered when the .dll is
          unloaded.

          Windows NT/2000:
          No window classes registered by a .dll registers are unregistered when
          the .dll is unloaded.

          -------------
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se



          [This message has been edited by Fred Oxenby (edited January 22, 2000).]
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se

          Comment


          • #6
            A few more questions:

            (1) Are Classes "Process" specific ?

            If two apps use the same name to create a Class (a Non-Global one) does windows treat them as different classes, since the application Instance used (different process) is different ?


            (2) If you create a Class with Code in a DLL which was called by the EXE, but use the EXEs instance, instead of the DLLs instance , does this make the class specific to the EXEs process (rather than to the DLL which can be shared) ?

            I understand Instances and processes reasonbaly well, but coming from a DOS Basic and VB background, I sometimes get a little confused (especially with DLLs being shared and all).

            I just need to "verify" a few things.

            Chris Boss
            Computer Workshop
            Developer of "EZGUI"
            http://cwsof.com
            http://twitter.com/EZGUIProGuy

            Comment

            Working...
            X