Paradox'; $metakeys = "paradox objectpal window class name windows api functions"; $metadesc = "How to determine the class name of the Paradox Desktop window"; ?>

Question: How do I determine the class name of the Paradox Desktop window?

Answer: The following code shows how you can do this:

var
   app  Application
   li   LongInt
   tc   tCursor
endVar

const
   TMP = ":PRIV:OPENWINS"
endConst

   ; First, get Paradox's current Handle.
   li = app.WindowHandle()

   ; Get a list of all open windows.
   enumWindowNames( TMP )
   sleep()              ; process any pending messages.
   tc.open( TMP )

   ; Search for the saved handle and save the classname
   if tc.locate( "Handle", li ) then
      str = tc."ClassName"
   else
      str = "Unable to locate classname for " +
            "window handle " + string( li )
   endIf

   ; Formally close all tCursors!
   if tc.isAssigned() then
      tc.close()
   endIf

   ; Display results
   msgInfo( "FYI", "The classname of Paradox's Desktop " +
            "window is \"" + str + "\"." );

   ; Clean-up
   delete( TMP )

Note: The class name can change between versions. If you're building applications to support multiple Paradox versions and are incorporating code that depends on the class name of the Desktop window, be sure to verify the class name you're using for each Paradox version you support. And, yes, this includes Runtime versions as well.

Why is this important?

Many Windows API functions require the handle of the target window. However, handles are not consistent; they're assigned by Windows when applications are started and unassigned when those applications close. However, the API provides the findWindow() function to determine whether or not a certain type of window is open, based on its class name. Once you know the class name of a given application, you can affect that window using the Windows API.

For ObjectPAL developers, this means you can perform a variety of tricks with your application, such as changing the icon, replacing the Control menu, and so on.