| 1 | /**************************************************************************
|
|---|
| 2 | *
|
|---|
| 3 | * SOURCE FILE NAME = PDFWRITE.C
|
|---|
| 4 | *
|
|---|
| 5 | * DESCRIPTIVE NAME = Portdriver to redirect PS stream to GhostScript
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright : Bart van Leeuwen, netlabs 2000
|
|---|
| 8 | *
|
|---|
| 9 | * VERSION = V0.1.7 Beta Release
|
|---|
| 10 | *
|
|---|
| 11 | * DATE = 26-2-2000
|
|---|
| 12 | *
|
|---|
| 13 | ****************************************************************************/
|
|---|
| 14 |
|
|---|
| 15 | #define LINT_ARGS /* argument checking enabled */
|
|---|
| 16 |
|
|---|
| 17 | #define INCL_DOS
|
|---|
| 18 | #define INCL_GPI
|
|---|
| 19 | #undef INCL_GPI
|
|---|
| 20 | #define INCL_DEV
|
|---|
| 21 | #define INCL_DOSMEMMGR /* Include standard OS/2 support */
|
|---|
| 22 | #define INCL_DOSMODULEMGR /* For DosLoadModule */
|
|---|
| 23 | #define INCL_DOSPROCESS
|
|---|
| 24 | #define INCL_GPILCIDS
|
|---|
| 25 | #define INCL_WINCOMMON /* Include Window Management support */
|
|---|
| 26 | #define INCL_WINDOWMGR
|
|---|
| 27 | #define INCL_WINSWITCHLIST
|
|---|
| 28 | #define INCL_WINPROGRAMLIST
|
|---|
| 29 | #define INCL_WINMENUS
|
|---|
| 30 | #define INCL_WINWINDOWMGR
|
|---|
| 31 | #define INCL_WINMESSAGEMGR
|
|---|
| 32 | #define INCL_WINDIALOGS
|
|---|
| 33 | #define INCL_WINSTATICS
|
|---|
| 34 | #define INCL_WINLISTBOXES
|
|---|
| 35 | #define INCL_WINMENUS
|
|---|
| 36 | #define INCL_WINSYS
|
|---|
| 37 | #define INCL_WINFRAMEMGR
|
|---|
| 38 | #define INCL_INCLWINACCELERATORS
|
|---|
| 39 | #define INCL_WINPOINTERS
|
|---|
| 40 | #define INCL_WINERRORS
|
|---|
| 41 | #define INCL_WINSHELLDATA
|
|---|
| 42 |
|
|---|
| 43 | #define INCL_WINTYPES
|
|---|
| 44 | #define INCL_WINACCELERATORS
|
|---|
| 45 | #define INCL_WINBUTTONS
|
|---|
| 46 | #define INCL_WINENTRYFIELDS
|
|---|
| 47 | #define INCL_WINRECTANGLES
|
|---|
| 48 | #define INCL_WINTIMER
|
|---|
| 49 | #define INCL_WINSCROLLBARS
|
|---|
| 50 | #define INCL_WINHEAP
|
|---|
| 51 | #define INCL_SHLERRORS
|
|---|
| 52 | #define INCL_WININPUT
|
|---|
| 53 | #define INCL_WINHELP
|
|---|
| 54 | #define INCL_WINSTDSPIN
|
|---|
| 55 | #define INCL_WINSTDFILE
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | #define INCL_SPL
|
|---|
| 59 | #define INCL_SPLP
|
|---|
| 60 | #define INCL_SPLERRORS
|
|---|
| 61 | #define INCL_SHLERRORS
|
|---|
| 62 | #define INCL_DOSERRORS
|
|---|
| 63 | #define INCL_WINHOOKS
|
|---|
| 64 | #define INCL_SPLDOSPRINT
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | #include <os2.h>
|
|---|
| 68 |
|
|---|
| 69 | #include <stdlib.h>
|
|---|
| 70 | #include <stdio.h>
|
|---|
| 71 | #include <string.h>
|
|---|
| 72 | #include <time.h>
|
|---|
| 73 |
|
|---|
| 74 | #include "ecups.h"
|
|---|
| 75 | #include "echelp.h"
|
|---|
| 76 | #include "ecdebug.h"
|
|---|
| 77 |
|
|---|
| 78 | extern PSZ szDefaultPortDrvPath;
|
|---|
| 79 |
|
|---|
| 80 | /*
|
|---|
| 81 | ** We want to avoid automatically loading the help manager(HELPMGR.DLL),
|
|---|
| 82 | ** since this takes up lots of memory.
|
|---|
| 83 | ** Do this by only linking to the HELPMGR if user selects help item.
|
|---|
| 84 | ** We replace the WinxxxxHelpInstance calls with our local versions.
|
|---|
| 85 | ** These versions use DosLoadModule() and DosQueryProcAddr() to
|
|---|
| 86 | ** call the "real" help manager functions.
|
|---|
| 87 | ** The below function pointers, prototypes and variables are used
|
|---|
| 88 | ** to this end.
|
|---|
| 89 | */
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | /*
|
|---|
| 93 | ** Following routines replace Win help manager function calls.
|
|---|
| 94 | ** This is done to avoid automatically loading the help manager
|
|---|
| 95 | ** when the port driver is used.
|
|---|
| 96 | ** DosLoadModule is used to get the help manager function addresses
|
|---|
| 97 | ** and WinHook mechanism is used to get notified of F1 key.
|
|---|
| 98 | **
|
|---|
| 99 | ** All CallxxHelpxx call equivalent WinxxHelpxx
|
|---|
| 100 | */
|
|---|
| 101 |
|
|---|
| 102 | /****************************************************************************
|
|---|
| 103 | *
|
|---|
| 104 | * FUNCTION NAME = CALLAssociateHelpInstance
|
|---|
| 105 | *
|
|---|
| 106 | * DESCRIPTION =
|
|---|
| 107 | *
|
|---|
| 108 | * INPUT =
|
|---|
| 109 | *
|
|---|
| 110 | * OUTPUT =
|
|---|
| 111 | *
|
|---|
| 112 | * RETURN-NORMAL =
|
|---|
| 113 | * RETURN-ERROR =
|
|---|
| 114 | *
|
|---|
| 115 | ****************************************************************************/
|
|---|
| 116 |
|
|---|
| 117 | BOOL APIENTRY CALLAssociateHelpInstance (HWND hwndHelpInstance,
|
|---|
| 118 | HWND hwndApp)
|
|---|
| 119 | {
|
|---|
| 120 | ULONG rc = 0;
|
|---|
| 121 | HMODULE hModule;
|
|---|
| 122 |
|
|---|
| 123 | if (!hvHelpmgrModule)
|
|---|
| 124 | {
|
|---|
| 125 | /*
|
|---|
| 126 | ** If there is an error display it and return.
|
|---|
| 127 | ** This call should only be made if CreateHelpInstance was called.
|
|---|
| 128 | **
|
|---|
| 129 | ** This uses an error message from print object and should
|
|---|
| 130 | ** be replaced with custom message.
|
|---|
| 131 | */
|
|---|
| 132 | DosQueryModuleHandle ("WPPRINT", &hModule);
|
|---|
| 133 |
|
|---|
| 134 | #define STR_BASE 7000
|
|---|
| 135 | #define STR_DLL_LOAD_ERROR (STR_BASE + 36)
|
|---|
| 136 |
|
|---|
| 137 | DisplayError (HWND_DESKTOP, hModule, STR_DLL_LOAD_ERROR,
|
|---|
| 138 | MB_OK | MB_APPLMODAL | MB_MOVEABLE);
|
|---|
| 139 | }
|
|---|
| 140 | else
|
|---|
| 141 | {
|
|---|
| 142 | /*
|
|---|
| 143 | ** Check to see if we have the pointer from a previous call
|
|---|
| 144 | */
|
|---|
| 145 | if (!pfnWinAssociateHelpInstance)
|
|---|
| 146 | {
|
|---|
| 147 | /*
|
|---|
| 148 | ** Get pointer to the location of the function we want.
|
|---|
| 149 | */
|
|---|
| 150 | rc = DosQueryProcAddr (hvHelpmgrModule,(ULONG)NULL,
|
|---|
| 151 | PROC_WIN32ASSOCIATEHELPINSTANCE, /* @119994 */
|
|---|
| 152 | (PFN *)&pfnWinAssociateHelpInstance);
|
|---|
| 153 | }
|
|---|
| 154 | /*
|
|---|
| 155 | ** If no error continue.
|
|---|
| 156 | */
|
|---|
| 157 | if (!rc )
|
|---|
| 158 | {
|
|---|
| 159 | rc = (*pfnWinAssociateHelpInstance)(hwndHelpInstance, hwndApp);
|
|---|
| 160 | /*
|
|---|
| 161 | ** Function returns a bool
|
|---|
| 162 | */
|
|---|
| 163 | if (rc == TRUE)
|
|---|
| 164 | return(TRUE);
|
|---|
| 165 | }
|
|---|
| 166 | }
|
|---|
| 167 | return(FALSE);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | /****************************************************************************
|
|---|
| 171 | *
|
|---|
| 172 | * FUNCTION NAME = CALLCreateHelpInstance
|
|---|
| 173 | *
|
|---|
| 174 | * DESCRIPTION =
|
|---|
| 175 | *
|
|---|
| 176 | * INPUT =
|
|---|
| 177 | *
|
|---|
| 178 | * OUTPUT =
|
|---|
| 179 | *
|
|---|
| 180 | * RETURN-NORMAL =
|
|---|
| 181 | * RETURN-ERROR =
|
|---|
| 182 | *
|
|---|
| 183 | ****************************************************************************/
|
|---|
| 184 |
|
|---|
| 185 | HWND APIENTRY CALLCreateHelpInstance (HAB hab,
|
|---|
| 186 | PHELPINIT phinitHMInitStructure)
|
|---|
| 187 | {
|
|---|
| 188 | ULONG rc = 0;
|
|---|
| 189 | HWND hwnd = (HWND)NULLHANDLE;
|
|---|
| 190 | HMODULE hModule;
|
|---|
| 191 |
|
|---|
| 192 | /*
|
|---|
| 193 | ** Check to see if we already have the handle
|
|---|
| 194 | */
|
|---|
| 195 | if (!hvHelpmgrModule)
|
|---|
| 196 | rc = DosLoadModule((PSZ)NULL, 0, (PSZ)"HELPMGR",
|
|---|
| 197 | (PHMODULE)&hvHelpmgrModule);
|
|---|
| 198 | if (rc)
|
|---|
| 199 | {
|
|---|
| 200 | /*
|
|---|
| 201 | ** If there is an error dispaly it and return.
|
|---|
| 202 | */
|
|---|
| 203 | DosQueryModuleHandle ("WPPRINT", &hModule);
|
|---|
| 204 | DisplayError (HWND_DESKTOP, hModule, STR_DLL_LOAD_ERROR,
|
|---|
| 205 | MB_OK | MB_APPLMODAL | MB_MOVEABLE);
|
|---|
| 206 | }
|
|---|
| 207 | else
|
|---|
| 208 | {
|
|---|
| 209 | if (!pfnWinCreateHelpInstance)
|
|---|
| 210 | /*
|
|---|
| 211 | ** Next get pointer to the location of the function we want.
|
|---|
| 212 | */
|
|---|
| 213 | rc = DosQueryProcAddr (hvHelpmgrModule,(ULONG)NULL,
|
|---|
| 214 | PROC_WIN32CREATEHELPINSTANCE, /* @119994 */
|
|---|
| 215 | (PFN *)&pfnWinCreateHelpInstance);
|
|---|
| 216 | /*
|
|---|
| 217 | ** If no error continue.
|
|---|
| 218 | */
|
|---|
| 219 | if (!rc )
|
|---|
| 220 | hwnd = (*pfnWinCreateHelpInstance)(hab, phinitHMInitStructure );
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 | return(hwnd);
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | /****************************************************************************
|
|---|
| 227 | *
|
|---|
| 228 | * FUNCTION NAME = CALLDestroyHelpInstance
|
|---|
| 229 | *
|
|---|
| 230 | * DESCRIPTION =
|
|---|
| 231 | *
|
|---|
| 232 | * INPUT =
|
|---|
| 233 | *
|
|---|
| 234 | * OUTPUT =
|
|---|
| 235 | *
|
|---|
| 236 | * RETURN-NORMAL =
|
|---|
| 237 | * RETURN-ERROR =
|
|---|
| 238 | *
|
|---|
| 239 | ****************************************************************************/
|
|---|
| 240 |
|
|---|
| 241 | BOOL APIENTRY CALLDestroyHelpInstance (HWND hwndHelpInstance)
|
|---|
| 242 | {
|
|---|
| 243 |
|
|---|
| 244 | ULONG rc = 0;
|
|---|
| 245 | HMODULE hModule;
|
|---|
| 246 |
|
|---|
| 247 | if (!hvHelpmgrModule)
|
|---|
| 248 | {
|
|---|
| 249 | /*
|
|---|
| 250 | ** If there is an error display it and return.
|
|---|
| 251 | */
|
|---|
| 252 | DosQueryModuleHandle ("WPPRINT", &hModule);
|
|---|
| 253 | DisplayError (HWND_DESKTOP, hModule, STR_DLL_LOAD_ERROR,
|
|---|
| 254 | MB_OK | MB_APPLMODAL | MB_MOVEABLE);
|
|---|
| 255 | }
|
|---|
| 256 | else
|
|---|
| 257 | {
|
|---|
| 258 | if (!pfnWinDestroyHelpInstance)
|
|---|
| 259 | /*
|
|---|
| 260 | ** Next get pointer to the location of the function we want.
|
|---|
| 261 | */
|
|---|
| 262 | rc = DosQueryProcAddr (hvHelpmgrModule,(ULONG)NULL,
|
|---|
| 263 | PROC_WIN32DESTROYHELPINSTANCE, /* @119994 */
|
|---|
| 264 | (PFN *)&pfnWinDestroyHelpInstance);
|
|---|
| 265 | /*
|
|---|
| 266 | ** If no error continue.
|
|---|
| 267 | */
|
|---|
| 268 | if (!rc )
|
|---|
| 269 | {
|
|---|
| 270 | rc = (*pfnWinDestroyHelpInstance)(hwndHelpInstance);
|
|---|
| 271 | /*
|
|---|
| 272 | ** Function returns a bool
|
|---|
| 273 | */
|
|---|
| 274 | if (rc == TRUE)
|
|---|
| 275 | {
|
|---|
| 276 | return(TRUE);
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | }
|
|---|
| 280 | return(FALSE);
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | /****************************************************************************
|
|---|
| 284 | *
|
|---|
| 285 | * FUNCTION NAME = CALLQueryHelpInstance
|
|---|
| 286 | *
|
|---|
| 287 | * DESCRIPTION =
|
|---|
| 288 | *
|
|---|
| 289 | * INPUT =
|
|---|
| 290 | *
|
|---|
| 291 | * OUTPUT =
|
|---|
| 292 | *
|
|---|
| 293 | * RETURN-NORMAL =
|
|---|
| 294 | *
|
|---|
| 295 | * RETURN-ERROR =
|
|---|
| 296 | *
|
|---|
| 297 | ****************************************************************************/
|
|---|
| 298 |
|
|---|
| 299 | HWND APIENTRY CALLQueryHelpInstance (HWND hwndApp)
|
|---|
| 300 | {
|
|---|
| 301 | ULONG rc = 0;
|
|---|
| 302 | HWND hwnd = (HWND)NULLHANDLE;
|
|---|
| 303 | HMODULE hModule;
|
|---|
| 304 |
|
|---|
| 305 | if (!hvHelpmgrModule)
|
|---|
| 306 | {
|
|---|
| 307 | /*
|
|---|
| 308 | ** If there is an error display it and return.
|
|---|
| 309 | */
|
|---|
| 310 | DosQueryModuleHandle ("WPPRINT", &hModule);
|
|---|
| 311 | DisplayError (HWND_DESKTOP, hModule, STR_DLL_LOAD_ERROR,
|
|---|
| 312 | MB_OK | MB_APPLMODAL | MB_MOVEABLE);
|
|---|
| 313 | }
|
|---|
| 314 | else
|
|---|
| 315 | {
|
|---|
| 316 | if (!pfnWinQueryHelpInstance)
|
|---|
| 317 | /*
|
|---|
| 318 | ** Get pointer to the location of the function we want.
|
|---|
| 319 | */
|
|---|
| 320 | rc = DosQueryProcAddr (hvHelpmgrModule,(ULONG)NULL,
|
|---|
| 321 | PROC_WIN32QUERYHELPINSTANCE, /* @119994 */
|
|---|
| 322 | (PFN *)&pfnWinQueryHelpInstance);
|
|---|
| 323 | /*
|
|---|
| 324 | ** If no error continue.
|
|---|
| 325 | */
|
|---|
| 326 | if (!rc )
|
|---|
| 327 | {
|
|---|
| 328 | /*
|
|---|
| 329 | ** Make sure that the handle is associated with this instance
|
|---|
| 330 | **
|
|---|
| 331 | ** Make call
|
|---|
| 332 | */
|
|---|
| 333 | hwnd = (*pfnWinQueryHelpInstance)( hwndApp);
|
|---|
| 334 |
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 | return(hwnd);
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | /****************************************************************************
|
|---|
| 341 | *
|
|---|
| 342 | * FUNCTION NAME = SetHelpStubHook
|
|---|
| 343 | *
|
|---|
| 344 | * DESCRIPTION =
|
|---|
| 345 | *
|
|---|
| 346 | * INPUT =
|
|---|
| 347 | *
|
|---|
| 348 | * OUTPUT =
|
|---|
| 349 | *
|
|---|
| 350 | * RETURN-NORMAL =
|
|---|
| 351 | * RETURN-ERROR =
|
|---|
| 352 | *
|
|---|
| 353 | ****************************************************************************/
|
|---|
| 354 |
|
|---|
| 355 | BOOL EXPENTRY SetHelpStubHook()
|
|---|
| 356 | {
|
|---|
| 357 | if(!HelpStubHookIsSet)
|
|---|
| 358 | {
|
|---|
| 359 | if(WinSetHook(0L, HMQ_CURRENT, HK_HELP, (PFN)HelpStubHook, 0L))
|
|---|
| 360 | {
|
|---|
| 361 | HelpStubHookIsSet = TRUE;
|
|---|
| 362 | return TRUE;
|
|---|
| 363 | }
|
|---|
| 364 | }
|
|---|
| 365 | return FALSE;
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | /****************************************************************************
|
|---|
| 369 | *
|
|---|
| 370 | * FUNCTION NAME = ReleaseHelpStubHook
|
|---|
| 371 | *
|
|---|
| 372 | * DESCRIPTION =
|
|---|
| 373 | *
|
|---|
| 374 | * INPUT =
|
|---|
| 375 | *
|
|---|
| 376 | * OUTPUT =
|
|---|
| 377 | *
|
|---|
| 378 | * RETURN-NORMAL =
|
|---|
| 379 | * RETURN-ERROR =
|
|---|
| 380 | *
|
|---|
| 381 | ****************************************************************************/
|
|---|
| 382 |
|
|---|
| 383 | VOID EXPENTRY ReleaseHelpStubHook()
|
|---|
| 384 | {
|
|---|
| 385 | if(HelpStubHookIsSet)
|
|---|
| 386 | {
|
|---|
| 387 | WinReleaseHook(0L, HMQ_CURRENT, HK_HELP, (PFN)HelpStubHook, 0L);
|
|---|
| 388 | HelpStubHookIsSet = FALSE;
|
|---|
| 389 | }
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | /****************************************************************************
|
|---|
| 393 | *
|
|---|
| 394 | * FUNCTION NAME = HelpStubHook
|
|---|
| 395 | *
|
|---|
| 396 | * DESCRIPTION =
|
|---|
| 397 | *
|
|---|
| 398 | * INPUT =
|
|---|
| 399 | *
|
|---|
| 400 | * OUTPUT =
|
|---|
| 401 | *
|
|---|
| 402 | * RETURN-NORMAL =
|
|---|
| 403 | *
|
|---|
| 404 | * RETURN-ERROR =
|
|---|
| 405 | *
|
|---|
| 406 | ****************************************************************************/
|
|---|
| 407 |
|
|---|
| 408 | INT EXPENTRY HelpStubHook(HAB AppHAB,
|
|---|
| 409 | USHORT Context,
|
|---|
| 410 | USHORT IdTopic,
|
|---|
| 411 | USHORT IdSubTopic,
|
|---|
| 412 | PRECTL RectLPtr )
|
|---|
| 413 | {
|
|---|
| 414 |
|
|---|
| 415 | InitializeHelp();
|
|---|
| 416 |
|
|---|
| 417 | return FALSE;
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | /****************************************************************************
|
|---|
| 421 | *
|
|---|
| 422 | * FUNCTION NAME = InitializeHelp
|
|---|
| 423 | *
|
|---|
| 424 | * DESCRIPTION =
|
|---|
| 425 | *
|
|---|
| 426 | * INPUT =
|
|---|
| 427 | *
|
|---|
| 428 | * OUTPUT =
|
|---|
| 429 | *
|
|---|
| 430 | * RETURN-NORMAL =
|
|---|
| 431 | * RETURN-ERROR =
|
|---|
| 432 | *
|
|---|
| 433 | ****************************************************************************/
|
|---|
| 434 |
|
|---|
| 435 | VOID EXPENTRY InitializeHelp()
|
|---|
| 436 | {
|
|---|
| 437 | HAB hAB = NULLHANDLE; /* @WPOS */
|
|---|
| 438 | HWND hWnd;
|
|---|
| 439 | HWND hWndActive;
|
|---|
| 440 | ULONG ulBootDrive;
|
|---|
| 441 | HMODULE hModule;
|
|---|
| 442 | CHAR szBuf[256];
|
|---|
| 443 | CHAR szPathName[260]; /* will contain full path to this port driver */
|
|---|
| 444 |
|
|---|
| 445 | if(HelpAlreadyInitialized) return;
|
|---|
| 446 |
|
|---|
| 447 | /*
|
|---|
| 448 | ** Initialize Help
|
|---|
| 449 | ** ---------------
|
|---|
| 450 | **
|
|---|
| 451 | ** Create an instance of the Help Manager, and associate it
|
|---|
| 452 | ** with the Frame. If the Association fails, we handle it
|
|---|
| 453 | ** the same way as if the creation fails, ie hwndHelp
|
|---|
| 454 | ** (the Help Manager Object Window handle) is set to NULL.
|
|---|
| 455 | ** If we can't load the Module containing the Help Panel
|
|---|
| 456 | ** definitions, we forget Help altogether.
|
|---|
| 457 | */
|
|---|
| 458 | hWndActive = WinQueryActiveWindow(HWND_DESKTOP);
|
|---|
| 459 | hWnd = WinQueryWindow(hWndActive,QW_OWNER);
|
|---|
| 460 | /*
|
|---|
| 461 | ** if unable to get active window's owner
|
|---|
| 462 | ** use active window
|
|---|
| 463 | */
|
|---|
| 464 | if (hWnd == (HWND)NULL)
|
|---|
| 465 | hWnd = hWndActive ;
|
|---|
| 466 |
|
|---|
| 467 | /*
|
|---|
| 468 | ** We need our module handle.
|
|---|
| 469 | ** Easiest way to do this is to find the path to our port driver
|
|---|
| 470 | ** from the system INI file.
|
|---|
| 471 | ** If not found in the INI file
|
|---|
| 472 | ** assume it is in the boot drive's \OS2\DLL directory
|
|---|
| 473 | */
|
|---|
| 474 |
|
|---|
| 475 | /* change ? in szDefaultPortDrvPath to boot drive */
|
|---|
| 476 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
|---|
| 477 | sizeof (ULONG));
|
|---|
| 478 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
|
|---|
| 479 |
|
|---|
| 480 | PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
|---|
| 481 | "PM_PORT_DRIVER",
|
|---|
| 482 | "PDFWRITE",
|
|---|
| 483 | szDefaultPortDrvPath,
|
|---|
| 484 | szPathName,
|
|---|
| 485 | 256 );
|
|---|
| 486 |
|
|---|
| 487 | /*
|
|---|
| 488 | ** get module handle for our dll
|
|---|
| 489 | */
|
|---|
| 490 | DosQueryModuleHandle (szPathName, &hModule);
|
|---|
| 491 |
|
|---|
| 492 | /*
|
|---|
| 493 | ** Initialize a couple of the helpmgr structure elements
|
|---|
| 494 | ** First, get the title
|
|---|
| 495 | **
|
|---|
| 496 | ** Now load the title
|
|---|
| 497 | */
|
|---|
| 498 | WinLoadString (hAB, hModule,
|
|---|
| 499 | (USHORT)(PORT_HELP_TITLE), (SHORT)(256), szBuf);
|
|---|
| 500 | hmiHelpData.pszHelpWindowTitle = (PSZ)szBuf;
|
|---|
| 501 | hmiHelpData.pszHelpLibraryName = "WPHELP.HLP";
|
|---|
| 502 |
|
|---|
| 503 | hAB = WinQueryAnchorBlock(hWnd);
|
|---|
| 504 |
|
|---|
| 505 | /*
|
|---|
| 506 | ** Only create a handle if we don't have one.
|
|---|
| 507 | */
|
|---|
| 508 | if (hwndHelp == 0L)
|
|---|
| 509 | hwndHelp = CALLCreateHelpInstance(hAB, &hmiHelpData);
|
|---|
| 510 |
|
|---|
| 511 | /*
|
|---|
| 512 | ** Always associate the helpmgr handle with the active window
|
|---|
| 513 | */
|
|---|
| 514 | if (hwndHelp != 0L)
|
|---|
| 515 | {
|
|---|
| 516 | if(!CALLAssociateHelpInstance(hwndHelp, hWnd) )
|
|---|
| 517 | {
|
|---|
| 518 | CALLDestroyHelpInstance(hwndHelp);
|
|---|
| 519 | hwndHelp = (HWND)0L;
|
|---|
| 520 | }
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | /*
|
|---|
| 524 | ** If help was initialized, get rid of our hook. Otherwise, we have
|
|---|
| 525 | ** to ensure that our stub hook is the FIRST hook in the HK_HELP
|
|---|
| 526 | ** hook chain.
|
|---|
| 527 | */
|
|---|
| 528 | if (hwndHelp != 0L)
|
|---|
| 529 | {
|
|---|
| 530 | HelpAlreadyInitialized = TRUE;
|
|---|
| 531 | ReleaseHelpStubHook();
|
|---|
| 532 | }
|
|---|
| 533 | else
|
|---|
| 534 | {
|
|---|
| 535 | ReleaseHelpStubHook();
|
|---|
| 536 | SetHelpStubHook();
|
|---|
| 537 | }
|
|---|
| 538 | }
|
|---|