🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #197

Need help with static vars in multi-instanced code.

#197
From: Santanu Lahiri
Date: Tue, 07 Apr 1992 12:50
36 lines
2312 bytes
Hi folks!

As a rank beginner in Windows Programming, I am running into a problem (well,
actually many problems, but this one is one I cannot get a grip on).

I am beginning a port of one application I wrote for DOS.  It requires
me to run multiple instances of a code fragment within the program.
Specifically, a list box to select a file.  Now, I have the basic file
selection window working just fine and dandy.  Unfortunately, the listbox
approach I took requires declaring static handles for the listboxes within
the window procedure.  (I create several listboxes on receiving the WM_CREATE
message)

What happened was that I accidentally clicked on the FILE/OPEN menu item of
the parent window, and opened a second file selection window.  The new window
came up, worked fine and exited.  Unfortunately the first window was now dead.
I could work with the list boxes themselves, but the boxes would no longer
communicate with eachother.  The reason?  The handles had been whacked by
the second instance of the window.

It is extremely probable that this will happen when the program is put to use
and that there will be two or more parent windows calling this procedure
at the same time.  So I somehow need to isolate the handles of one instance
from another.  Is this possible?  Or do I need to allocate some sort of an
array to hold the handles and then check the instance using the window handle
when I process a message?  Keeping in mind that this is the same instance of 
the program running (no easy check for hPrevInstance), what is the best 
approach to this problem?

Thanks in advance.

Santanu
-- 
Santanu
-------------------------------------------------------------------------------
:: cat flames > /nev/dull                     slahiri@magnus.acs.ohio-state.edu
Technical Details
Message-ID: <1992Apr7.125032.5195@magnus.acs.ohio-state.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!slahiri

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.ms.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!slahiri
From: slahiri@magnus.acs.ohio-state.edu (Santanu Lahiri)
Subject: Need help with static vars in multi-instanced code.
Message-ID: <1992Apr7.125032.5195@magnus.acs.ohio-state.edu>
Sender: news@magnus.acs.ohio-state.edu
Nntp-Posting-Host: top.magnus.acs.ohio-state.edu
Organization: The Ohio State University
Distribution: usa
Date: Tue, 7 Apr 1992 12:50:32 GMT
Lines: 36