[4185] in comp.os.os2.announce archive
MISC: Open32 Sucesss story
daemon@ATHENA.MIT.EDU (Carlos Portela)
Sat Jul 4 15:28:09 1998
To: os2ann.DISCUSS@bloom-picayune.mit.edu
Date: 04 Jul 1998 14:02:00 -0400
From: cportela@simple-sw.com (Carlos Portela)
Reply-To: cportela@simple-sw.com
Reply-to: cportela@simple-sw.com
[Followups directed to comp.os.os2.programmer.porting]
---------------------------------------------------------------------
Hi All,
I recently requested opinions from this group regarding implementation of an
application under Windows and OS/2 with single source. You gave me all sorts
of ideas and we decided to try Open32.
We implemented the application under Windows and then ported it to OS/2
using the SMART resource translator (SMARTRC.EXE) and Open32. The port was
very easy. We included "os2win.h" in place of windows.h and made a few
changes to the source code. It worked!
Here are the changes we had to make:
1) Prototype WinCreateMsgQueue and WinDestroyMsgQueue as follows
extern long _System WinCreateMsgQueue(long, long);
extern long _System WinDestroyMsgQueue(long);
If you include "pmwin.h" to get those prototypes you get all sorts of
warnings and errors.
2) Added the following:
#if defined(_EOS2)
int main(int argc, char *argv[], char *envp[])
{
return WinCallWinMain( argc, argv, &WinMain, SW_SHOWNORMAL);
}
#endif
3) Defined "#define WS_EX_CLIENTEDGE 0x00000200L" for compatibility with
Windows. It does not appear to do anything under OS/2. This is used in the
call to CreateWindowEx. For compatibility wit Windows we also defined:
#define EM_SETLIMITTEXT 0x0143
#define BST_CHECKED 0x0001
#define BST_UNCHECKED 0x0000
Note that we haven't gotten EM_SETLIMITTEXT to work properly. This is the
only problem we have so far.
4) Every thread that calls SendMessage() must have its own message queue.
This is not documented in the Open32 documentation, or at least we didn't
find it. We added the following to the beginning of every thread:
#if defined(_EOS2)
long msg_q = WinCreateMsgQueue(0, 0);
#endif
and before the call to _enthread():
#if defined(_EOS2)
WinDestroyMsgQueue(msg_q);
#endif
Amazingly all dialog boxes work identically as they do under Windows.
The MDI metaphore works identically also.
Regards,
--
Carlos Portela, Simple Software Solutions, Inc.
e_Db 2.1 - Fast, reliable database engine
e_Fs 2.0 - Portable structured storage
e_Comm 2.0 - Client-server communications
http://www.simple-sw.com
_____________________________________________________________________
| NOTE: Please EMAIL submissions to comp-os-os2-announce@moderators.isc.org
| Correspondence to the COOA Moderator: lfirrantello@bix.com .
| Please see: http://www.bix.com/pub/os2ann/pindex.htm for posting guidelines