Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!hagbard!sunic!news.funet.fi!funic!santra!tuura!risto From: risto@tuura.UUCP (Risto Lankinen) Newsgroups: comp.windows.ms Subject: Re: MessageBox problem Message-ID: <767@tuura.UUCP> Date: 21 Sep 90 12:09:06 GMT References: <1990Sep9.224303.10981@bdmrrr.bdm.com> <1990Sep11.074217.18928@ciba-geigy.ch> <1990Sep12.043315.10404@Neon.Stanford.EDU> <1990S Organization: Nokia Data Systems Oy Lines: 34 poffen@sj.ate.slb.com (Russell Poffenberger) writes: >I have found that MessageBox doesn't work properly in all cases. In attempting >to write a dll (Screen Peace saver extension), I called MessageBox to try and >debug a problem, this failed and caused the system to hang. Running CVW spit >out a continuous ream of messages indicating that there were no more Device >Contexts available. It seemed to get stuck forever in a loop at that point. Hi! I have run into similar problem with DLL's. I would have liked to show a messagebox if the LibMain failed to initialize the DLL for some reason. Since the actual application is unaware of LibMain being called, there's no window handle to associate the MessageBox with. So, I used the handle returned from GetDesktopWindow(), but it wouldn't work (even though it does when an *application* wants to display a MessageBox without having created a window handle). On the other hand, if the LibMain() returned false to indicate the failure, there's no chance to tell the user what went wrong, because the DLL-related application will not start in case LibMain fails. What I've made myself a habit to do is always return TRUE from LibMain(), but set a flag, which would be returned by the first call made to the DLL by the application itself. The application would call, say, InitDLL(), which 'pseudo-initializes' the DLL and actually returns the possible error condition flagged by LibMain(). There's an added convenience that the WEP also knows which initializations were succesfully done in order to free just those resources that were grabbed. Terveisin: Risto Lankinen -- Risto Lankinen / product specialist *************************************** Nokia Data Systems, Technology Dept * 2 2 * THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME! Now working on 2 +1 * replies: risto@yj.data.nokia.fi ***************************************