Changeset 365 for trunk/hlpmgr


Ignore:
Timestamp:
Feb 5, 2010, 8:58:28 PM (16 years ago)
Author:
RBRi
Message:

format updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hlpmgr/helpmgr.c

    r26 r365  
    11// Standard library
    2 #include <string.h> 
    3 #include <stdlib.h> 
     2#include <string.h>
     3#include <stdlib.h>
    44#include <stdio.h>
    55
     
    6161int g_HelpInstanceCount = 0;
    6262
    63 // 
    64 
    65 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 
    66                                      ULONG msg, 
    67                                      MPARAM mp1, 
     63//
     64
     65MRESULT APIENTRY HelpManagerWndProc( HWND hwnd,
     66                                     ULONG msg,
     67                                     MPARAM mp1,
    6868                                     MPARAM mp2 );
    6969
     
    7575
    7676
    77 // Find if there is a help instance associated with 
     77// Find if there is a help instance associated with
    7878// this window
    7979//--------------------------------------------------------------------------------
     
    8585  LogEvent( "  GetAssociatedHelpInstance" );
    8686
    87   for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 
     87  for ( i = 0; i < MAX_HELP_INSTANCES; i ++ )
    8888  {
    8989    pHelpInstance = g_pHelpInstances[ i ];
     
    9191    {
    9292      LogEvent( "    Instance %d: %8x", i, pHelpInstance );
    93       if ( IsWindowAssociated( pHelpInstance, 
     93      if ( IsWindowAssociated( pHelpInstance,
    9494                               hwnd ) )
    9595      {
     
    9999    }
    100100  }
    101  
     101
    102102  return NULL;
    103103}
     
    112112  HWND hwnd;
    113113  HWND hClientWnd;
    114   TPHelpInstance pHelpInstance; 
     114  TPHelpInstance pHelpInstance;
    115115  LONG SearchType;
    116116
    117117  LogEvent( "QueryHelpInstance" );
    118118
    119   hDesktopWindow = WinQueryDesktopWindow( WinQueryAnchorBlock( hwndApp ), 
     119  hDesktopWindow = WinQueryDesktopWindow( WinQueryAnchorBlock( hwndApp ),
    120120                                          NULLHANDLE );
    121121
     
    145145          LogEvent( "        Found help instance: %8x", pHelpInstance );
    146146          return pHelpInstance;
    147         }     
     147        }
    148148      }
    149149      else
     
    152152      }
    153153    }
    154      
     154
    155155    LogEvent( "  No help instance" );
    156156
     
    180180    }
    181181    hwnd = parentOrOwner;
    182   } 
     182  }
    183183
    184184  LogEvent( "  No help instance found" );
     
    203203  LogEvent( "--------------------------------------------------" );
    204204  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 );
    212208
    213209  pHelpInstance = MakeNewHelpInstance();
     
    215211  // find blank slot in help instance array
    216212  FoundUnusedSlot = FALSE;
    217   for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 
     213  for ( i = 0; i < MAX_HELP_INSTANCES; i ++ )
    218214  {
    219215    if ( g_pHelpInstances[ i ] == NULL )
     
    226222  if ( ! FoundUnusedSlot )
    227223  {
    228     LogEvent( "Too many help instances, out of slots" );   
     224    LogEvent( "Too many help instances, out of slots" );
    229225    return NULLHANDLE;
    230226  }
    231      
     227
    232228  g_HelpInstanceCount ++;
    233229
     
    242238  {
    243239    rc = WinGetLastError( hab );
    244     LogEvent( "WinRegisterClass failed, error=%d", rc );   
     240    LogEvent( "WinRegisterClass failed, error=%d", rc );
    245241    return NULLHANDLE;
    246242  }
     
    249245
    250246  // Create help window as an object window (child of HWND_OBJECT)
    251   pHelpInstance -> FHandle = 
     247  pHelpInstance -> FHandle =
    252248    WinCreateWindow( HWND_OBJECT,           // parent: object window
    253249                     szNewHelpManagerClass, // window class
     
    260256                     NULL,                  // control data - none
    261257                     NULL );                // presentation parameters - none
    262  
     258
    263259  if ( pHelpInstance -> FHandle == NULLHANDLE )
    264260  {
     
    271267  // store instance pointer and magic number for checking later.
    272268  // Could just have used class name!
    273   WinSetWindowULong( pHelpInstance -> FHandle, 
     269  WinSetWindowULong( pHelpInstance -> FHandle,
    274270                     QWL_HELPINSTANCEMAGICNUMBER,
    275271                     HELPINSTANCEMAGICNUMBER );
    276   WinSetWindowULong( pHelpInstance -> FHandle, 
     272  WinSetWindowULong( pHelpInstance -> FHandle,
    277273                     QWL_HELPINSTANCEPTR,
    278274                     (ULONG) pHelpInstance );
     
    308304  pHelpInstance -> HelpTableFromResource = FALSE;
    309305
    310   if ( HelpTable != 0 ) 
     306  if ( HelpTable != 0 )
    311307  {
    312308    if ( ( HelpTable & 0xffff0000 ) == 0xffff0000 )
     
    329325  else
    330326  {
    331     pHelpInstance -> pHelpTable = NULL;   
     327    pHelpInstance -> pHelpTable = NULL;
    332328  }
    333329
     
    336332  pHelpInstance -> FViewerStartupMessagesCount = 0;
    337333
    338   LogEvent( "  Allocating shared memory: %s",
    339             SHARED_MEM_NAME );
     334  LogEvent( "  Allocating shared memory: %s", SHARED_MEM_NAME );
    340335  rc = GetSubAllocatedSharedMemory( SHARED_MEM_NAME,
    341336                                    SHARED_MEM_SIZE,
     
    347342    return NULLHANDLE;
    348343  }
    349   pSharedStruct = 
     344  pSharedStruct =
    350345    (TNewHelpMgrSharedStruct*) pHelpInstance -> SharedMemory.FMem.FPointer;
    351346
    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 );
    356349
    357350  phinitHMInitStructure -> ulReturnCode = 0;
     
    381374
    382375  // remove from list
    383   for ( i = 0; i < MAX_HELP_INSTANCES; i ++ ) 
     376  for ( i = 0; i < MAX_HELP_INSTANCES; i ++ )
    384377    if ( g_pHelpInstances[ i ] == pHelpInstance )
    385378      g_pHelpInstances[ i ] = NULL;
     
    443436
    444437  // 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,
    448441              0 );
    449442  // Note this call seems to fail on some apps, so ignore result
     
    454447    LogEvent( "  Help Instance NULLHANDLE, clearing" );
    455448
    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,
    462455                                hwndApp );
    463456      }
     
    471464  else
    472465    LogEvent( "  Window Title: Blank/invalid" );
    473    
     466
    474467  pHelpInstance = GetHelpInstance( hwndHelpInstance );
    475468  if ( pHelpInstance == NULL )
     
    546539// Portions contributed by Aaron Reed at IBM
    547540
    548 // typedef void _Far16 * HWND16; 
     541// typedef void _Far16 * HWND16;
    549542typedef HWND HWND16;
    550543typedef USHORT BOOL16;
     
    562555    PHELPSUBTABLE phstHelpSubTable;
    563556    USHORT        idExtPanel;
    564  
     557
    565558} HELPTABLE16, _Far16 *PHELPTABLE16;
    566559
     
    578571    USHORT       usShowPanelId;
    579572    PSZ16        pszHelpLibraryName;
    580  
     573
    581574} HELPINIT16, _Far16 *PHELPINIT16;
    582575
     
    608601  HelpTable = (ULONG) phinitHMInitStructure -> phtHelpTable;
    609602  LogEvent( "    Help Table: %8x", HelpTable );
    610   if ( HelpTable ) 
     603  if ( HelpTable )
    611604  {
    612605    if ( ( HelpTable & 0xffff0000 ) == 0xffff0000 )
     
    620613      // It's a pointer, so convert 16->32
    621614      LogEvent( "    Converting pointer" );
    622       helpinit.phtHelpTable = 
     615      helpinit.phtHelpTable =
    623616        (PHELPTABLE) (PHELPTABLE16) HelpTable;
    624617    }
    625618  }
    626619
    627   helpinit.hmodHelpTableModule = 
     620  helpinit.hmodHelpTableModule =
    628621    (HMODULE) phinitHMInitStructure -> hmodHelpTableModule;
    629   helpinit.pszHelpWindowTitle = 
     622  helpinit.pszHelpWindowTitle =
    630623    (PSZ) phinitHMInitStructure -> pszHelpWindowTitle;
    631   helpinit.pszHelpLibraryName = 
     624  helpinit.pszHelpLibraryName =
    632625    (PSZ) phinitHMInitStructure -> pszHelpLibraryName;
    633    
     626
    634627  LogEvent( "  Conversions done, calling 32 bit" );
    635628
    636629  hInstance = NHM32CreateHelpInstance( hab, &helpinit );
    637  
     630
    638631  LogEvent( "  32 bit returned, copying result code" );
    639632
     
    663656{
    664657  LogEvent( "NHM16AssociateHelpInstance" );
    665   return NHM32AssociateHelpInstance( (HWND) hwndHelpInstance, 
     658  return NHM32AssociateHelpInstance( (HWND) hwndHelpInstance,
    666659                                     (HWND) hwndApp );
    667660}
     
    755748
    756749  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)
    759752    if ( FindIDInHelpSubTable( ChildControlID,
    760753                               pHelpSubTable,
    761754                               pHelpPanelID ) )
    762755    {
    763       LogEvent( "  Found Child Control ID, Panel: %hu", 
     756      LogEvent( "  Found Child Control ID, Panel: %hu",
    764757                *pHelpPanelID );
    765758      return TRUE;
     
    777770                             pHelpSubTable,
    778771                             pHelpPanelID ) )
    779   { 
    780     LogEvent( "  Found Control ID, Panel: %hu", 
     772  {
     773    LogEvent( "  Found Control ID, Panel: %hu",
    781774              *pHelpPanelID );
    782775    return TRUE;
     
    785778  LogEvent( "  Control ID not found" );
    786779
    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
    790783  if ( FindIDInHelpSubTable( WindowID,
    791784                             pHelpSubTable,
    792785                             pHelpPanelID ) )
    793786  {
    794     LogEvent( "  Found Window ID in subtable, Panel: %hu", 
     787    LogEvent( "  Found Window ID in subtable, Panel: %hu",
    795788              *pHelpPanelID );
    796789    return TRUE;
     
    808801//--------------------------------------------------------------------------------
    809802// Help Hook function
    810 // 
     803//
    811804// installed during WinCreateHelpInstance
    812805//
    813 // This function is called by the standard OS/2 windows on 
     806// This function is called by the standard OS/2 windows on
    814807// WM_HELP messages.
    815 // 
     808//
    816809// Notes:
    817810//   The parameters are ULONG but passed from USHORTs
     
    833826  USHORT ChildControlID;
    834827  USHORT Mode;
    835  
     828
    836829  ControlID = (USHORT) ulControlID;
    837830  ChildControlID = (USHORT) ulChildControlID;
    838831  Mode = (USHORT) ulMode;
    839  
     832
    840833  LogEvent( "--------------------------------------------------" );
    841834  LogEvent( "HelpHook" );
     
    852845
    853846  pHelpInstance = GetHelpInstanceForWindowChain( hFocusWindow );
    854  
     847
    855848  if ( pHelpInstance == NULL )
    856849  {
     
    867860  switch( Mode )
    868861  {
    869     case HLPM_MENU:   
     862    case HLPM_MENU:
    870863      LogEvent( "  Menu Mode" );
    871       LogEvent( "  Frame: %x", hFocusFrame );           
     864      LogEvent( "  Frame: %x", hFocusFrame );
    872865      break;
    873866
     
    883876      {
    884877        // override if active window set.
    885         WindowID = WinQueryWindowUShort( pHelpInstance -> FActiveWindow, 
     878        WindowID = WinQueryWindowUShort( pHelpInstance -> FActiveWindow,
    886879                                         QWS_ID );
    887880        LogEvent( "    Active window set; overriding, Window ID: %d", WindowID );
     
    895888  LogEvent( "  Child Control ID: %hu", (USHORT) ChildControlID );
    896889
    897   if ( pHelpInstance -> pHelpTable == NULL ) 
     890  if ( pHelpInstance -> pHelpTable == NULL )
    898891  {
    899892    LogEvent( "  No Help Table loaded for instance" );
     
    902895
    903896  if ( ! FindHelpTopic( pHelpInstance,
    904                         WindowID, 
     897                        WindowID,
    905898                        ControlID,
    906899                        ChildControlID,
     
    927920//--------------------------------------------------------------------------------
    928921
    929 MRESULT APIENTRY HelpManagerWndProc( HWND hwnd, 
    930                                      ULONG msg, 
    931                                      MPARAM mp1, 
     922MRESULT APIENTRY HelpManagerWndProc( HWND hwnd,
     923                                     ULONG msg,
     924                                     MPARAM mp1,
    932925                                     MPARAM mp2 )
    933 { 
     926{
    934927  USHORT PanelID;
    935928  char buffer[ 256 ];
     
    945938  char* pMessageMem;
    946939  HWND hAppWindow;
    947  
     940
    948941  if (    msg == WM_CREATE
    949942       || msg == WM_DESTROY
     
    952945    return 0;
    953946
    954   if (    msg >= WM_USER 
     947  if (    msg >= WM_USER
    955948       && msg != NHM_VIEWER_READY
    956949       && msg != NHM_FORGET_VIEWER )
     
    963956
    964957  pHelpInstance = GetHelpInstance( hwnd );
    965   if ( pHelpInstance == NULL ) 
     958  if ( pHelpInstance == NULL )
    966959  {
    967960    LogEvent( "  Not a valid help manager window" );
     
    980973  LogEvent( "  Message:      %8x", msg );
    981974  LogEvent( "  App Window:   %8x", (ULONG) hAppWindow );
    982  
     975
    983976  switch( msg )
    984977  {
    985     case HM_HELP_CONTENTS: 
     978    case HM_HELP_CONTENTS:
    986979      LogEvent( "HM_HELP_CONTENTS" );
    987980      EnsureViewerRunning( pHelpInstance );
    988       PostViewerMessage( pHelpInstance, 
    989                          NHM_HELP_CONTENTS, 
    990                          0, 
     981      PostViewerMessage( pHelpInstance,
     982                         NHM_HELP_CONTENTS,
     983                         0,
    991984                         0 );
    992985      break;
    993986
    994     case HM_HELP_INDEX: 
     987    case HM_HELP_INDEX:
    995988      LogEvent( "HM_HELP_INDEX" );
    996989      EnsureViewerRunning( pHelpInstance );
    997990      PostViewerMessage( pHelpInstance,
    998                          NHM_HELP_INDEX, 
    999                          0, 
     991                         NHM_HELP_INDEX,
     992                         0,
    1000993                         0 );
    1001994      break;
    1002995
    1003     case HM_DISPLAY_HELP: 
     996    case HM_DISPLAY_HELP:
    1004997      LogEvent( "  HM_DISPLAY_HELP" );
    1005998      switch( (ULONG) mp2 )
     
    10411034                             (MPARAM) pMessageMem,
    10421035                             0 );
    1043          
     1036
    10441037          break;
    10451038      }
     
    10531046      // find active window
    10541047      hFrameWindow = GetTopLevelWindow( WinQueryFocus( HWND_DESKTOP ) );
    1055      
     1048
    10561049      // get ID
    10571050      WindowID = WinQueryWindowUShort( hFrameWindow, QWS_ID );
     
    10731066      break;
    10741067
    1075     case HM_KEYS_HELP: 
     1068    case HM_KEYS_HELP:
    10761069      LogEvent( "HM_KEYS_HELP" );
    10771070      if ( hAppWindow == NULLHANDLE )
     
    10791072        LogEvent( "  No app windows; can't ask for keys help topic" );
    10801073        return 0;
    1081       }       
    1082       PanelID = 
     1074      }
     1075      PanelID =
    10831076        (USHORT) WinSendMsg( hAppWindow,
    10841077                             HM_QUERY_KEYS_HELP,
     
    10941087                           0 );
    10951088      }
    1096                          
    1097       break;
    1098    
     1089
     1090      break;
     1091
    10991092    case HM_DISMISS_WINDOW:
    11001093      LogEvent( "HM_DISMISS_WINDOW" );
     
    11171110      LogEvent( "  Filename(s): %s", (char*) mp1 );
    11181111      StoreString( & pHelpInstance -> FHelpFileNames,
    1119                    (char*) mp1 ); 
     1112                   (char*) mp1 );
    11201113      if ( pHelpInstance -> FViewerStarted )
    11211114      {
     
    11481141                           0 );
    11491142      }
    1150       break;   
     1143      break;
    11511144
    11521145    case HM_LOAD_HELP_TABLE:
     
    11541147      NHM32LoadHelpTable( pHelpInstance -> FHandle,
    11551148                          SHORT1FROMMP( mp1 ),
    1156                           (HMODULE) mp2 ); 
     1149                          (HMODULE) mp2 );
    11571150      break;
    11581151
     
    11701163      PostQueuedViewerMessages( pHelpInstance );
    11711164      break;
    1172    
     1165
    11731166    case NHM_FORGET_VIEWER:
    11741167      // viewer notifying us it is now doing something else
     
    11771170      pHelpInstance -> FViewerStarted = FALSE;
    11781171      pHelpInstance -> FViewerWindow = NULLHANDLE;
    1179       break;     
     1172      break;
    11801173
    11811174/*
    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:
    11851178      // viewer has stopped
    11861179      LogEvent( "Viewer has stopped" );
     
    12001193      LogEvent( "  Ignoring unsupported: HM_REPLACE_USING_HELP" );
    12011194      break;
    1202        
     1195
    12031196    case HM_SET_OBJCOM_WINDOW:
    12041197      LogEvent( "  Ignoring unsupported: HM_SET_OBJCOM_WINDOW" );
     
    12371230      break;
    12381231
    1239     default: 
    1240       LogEvent( "  Unrecognised Message: %x", msg );   
     1232    default:
     1233      LogEvent( "  Unrecognised Message: %x", msg );
    12411234  }
    12421235
     
    12551248    if ( pHelpInstance != NULL )
    12561249    {
    1257       LogEvent( "    %8x (handle: %8x) active, destroying", 
     1250      LogEvent( "    %8x (handle: %8x) active, destroying",
    12581251                pHelpInstance,
    12591252                pHelpInstance -> FHandle );
     
    12721265  LogEvent( "--------------------------------------------------" );
    12731266
    1274   GetApplicationFilename( ApplicationFilename, 
     1267  GetApplicationFilename( ApplicationFilename,
    12751268                          sizeof( ApplicationFilename ) );
    12761269
     
    12891282  LogEvent( "--------------------------------------------------" );
    12901283
    1291   GetApplicationFilename( ApplicationFilename, 
     1284  GetApplicationFilename( ApplicationFilename,
    12921285                          sizeof( ApplicationFilename ) );
    12931286
     
    13031296// Tested - still required on Watcom 11.0c, OW 1.0, 1.1, 1.2rc3
    13041297// NOTE! This function DOES NOT get called
    1305 unsigned LibMain( unsigned hmod, unsigned termination ) 
     1298unsigned LibMain( unsigned hmod, unsigned termination )
    13061299{
    13071300  return 1;
Note: See TracChangeset for help on using the changeset viewer.