TIP: Click on subject to list as thread! ANSI
echo: os2
to: Jonathan de Boyne Pollard
from: Herbert Rosenau
date: 1999-12-05 01:26:06
subject: DETACH

 HR>> The only thing a programmer has to do is to

 HR>> - write a multithreaded VIO program
 HR>> - link with a PM DLL

 HR>> then if he would any PM ineraction he starts a thread that calls
 HR>> the DLL and this can interact with PM as it likes. 

 JdBP> Maybe you should have tried this before posting.  

I'd so! There is a very big system running a lot of VIO and PM applications
with a lot of functions in a couple of DLLs. To become a unified error handler 
we have written a multithreaded DLL to become a PM window up even if the
calling application is a background one (AVIO - optionally detached). 

 JdBP> If you had, you would have found that WinCreateMsgQueue()
 JdBP> returns an error if Presentation Manager detects that the
 JdBP> process type in the PIB is for a windowed or full-screen VIO
 JdBP> process. WinInitialize() will create an anchor block, but a
 JdBP> text-mode process, because of this check, will fail if it tries
 JdBP> to do anything that involves sending messages at any stage,
 JdBP> because it doesn't have a message queue.

Yes - if it is tried in the same thread! Make a PM DLL, start inside that DLL
a separate thread (use semaphore to syncronise with the non PM thread). Then
link your application with that DLL.

All applications have to use the same compiler- and linker flags - but my use
differen program types.

The trick is the separate thread and the PM type of the DLL.

 JdBP> For those unfamiliar with the mechanisms of PM, this can have
 JdBP> surprising results. WinQueryWindowText() doesn't work when used
 JdBP> by a text-mode application, for instance.  

Nothing of Win..() APIs other than WinPostMessage() will work outside a PM
application.

 JdBP> This is surprising to the PM novice, until he reads the PM
 JdBP> reference and finds that WinQueryWindowText() simply calls
 JdBP> WinSendMsg() with WM_QUERYWINDOWPARAMS behind the scenes.  The
 JdBP> WinSendMsg() fails, of course, because the text-mode
 JdBP> application doesn't have a message queue.

Right. 

But a thread my be a PM thread if the DLL is ready for PM. And you can make it 
one if you declare it as PM in its *.def.


--- Sqed/32 1.15/development  389:
231/992
* Origin: Jede Loesung bringt neue Probleme ! (2:2476/493)

SOURCE: echoes via The OS/2 BBS

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.