source: branches/v2.9_Lars/common_functions/message.c

Last change on this file was 130, checked in by erdmann, 21 months ago

merge from trunk CS 129

File size: 11.5 KB
Line 
1
2#define INCL_WIN
3
4#include <os2.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8
9void errorResourceVerbose(void)
10{
11 WinMessageBox(HWND_DESKTOP,0,
12 "The resource DLL which contains all the dialogs, graphics and messages cannot be loaded. \
13 \nPlease check your installation.",
14 "Problem with class installation",12345,
15 MB_OK|MB_MOVEABLE|MB_ERROR);
16}
17
18void errorResource(void)
19{
20#if 0
21 /*
22 Don't show a message box because on WPS startup this may lead to a deadlock.
23 At least I suspect this happens on system where the MM classes don't work.
24 Instead there's a new function errorResourceVerbose() which may be called when we
25 know, the WPS is up and running.
26 */
27 WinMessageBox(HWND_DESKTOP,0,
28 "The resource DLL which contains all the dialogs, graphics and messages cannot be loaded. \
29Please check your installation.",
30"Problem with class installation",12345,
31 MB_OK|MB_MOVEABLE|MB_ERROR);
32#endif
33}
34
35
36/*!**************************************************/
37/* */
38/* @@DESC */
39/* */
40/* Show a message box with text strings loaded from */
41/* the resource DLL or the EXE file. */
42/* */
43/* @@RETURNS */
44/* */
45/* ULONG ulResult */
46/* */
47/* MBID_ERROR in case of an error. */
48/* :p. */
49/* Result code from WinMessageBox(). */
50/* */
51/* */
52/*!!*************************************************/
53ULONG messageBox( PSZ text, ULONG ulTextID , LONG lSizeText,
54 PSZ title, ULONG ulTitleID, LONG lSizeTitle,
55 HMODULE hResource, HWND hwnd, ULONG ulFlags)
56{
57
58 if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulTextID,lSizeText,text)) {
59 errorResource();
60 return MBID_ERROR;
61 }
62 if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulTitleID,lSizeTitle,title)) {
63 errorResource();
64 return MBID_ERROR;
65 }
66 return WinMessageBox( hwnd, hwnd, text, title, 0UL, ulFlags );
67}
68
69static ULONG mBox( PSZ text, ULONG ulTextID , LONG lSizeText,
70 PSZ title, ULONG ulTitleID, LONG lSizeTitle,
71 HMODULE hResource, HWND hwnd, ULONG ulFlags)
72{
73
74 if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulTextID,lSizeText,text)) {
75 errorResource();
76 return MBID_ERROR;
77 }
78 if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulTitleID,lSizeTitle,title)) {
79 errorResource();
80 return MBID_ERROR;
81 }
82 return WinMessageBox( HWND_DESKTOP, hwnd, text, title, 0UL, ulFlags );
83}
84
85#if 0
86/*!**************************************************/
87/* */
88/* @@DESC */
89/* */
90/* Show a message box with text strings loaded from */
91/* the resource DLL or the EXE file. */
92/* Unlike messagebox no buffers must be given but */
93/* only the string IDs. Max title length is 256, */
94/* max text length 256. */
95/* :p. */
96/* */
97/* This function is obsolete. */
98/* Use MsgShowMessageBox() instead. */
99/* */
100/* @@RETURNS */
101/* */
102/* ULONG ulResult */
103/* */
104/* MBID_ERROR in case of an error. */
105/* :p. */
106/* Result code from WinMessageBox(). */
107/* */
108/* @@REMARKS */
109/* */
110/* This function is obsolete. */
111/* Use MsgShowMessageBox() instead. */
112/* */
113/*!!*************************************************/
114ULONG showMessageBox2(HWND hwnd, ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag)
115{
116 char text[256];
117 char title[256];
118
119 return mBox( text, ulIDText , sizeof(text),
120 title, ulIDTitle, sizeof(title),
121 hModule, hwnd, ulFlag);
122};
123#endif
124
125/*!**************************************************/
126/* */
127/* @@DESC */
128/* */
129/* Show a message box with text strings loaded from */
130/* the resource DLL or the EXE file. */
131/* Unlike messagebox() no buffers must be given but */
132/* only the string IDs. Max title length is 256, */
133/* max text length 256. */
134/* */
135/* @@PARAM */
136/* */
137/* HWND hwnd input */
138/* */
139/* Handle to a window. This will be the owner of */
140/* the message box. */
141/* */
142/* @@PARAM */
143/* */
144/* ULONG ulIDTitle input */
145/* */
146/* ID of the string to be used as the title. */
147/* */
148/* @@PARAM */
149/* */
150/* ULONG ulIDText input */
151/* */
152/* ID of the string to be used as the text. */
153/* */
154/* @@PARAM */
155/* */
156/* HMODULE hModule input */
157/* */
158/* Handle to a ressource DLL or NULLHANDLE. If */
159/* this parameter is null the strings will be */
160/* taken from ressources bound to the executable. */
161/* */
162/* @@PARAM */
163/* */
164/* ULONG ulFlags input */
165/* */
166/* Flags specifying the appearance of the message */
167/* box. See WinMessageBox() for more information. */
168/* */
169/* @@RETURNS */
170/* */
171/* ULONG ulResult */
172/* */
173/* MBID_ERROR in case of an error. This may be */
174/* for example if the ressources can't be found. */
175/* :p. */
176/* Result code from WinMessageBox(). */
177/* */
178/* @@REMARKS */
179/* */
180/* The parent of the message box is HWND_DESKTOP. */
181/* */
182/*!!*************************************************/
183ULONG MsgShowMessageBox(HWND hwnd, ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag)
184{
185 PSZ pText;
186 PSZ pTitle;
187 ULONG rc;
188
189#define TLENGTH 256L
190
191 if(NULL==(pText=malloc(TLENGTH*2*sizeof(char))))
192 return MBID_ERROR;
193
194 pTitle=pText+TLENGTH*sizeof(char);
195
196 rc=mBox( pText, ulIDText , TLENGTH,
197 pTitle, ulIDTitle, TLENGTH,
198 hModule, hwnd, ulFlag);
199
200 free(pText);
201 return rc;
202};
203
204
205/*!**************************************************/
206/* */
207/* @@DESC */
208/* */
209/* Load a message string from a resource DLL or the */
210/* EXE file. */
211/* */
212/* @@RETURNS */
213/* */
214/* BOOL rc */
215/* */
216/* TRUE if string was found in the resource DLL or */
217/* EXE file. FALSE otherwise. */
218/* */
219/* @@REMARKS */
220/* */
221/* This function is obsolete. */
222/* Use MsgGetMessage() instead. */
223/* */
224/*!!*************************************************/
225BOOL getMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd)
226{
227 if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulID,lSizeText,text)) {
228 strcpy((PCHAR)text,"");
229 return FALSE;
230 }
231 return TRUE;
232}
233
234/*!***********************************************************/
235/* */
236/* Load a message string from a resource DLL or the */
237/* EXE file. */
238/* */
239/* @@RETURNS */
240/* */
241/* BOOL rc */
242/* */
243/* TRUE if string was found in the resource DLL or */
244/* EXE file. FALSE otherwise. */
245/* */
246/* @@REMARKS */
247/* */
248/* If an error occurs an empty string is placed in the */
249/* buffer. */
250/* */
251/*!!**********************************************************/
252BOOL MsgGetMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd)
253{
254 return getMessage( text, ulID, lSizeText, hResource, hwnd);
255}
256
257void pmUsage()
258{
259 WinMessageBox(HWND_DESKTOP,0,
260 "This helper shouldn't be started by hand. \
261 \nIt is called by the multimedia classes. \
262 \nIf you didn't launch the helper by hand you may have found a bug. \
263 \nPlease contact the author.",
264 "Problem with multimedia classes",12345,
265 MB_OK|MB_MOVEABLE|MB_ERROR);
266
267}
268
Note: See TracBrowser for help on using the repository browser.