| 1 | /* pm.c -- Presentation Manager stuff
|
|---|
| 2 | Copyright (c) 1994-1995 by Eberhard Mattes
|
|---|
| 3 |
|
|---|
| 4 | This file is part of emx.
|
|---|
| 5 |
|
|---|
| 6 | emx is free software; you can redistribute it and/or modify it
|
|---|
| 7 | under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | emx is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with emx; see the file COPYING. If not, write to
|
|---|
| 18 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
|---|
| 19 | Boston, MA 02111-1307, USA.
|
|---|
| 20 |
|
|---|
| 21 | As special exception, emx.dll can be distributed without source code
|
|---|
| 22 | unless it has been changed. If you modify emx.dll, this exception
|
|---|
| 23 | no longer applies and you must remove this paragraph from all source
|
|---|
| 24 | files for emx.dll. */
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | #define INCL_DOSMODULEMGR
|
|---|
| 28 | #define INCL_DOSSESMGR
|
|---|
| 29 | #define INCL_DOSPROCESS
|
|---|
| 30 | #define INCL_WINWINDOWMGR
|
|---|
| 31 | #include <os2emx.h>
|
|---|
| 32 | #include "emxdll.h"
|
|---|
| 33 |
|
|---|
| 34 | static HMODULE hmod_pmwin;
|
|---|
| 35 | static char pm_initialized;
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | static HAB (*p_WinInitialize) (ULONG fsOptions);
|
|---|
| 39 | static HMQ (*p_WinCreateMsgQueue) (HAB hab, LONG cmsg);
|
|---|
| 40 | static ULONG (*p_WinMessageBox) (HWND hwndParent, HWND hwndOwner, PCSZ pszText,
|
|---|
| 41 | PCSZ pszCaption, ULONG idWindow, ULONG flStyle);
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | #define LOAD_PMWIN(ord,var) \
|
|---|
| 45 | (DosQueryProcAddr (hmod_pmwin, ord, NULL, (PPFN)var) != 0)
|
|---|
| 46 |
|
|---|
| 47 | int pm_init (void)
|
|---|
| 48 | {
|
|---|
| 49 | HAB hab;
|
|---|
| 50 | HMQ hmq;
|
|---|
| 51 | HMODULE hmod_pmwin;
|
|---|
| 52 | char obj[9];
|
|---|
| 53 |
|
|---|
| 54 | /* Loading PMWIN.DLL starts the Presentation Manager. We don't want
|
|---|
| 55 | to do this when running a non-PM program from the OS/2 recovery
|
|---|
| 56 | command line. Strangely enough, WinInitialize succeeds for
|
|---|
| 57 | non-PM programs run from the OS/2 recovery command line. */
|
|---|
| 58 |
|
|---|
| 59 | if (init_pib_ptr->pib_ultype != SSF_TYPE_PM)
|
|---|
| 60 | return FALSE;
|
|---|
| 61 |
|
|---|
| 62 | /* Dynamically load PMWIN.DLL. If references to PMWIN.DLL were made
|
|---|
| 63 | at link time, programs using EMX.DLL could not be used when
|
|---|
| 64 | booting from diskette and with RUN= of config.sys. */
|
|---|
| 65 |
|
|---|
| 66 | if (DosLoadModule (obj, sizeof (obj), "PMWIN", &hmod_pmwin) != 0)
|
|---|
| 67 | return FALSE;
|
|---|
| 68 |
|
|---|
| 69 | if (LOAD_PMWIN (763, &p_WinInitialize)
|
|---|
| 70 | || LOAD_PMWIN (716, &p_WinCreateMsgQueue)
|
|---|
| 71 | || LOAD_PMWIN (789, &p_WinMessageBox))
|
|---|
| 72 | {
|
|---|
| 73 | DosFreeModule (hmod_pmwin);
|
|---|
| 74 | return FALSE;
|
|---|
| 75 | }
|
|---|
| 76 | pm_initialized = TRUE;
|
|---|
| 77 |
|
|---|
| 78 | hab = p_WinInitialize (0);
|
|---|
| 79 | if (hab == NULLHANDLE) return FALSE;
|
|---|
| 80 | hmq = p_WinCreateMsgQueue (hab, 0);
|
|---|
| 81 | return hmq != NULLHANDLE;
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | /* Unload any DLLs loaded by pm_init(). */
|
|---|
| 86 |
|
|---|
| 87 | void pm_term (void)
|
|---|
| 88 | {
|
|---|
| 89 | if (pm_initialized)
|
|---|
| 90 | {
|
|---|
| 91 | pm_initialized = FALSE;
|
|---|
| 92 | DosFreeModule (hmod_pmwin);
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | void pm_message_box (PCSZ text)
|
|---|
| 98 | {
|
|---|
| 99 | if (p_WinMessageBox != NULL)
|
|---|
| 100 | p_WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, text, "emx.dll", 0,
|
|---|
| 101 | MB_MOVEABLE | MB_OK | MB_ICONHAND);
|
|---|
| 102 | }
|
|---|