Published on Wednesday, May 23rd, 2007 at 7:59 am

I have discovered an issue relevant to Premium edition upwards. One of my SB apps uses the Win API call FindWindow to check if an instance of the application is already running.  The FindWindow call takes two parameters a 'class' and the window caption you are looking for.

If you're not sure of the class you can send a 0 in the class parameter (There is also a slight change in the REGISTER definition).

Anyway the problem I ran into was when I exited my application and ran it a second time, It would act as if there is an instance already running and not allow itself to run.  Killing the NTVDM would make no difference.

So I wrote a little app to go through an enumeration of the available windows in the system and sure enough there was a window there with the same caption as my applications, Even though my app is no longer running and NTVDM was killed.

The thing I noted was the windows class name was "ThumbnailClass" – Which I'm pretty sure is to do with Vista's "Desktop Window Manager" fancy effects it uses for task switching. It shows you a thumbnail image of your application while you switch tasks. Now why this would still be present when my application is no longer running is beyond me, perhaps its a synchronisation problem between the Win16 layer windows enumeration and the Desktop Window Manager.  However the problem is existant on the Business edition and I presume the Premium edition as the fancy Aero effects dont come with  the Basic edition.

So the solution I used was to find the class of the Superbase application window and also use that in my call to FindWindow.

So if you're checking for a class name the REGISTER definition will be:

REGISTER "USER","FindWindow","HCC"

if you dont know the class name and will pass a 0 instead it will be:

REGISTER "USER","FindWindow","HJC"

And to get the handle of a window of a SB Application by its caption the call will be:

hwnd% = CALL ("FindWindow","SBV3DATACLASS",caption$)

Be Sociable, Share!

Related Posts

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

About Me

Welcome to my blog. Here you'll find mainly work related content, a suppository for all my notes which otherwise would end up on a post it note.