source: vendor/emx/current/src/os2/pm.c

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.9 KB
Line 
1/* pm.c -- Presentation Manager stuff
2 Copyright (c) 1994-1995 by Eberhard Mattes
3
4This file is part of emx.
5
6emx is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11emx is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with emx; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.
20
21As special exception, emx.dll can be distributed without source code
22unless it has been changed. If you modify emx.dll, this exception
23no longer applies and you must remove this paragraph from all source
24files 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
34static HMODULE hmod_pmwin;
35static char pm_initialized;
36
37
38static HAB (*p_WinInitialize) (ULONG fsOptions);
39static HMQ (*p_WinCreateMsgQueue) (HAB hab, LONG cmsg);
40static 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
47int 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
87void pm_term (void)
88{
89 if (pm_initialized)
90 {
91 pm_initialized = FALSE;
92 DosFreeModule (hmod_pmwin);
93 }
94}
95
96
97void 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}
Note: See TracBrowser for help on using the repository browser.