Changeset 365 for trunk/hlpmgr
- Timestamp:
- Feb 5, 2010, 8:58:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hlpmgr/helpmgr.c
r26 r365 1 1 // Standard library 2 #include <string.h> 3 #include <stdlib.h> 2 #include <string.h> 3 #include <stdlib.h> 4 4 #include <stdio.h> 5 5 … … 61 61 int g_HelpInstanceCount = 0; 62 62 63 // 64 65 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 66 ULONG msg, 67 MPARAM mp1, 63 // 64 65 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 66 ULONG msg, 67 MPARAM mp1, 68 68 MPARAM mp2 ); 69 69 … … 75 75 76 76 77 // Find if there is a help instance associated with 77 // Find if there is a help instance associated with 78 78 // this window 79 79 //-------------------------------------------------------------------------------- … … 85 85 LogEvent( " GetAssociatedHelpInstance" ); 86 86 87 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 87 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 88 88 { 89 89 pHelpInstance = g_pHelpInstances[ i ]; … … 91 91 { 92 92 LogEvent( " Instance %d: %8x", i, pHelpInstance ); 93 if ( IsWindowAssociated( pHelpInstance, 93 if ( IsWindowAssociated( pHelpInstance, 94 94 hwnd ) ) 95 95 { … … 99 99 } 100 100 } 101 101 102 102 return NULL; 103 103 } … … 112 112 HWND hwnd; 113 113 HWND hClientWnd; 114 TPHelpInstance pHelpInstance; 114 TPHelpInstance pHelpInstance; 115 115 LONG SearchType; 116 116 117 117 LogEvent( "QueryHelpInstance" ); 118 118 119 hDesktopWindow = WinQueryDesktopWindow( WinQueryAnchorBlock( hwndApp ), 119 hDesktopWindow = WinQueryDesktopWindow( WinQueryAnchorBlock( hwndApp ), 120 120 NULLHANDLE ); 121 121 … … 145 145 LogEvent( " Found help instance: %8x", pHelpInstance ); 146 146 return pHelpInstance; 147 } 147 } 148 148 } 149 149 else … … 152 152 } 153 153 } 154 154 155 155 LogEvent( " No help instance" ); 156 156 … … 180 180 } 181 181 hwnd = parentOrOwner; 182 } 182 } 183 183 184 184 LogEvent( " No help instance found" ); … … 203 203 LogEvent( "--------------------------------------------------" ); 204 204 LogEvent( "NHM32CreateHelpInstance" ); 205 LogEvent( " Help Manager Version: %s", 206 HelpMgrVersion ); 207 208 LogEvent( " Filename(s): %s", 209 phinitHMInitStructure -> pszHelpLibraryName ); 210 LogEvent( " Title: %s", 211 phinitHMInitStructure -> pszHelpWindowTitle ); 205 LogEvent( " Help Manager Version: %s", HelpMgrVersion ); 206 LogEvent( " Filename(s): %s", phinitHMInitStructure -> pszHelpLibraryName ); 207 LogEvent( " Title: %s", phinitHMInitStructure -> pszHelpWindowTitle ); 212 208 213 209 pHelpInstance = MakeNewHelpInstance(); … … 215 211 // find blank slot in help instance array 216 212 FoundUnusedSlot = FALSE; 217 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 213 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 218 214 { 219 215 if ( g_pHelpInstances[ i ] == NULL ) … … 226 222 if ( ! FoundUnusedSlot ) 227 223 { 228 LogEvent( "Too many help instances, out of slots" ); 224 LogEvent( "Too many help instances, out of slots" ); 229 225 return NULLHANDLE; 230 226 } 231 227 232 228 g_HelpInstanceCount ++; 233 229 … … 242 238 { 243 239 rc = WinGetLastError( hab ); 244 LogEvent( "WinRegisterClass failed, error=%d", rc ); 240 LogEvent( "WinRegisterClass failed, error=%d", rc ); 245 241 return NULLHANDLE; 246 242 } … … 249 245 250 246 // Create help window as an object window (child of HWND_OBJECT) 251 pHelpInstance -> FHandle = 247 pHelpInstance -> FHandle = 252 248 WinCreateWindow( HWND_OBJECT, // parent: object window 253 249 szNewHelpManagerClass, // window class … … 260 256 NULL, // control data - none 261 257 NULL ); // presentation parameters - none 262 258 263 259 if ( pHelpInstance -> FHandle == NULLHANDLE ) 264 260 { … … 271 267 // store instance pointer and magic number for checking later. 272 268 // Could just have used class name! 273 WinSetWindowULong( pHelpInstance -> FHandle, 269 WinSetWindowULong( pHelpInstance -> FHandle, 274 270 QWL_HELPINSTANCEMAGICNUMBER, 275 271 HELPINSTANCEMAGICNUMBER ); 276 WinSetWindowULong( pHelpInstance -> FHandle, 272 WinSetWindowULong( pHelpInstance -> FHandle, 277 273 QWL_HELPINSTANCEPTR, 278 274 (ULONG) pHelpInstance ); … … 308 304 pHelpInstance -> HelpTableFromResource = FALSE; 309 305 310 if ( HelpTable != 0 ) 306 if ( HelpTable != 0 ) 311 307 { 312 308 if ( ( HelpTable & 0xffff0000 ) == 0xffff0000 ) … … 329 325 else 330 326 { 331 pHelpInstance -> pHelpTable = NULL; 327 pHelpInstance -> pHelpTable = NULL; 332 328 } 333 329 … … 336 332 pHelpInstance -> FViewerStartupMessagesCount = 0; 337 333 338 LogEvent( " Allocating shared memory: %s", 339 SHARED_MEM_NAME ); 334 LogEvent( " Allocating shared memory: %s", SHARED_MEM_NAME ); 340 335 rc = GetSubAllocatedSharedMemory( SHARED_MEM_NAME, 341 336 SHARED_MEM_SIZE, … … 347 342 return NULLHANDLE; 348 343 } 349 pSharedStruct = 344 pSharedStruct = 350 345 (TNewHelpMgrSharedStruct*) pHelpInstance -> SharedMemory.FMem.FPointer; 351 346 352 strcpy( pSharedStruct -> Title, 353 "NewView Help Manager" ); 354 strcpy( pSharedStruct -> Version, 355 HelpMgrVersion ); 347 strcpy( pSharedStruct -> Title, "NewView Help Manager" ); 348 strcpy( pSharedStruct -> Version, HelpMgrVersion ); 356 349 357 350 phinitHMInitStructure -> ulReturnCode = 0; … … 381 374 382 375 // remove from list 383 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 376 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 384 377 if ( g_pHelpInstances[ i ] == pHelpInstance ) 385 378 g_pHelpInstances[ i ] = NULL; … … 443 436 444 437 // Notify the window (Only required by SmartSuite?) 445 WinSendMsg( hwndApp, 446 WM_SETHELPINFO, 447 (MPARAM) hwndHelpInstance, 438 WinSendMsg( hwndApp, 439 WM_SETHELPINFO, 440 (MPARAM) hwndHelpInstance, 448 441 0 ); 449 442 // Note this call seems to fail on some apps, so ignore result … … 454 447 LogEvent( " Help Instance NULLHANDLE, clearing" ); 455 448 456 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 457 { 458 pHelpInstance = g_pHelpInstances[ i ]; 459 if ( pHelpInstance != NULL ) 460 { 461 RemoveAssociatedWindow( pHelpInstance, 449 for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 450 { 451 pHelpInstance = g_pHelpInstances[ i ]; 452 if ( pHelpInstance != NULL ) 453 { 454 RemoveAssociatedWindow( pHelpInstance, 462 455 hwndApp ); 463 456 } … … 471 464 else 472 465 LogEvent( " Window Title: Blank/invalid" ); 473 466 474 467 pHelpInstance = GetHelpInstance( hwndHelpInstance ); 475 468 if ( pHelpInstance == NULL ) … … 546 539 // Portions contributed by Aaron Reed at IBM 547 540 548 // typedef void _Far16 * HWND16; 541 // typedef void _Far16 * HWND16; 549 542 typedef HWND HWND16; 550 543 typedef USHORT BOOL16; … … 562 555 PHELPSUBTABLE phstHelpSubTable; 563 556 USHORT idExtPanel; 564 557 565 558 } HELPTABLE16, _Far16 *PHELPTABLE16; 566 559 … … 578 571 USHORT usShowPanelId; 579 572 PSZ16 pszHelpLibraryName; 580 573 581 574 } HELPINIT16, _Far16 *PHELPINIT16; 582 575 … … 608 601 HelpTable = (ULONG) phinitHMInitStructure -> phtHelpTable; 609 602 LogEvent( " Help Table: %8x", HelpTable ); 610 if ( HelpTable ) 603 if ( HelpTable ) 611 604 { 612 605 if ( ( HelpTable & 0xffff0000 ) == 0xffff0000 ) … … 620 613 // It's a pointer, so convert 16->32 621 614 LogEvent( " Converting pointer" ); 622 helpinit.phtHelpTable = 615 helpinit.phtHelpTable = 623 616 (PHELPTABLE) (PHELPTABLE16) HelpTable; 624 617 } 625 618 } 626 619 627 helpinit.hmodHelpTableModule = 620 helpinit.hmodHelpTableModule = 628 621 (HMODULE) phinitHMInitStructure -> hmodHelpTableModule; 629 helpinit.pszHelpWindowTitle = 622 helpinit.pszHelpWindowTitle = 630 623 (PSZ) phinitHMInitStructure -> pszHelpWindowTitle; 631 helpinit.pszHelpLibraryName = 624 helpinit.pszHelpLibraryName = 632 625 (PSZ) phinitHMInitStructure -> pszHelpLibraryName; 633 626 634 627 LogEvent( " Conversions done, calling 32 bit" ); 635 628 636 629 hInstance = NHM32CreateHelpInstance( hab, &helpinit ); 637 630 638 631 LogEvent( " 32 bit returned, copying result code" ); 639 632 … … 663 656 { 664 657 LogEvent( "NHM16AssociateHelpInstance" ); 665 return NHM32AssociateHelpInstance( (HWND) hwndHelpInstance, 658 return NHM32AssociateHelpInstance( (HWND) hwndHelpInstance, 666 659 (HWND) hwndApp ); 667 660 } … … 755 748 756 749 if ( ChildControlID != (USHORT) -1 ) 757 { 758 // Child control -1 means not applicable (e.g. top level menu) 750 { 751 // Child control -1 means not applicable (e.g. top level menu) 759 752 if ( FindIDInHelpSubTable( ChildControlID, 760 753 pHelpSubTable, 761 754 pHelpPanelID ) ) 762 755 { 763 LogEvent( " Found Child Control ID, Panel: %hu", 756 LogEvent( " Found Child Control ID, Panel: %hu", 764 757 *pHelpPanelID ); 765 758 return TRUE; … … 777 770 pHelpSubTable, 778 771 pHelpPanelID ) ) 779 { 780 LogEvent( " Found Control ID, Panel: %hu", 772 { 773 LogEvent( " Found Control ID, Panel: %hu", 781 774 *pHelpPanelID ); 782 775 return TRUE; … … 785 778 LogEvent( " Control ID not found" ); 786 779 787 // Control not found, we can only show help for the 788 // Window as a whole. First, see if the subtable 789 // has an entry for the window 780 // Control not found, we can only show help for the 781 // Window as a whole. First, see if the subtable 782 // has an entry for the window 790 783 if ( FindIDInHelpSubTable( WindowID, 791 784 pHelpSubTable, 792 785 pHelpPanelID ) ) 793 786 { 794 LogEvent( " Found Window ID in subtable, Panel: %hu", 787 LogEvent( " Found Window ID in subtable, Panel: %hu", 795 788 *pHelpPanelID ); 796 789 return TRUE; … … 808 801 //-------------------------------------------------------------------------------- 809 802 // Help Hook function 810 // 803 // 811 804 // installed during WinCreateHelpInstance 812 805 // 813 // This function is called by the standard OS/2 windows on 806 // This function is called by the standard OS/2 windows on 814 807 // WM_HELP messages. 815 // 808 // 816 809 // Notes: 817 810 // The parameters are ULONG but passed from USHORTs … … 833 826 USHORT ChildControlID; 834 827 USHORT Mode; 835 828 836 829 ControlID = (USHORT) ulControlID; 837 830 ChildControlID = (USHORT) ulChildControlID; 838 831 Mode = (USHORT) ulMode; 839 832 840 833 LogEvent( "--------------------------------------------------" ); 841 834 LogEvent( "HelpHook" ); … … 852 845 853 846 pHelpInstance = GetHelpInstanceForWindowChain( hFocusWindow ); 854 847 855 848 if ( pHelpInstance == NULL ) 856 849 { … … 867 860 switch( Mode ) 868 861 { 869 case HLPM_MENU: 862 case HLPM_MENU: 870 863 LogEvent( " Menu Mode" ); 871 LogEvent( " Frame: %x", hFocusFrame ); 864 LogEvent( " Frame: %x", hFocusFrame ); 872 865 break; 873 866 … … 883 876 { 884 877 // override if active window set. 885 WindowID = WinQueryWindowUShort( pHelpInstance -> FActiveWindow, 878 WindowID = WinQueryWindowUShort( pHelpInstance -> FActiveWindow, 886 879 QWS_ID ); 887 880 LogEvent( " Active window set; overriding, Window ID: %d", WindowID ); … … 895 888 LogEvent( " Child Control ID: %hu", (USHORT) ChildControlID ); 896 889 897 if ( pHelpInstance -> pHelpTable == NULL ) 890 if ( pHelpInstance -> pHelpTable == NULL ) 898 891 { 899 892 LogEvent( " No Help Table loaded for instance" ); … … 902 895 903 896 if ( ! FindHelpTopic( pHelpInstance, 904 WindowID, 897 WindowID, 905 898 ControlID, 906 899 ChildControlID, … … 927 920 //-------------------------------------------------------------------------------- 928 921 929 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 930 ULONG msg, 931 MPARAM mp1, 922 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 923 ULONG msg, 924 MPARAM mp1, 932 925 MPARAM mp2 ) 933 { 926 { 934 927 USHORT PanelID; 935 928 char buffer[ 256 ]; … … 945 938 char* pMessageMem; 946 939 HWND hAppWindow; 947 940 948 941 if ( msg == WM_CREATE 949 942 || msg == WM_DESTROY … … 952 945 return 0; 953 946 954 if ( msg >= WM_USER 947 if ( msg >= WM_USER 955 948 && msg != NHM_VIEWER_READY 956 949 && msg != NHM_FORGET_VIEWER ) … … 963 956 964 957 pHelpInstance = GetHelpInstance( hwnd ); 965 if ( pHelpInstance == NULL ) 958 if ( pHelpInstance == NULL ) 966 959 { 967 960 LogEvent( " Not a valid help manager window" ); … … 980 973 LogEvent( " Message: %8x", msg ); 981 974 LogEvent( " App Window: %8x", (ULONG) hAppWindow ); 982 975 983 976 switch( msg ) 984 977 { 985 case HM_HELP_CONTENTS: 978 case HM_HELP_CONTENTS: 986 979 LogEvent( "HM_HELP_CONTENTS" ); 987 980 EnsureViewerRunning( pHelpInstance ); 988 PostViewerMessage( pHelpInstance, 989 NHM_HELP_CONTENTS, 990 0, 981 PostViewerMessage( pHelpInstance, 982 NHM_HELP_CONTENTS, 983 0, 991 984 0 ); 992 985 break; 993 986 994 case HM_HELP_INDEX: 987 case HM_HELP_INDEX: 995 988 LogEvent( "HM_HELP_INDEX" ); 996 989 EnsureViewerRunning( pHelpInstance ); 997 990 PostViewerMessage( pHelpInstance, 998 NHM_HELP_INDEX, 999 0, 991 NHM_HELP_INDEX, 992 0, 1000 993 0 ); 1001 994 break; 1002 995 1003 case HM_DISPLAY_HELP: 996 case HM_DISPLAY_HELP: 1004 997 LogEvent( " HM_DISPLAY_HELP" ); 1005 998 switch( (ULONG) mp2 ) … … 1041 1034 (MPARAM) pMessageMem, 1042 1035 0 ); 1043 1036 1044 1037 break; 1045 1038 } … … 1053 1046 // find active window 1054 1047 hFrameWindow = GetTopLevelWindow( WinQueryFocus( HWND_DESKTOP ) ); 1055 1048 1056 1049 // get ID 1057 1050 WindowID = WinQueryWindowUShort( hFrameWindow, QWS_ID ); … … 1073 1066 break; 1074 1067 1075 case HM_KEYS_HELP: 1068 case HM_KEYS_HELP: 1076 1069 LogEvent( "HM_KEYS_HELP" ); 1077 1070 if ( hAppWindow == NULLHANDLE ) … … 1079 1072 LogEvent( " No app windows; can't ask for keys help topic" ); 1080 1073 return 0; 1081 } 1082 PanelID = 1074 } 1075 PanelID = 1083 1076 (USHORT) WinSendMsg( hAppWindow, 1084 1077 HM_QUERY_KEYS_HELP, … … 1094 1087 0 ); 1095 1088 } 1096 1097 break; 1098 1089 1090 break; 1091 1099 1092 case HM_DISMISS_WINDOW: 1100 1093 LogEvent( "HM_DISMISS_WINDOW" ); … … 1117 1110 LogEvent( " Filename(s): %s", (char*) mp1 ); 1118 1111 StoreString( & pHelpInstance -> FHelpFileNames, 1119 (char*) mp1 ); 1112 (char*) mp1 ); 1120 1113 if ( pHelpInstance -> FViewerStarted ) 1121 1114 { … … 1148 1141 0 ); 1149 1142 } 1150 break; 1143 break; 1151 1144 1152 1145 case HM_LOAD_HELP_TABLE: … … 1154 1147 NHM32LoadHelpTable( pHelpInstance -> FHandle, 1155 1148 SHORT1FROMMP( mp1 ), 1156 (HMODULE) mp2 ); 1149 (HMODULE) mp2 ); 1157 1150 break; 1158 1151 … … 1170 1163 PostQueuedViewerMessages( pHelpInstance ); 1171 1164 break; 1172 1165 1173 1166 case NHM_FORGET_VIEWER: 1174 1167 // viewer notifying us it is now doing something else … … 1177 1170 pHelpInstance -> FViewerStarted = FALSE; 1178 1171 pHelpInstance -> FViewerWindow = NULLHANDLE; 1179 break; 1172 break; 1180 1173 1181 1174 /* 1182 // This is worse han useless because View.exe 1183 is just the stub and will always exit immediately. 1184 case WM_APPTERMINATENOTIFY: 1175 // This is worse han useless because View.exe 1176 is just the stub and will always exit immediately. 1177 case WM_APPTERMINATENOTIFY: 1185 1178 // viewer has stopped 1186 1179 LogEvent( "Viewer has stopped" ); … … 1200 1193 LogEvent( " Ignoring unsupported: HM_REPLACE_USING_HELP" ); 1201 1194 break; 1202 1195 1203 1196 case HM_SET_OBJCOM_WINDOW: 1204 1197 LogEvent( " Ignoring unsupported: HM_SET_OBJCOM_WINDOW" ); … … 1237 1230 break; 1238 1231 1239 default: 1240 LogEvent( " Unrecognised Message: %x", msg ); 1232 default: 1233 LogEvent( " Unrecognised Message: %x", msg ); 1241 1234 } 1242 1235 … … 1255 1248 if ( pHelpInstance != NULL ) 1256 1249 { 1257 LogEvent( " %8x (handle: %8x) active, destroying", 1250 LogEvent( " %8x (handle: %8x) active, destroying", 1258 1251 pHelpInstance, 1259 1252 pHelpInstance -> FHandle ); … … 1272 1265 LogEvent( "--------------------------------------------------" ); 1273 1266 1274 GetApplicationFilename( ApplicationFilename, 1267 GetApplicationFilename( ApplicationFilename, 1275 1268 sizeof( ApplicationFilename ) ); 1276 1269 … … 1289 1282 LogEvent( "--------------------------------------------------" ); 1290 1283 1291 GetApplicationFilename( ApplicationFilename, 1284 GetApplicationFilename( ApplicationFilename, 1292 1285 sizeof( ApplicationFilename ) ); 1293 1286 … … 1303 1296 // Tested - still required on Watcom 11.0c, OW 1.0, 1.1, 1.2rc3 1304 1297 // NOTE! This function DOES NOT get called 1305 unsigned LibMain( unsigned hmod, unsigned termination ) 1298 unsigned LibMain( unsigned hmod, unsigned termination ) 1306 1299 { 1307 1300 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.