[2] | 1 |
|
---|
| 2 | #define INCL_WIN
|
---|
| 3 |
|
---|
| 4 | #include <os2.h>
|
---|
| 5 | #include <stdio.h>
|
---|
[4] | 6 | #include <stdlib.h>
|
---|
[2] | 7 | #include <string.h>
|
---|
| 8 |
|
---|
| 9 | void errorResourceVerbose(void)
|
---|
| 10 | {
|
---|
| 11 | WinMessageBox(HWND_DESKTOP,0,
|
---|
| 12 | "The resource DLL which contains all the dialogs, graphics and messages cannot be loaded. \
|
---|
[104] | 13 | \nPlease check your installation.",
|
---|
| 14 | "Problem with class installation",12345,
|
---|
[2] | 15 | MB_OK|MB_MOVEABLE|MB_ERROR);
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | void 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
|
---|
[104] | 25 | know, the WPS is up and running.
|
---|
[2] | 26 | */
|
---|
| 27 | WinMessageBox(HWND_DESKTOP,0,
|
---|
| 28 | "The resource DLL which contains all the dialogs, graphics and messages cannot be loaded. \
|
---|
| 29 | Please 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 | /* */
|
---|
[4] | 47 | /* MBID_ERROR in case of an error. */
|
---|
[2] | 48 | /* :p. */
|
---|
| 49 | /* Result code from WinMessageBox(). */
|
---|
| 50 | /* */
|
---|
| 51 | /* */
|
---|
| 52 | /*!!*************************************************/
|
---|
[104] | 53 | ULONG messageBox( PSZ text, ULONG ulTextID , LONG lSizeText,
|
---|
| 54 | PSZ title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
[2] | 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 |
|
---|
[104] | 69 | static ULONG mBox( PSZ text, ULONG ulTextID , LONG lSizeText,
|
---|
| 70 | PSZ title, ULONG ulTitleID, LONG lSizeTitle,
|
---|
[2] | 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 |
|
---|
[4] | 85 | #if 0
|
---|
[2] | 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 */
|
---|
[4] | 93 | /* only the string IDs. Max title length is 256, */
|
---|
[2] | 94 | /* max text length 256. */
|
---|
[4] | 95 | /* :p. */
|
---|
[2] | 96 | /* */
|
---|
[4] | 97 | /* This function is obsolete. */
|
---|
| 98 | /* Use MsgShowMessageBox() instead. */
|
---|
| 99 | /* */
|
---|
[2] | 100 | /* @@RETURNS */
|
---|
| 101 | /* */
|
---|
| 102 | /* ULONG ulResult */
|
---|
| 103 | /* */
|
---|
[4] | 104 | /* MBID_ERROR in case of an error. */
|
---|
[2] | 105 | /* :p. */
|
---|
| 106 | /* Result code from WinMessageBox(). */
|
---|
| 107 | /* */
|
---|
[4] | 108 | /* @@REMARKS */
|
---|
[2] | 109 | /* */
|
---|
[4] | 110 | /* This function is obsolete. */
|
---|
| 111 | /* Use MsgShowMessageBox() instead. */
|
---|
| 112 | /* */
|
---|
[2] | 113 | /*!!*************************************************/
|
---|
| 114 | ULONG showMessageBox2(HWND hwnd, ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag)
|
---|
| 115 | {
|
---|
| 116 | char text[256];
|
---|
[4] | 117 | char title[256];
|
---|
[2] | 118 |
|
---|
| 119 | return mBox( text, ulIDText , sizeof(text),
|
---|
| 120 | title, ulIDTitle, sizeof(title),
|
---|
| 121 | hModule, hwnd, ulFlag);
|
---|
| 122 | };
|
---|
[4] | 123 | #endif
|
---|
[2] | 124 |
|
---|
| 125 | /*!**************************************************/
|
---|
| 126 | /* */
|
---|
| 127 | /* @@DESC */
|
---|
| 128 | /* */
|
---|
[4] | 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 | /*!!*************************************************/
|
---|
| 183 | ULONG MsgShowMessageBox(HWND hwnd, ULONG ulIDTitle, ULONG ulIDText, HMODULE hModule, ULONG ulFlag)
|
---|
| 184 | {
|
---|
[104] | 185 | PSZ pText;
|
---|
| 186 | PSZ pTitle;
|
---|
[4] | 187 | ULONG rc;
|
---|
| 188 |
|
---|
| 189 | #define TLENGTH 256L
|
---|
| 190 |
|
---|
[108] | 191 | if(NULL==(pText=malloc(TLENGTH*2*sizeof(char))))
|
---|
[4] | 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 | /* */
|
---|
[2] | 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 | /* */
|
---|
[4] | 219 | /* @@REMARKS */
|
---|
| 220 | /* */
|
---|
| 221 | /* This function is obsolete. */
|
---|
| 222 | /* Use MsgGetMessage() instead. */
|
---|
| 223 | /* */
|
---|
[2] | 224 | /*!!*************************************************/
|
---|
[104] | 225 | BOOL getMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd)
|
---|
[2] | 226 | {
|
---|
| 227 | if(!WinLoadString(WinQueryAnchorBlock(hwnd),hResource,ulID,lSizeText,text)) {
|
---|
[104] | 228 | strcpy((PCHAR)text,"");
|
---|
[2] | 229 | return FALSE;
|
---|
| 230 | }
|
---|
| 231 | return TRUE;
|
---|
| 232 | }
|
---|
| 233 |
|
---|
[4] | 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 | /*!!**********************************************************/
|
---|
[104] | 252 | BOOL MsgGetMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd)
|
---|
[2] | 253 | {
|
---|
| 254 | return getMessage( text, ulID, lSizeText, hResource, hwnd);
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | void pmUsage()
|
---|
| 258 | {
|
---|
| 259 | WinMessageBox(HWND_DESKTOP,0,
|
---|
[104] | 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.",
|
---|
[2] | 264 | "Problem with multimedia classes",12345,
|
---|
| 265 | MB_OK|MB_MOVEABLE|MB_ERROR);
|
---|
| 266 |
|
---|
| 267 | }
|
---|
| 268 |
|
---|