home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / mvhelp / vwr_help.bas < prev    next >
BASIC Source File  |  1994-01-10  |  3KB  |  73 lines

  1. '**************************************************************************
  2. '*  Sample VB code for Context Sensitive Help using Multimedia Viewer...  *
  3. '*          Copyright ⌐ 1994 Robert W. McGregor.  Use Freely.             *
  4. '**************************************************************************
  5.  
  6. ' Yes, Viewer be used to create context sensitive help for VB apps, just
  7. ' like WinHelp can.  While it *is* like WinHelp on steroids, with a lot of
  8. ' the same functionality, Viewer needs more coaxing to get the job done.
  9. ' Without writing a custom DLL this was the simplest way I could think of
  10. ' doing it...
  11.  
  12. ' Instead of the HelpContextID property (which is numerical, and Viewer
  13. ' won't accept a [MAP] section in the MVP file), use the form or control
  14. ' TAG property.  Set the Tag to the context string used in your RTF.
  15. ' Then you can trap the F1 keypress, pass the Tag as a context string to
  16. ' Viewer using the Viewer API, and presto, Context Sensitive Multimedia Help!
  17. '
  18. ' Please note that a VB Form can't get the focus unless all controls are
  19. ' disabled, so I've used a Help button to get help on the form itself.
  20. ' Maybe there's a better way, but this seems pretty straight forward.  If
  21. ' anyone knows of a better (i.e. simpler) way to do this, let me know, eh?
  22. '
  23. ' See-ya!
  24. ' Rob McGregor, Screaming Tiki Software
  25. ' CIS 73122,3125
  26.  
  27. Option Explicit
  28.  
  29. ' Viewer functions...
  30. Declare Function HwndFromVwr% Lib "mvapi2.dll" (ByVal hWnd%)
  31. Declare Function VwrCommand% Lib "mvapi2.dll" (ByVal iVwr%, ByVal szMVB As Any, ByVal szMacro$, ByVal iCmdOptions%)
  32. Declare Function VwrFromMVB% Lib "mvapi2.dll" (ByVal szMVB$)
  33. Declare Function VwrQuit% Lib "mvapi2.dll" (ByVal iVwr%)
  34. Declare Function VwrFromHwnd% Lib "mvapi2.dll" (ByVal hWnd%)
  35. Declare Function VwrFromHinst% Lib "mvapi2.dll" (ByVal hInst%)
  36. Declare Function VwrGetInfo% Lib "mvapi2.dll" (ByVal iVwr%, ByVal iInfoMsg%, ByVal lParam1&, ByVal lParam2&)
  37.  
  38. ' Viewer Defs...
  39. Global Const cmdoptNONE = 0
  40. Global Const cmdoptHIDE = 1
  41. Global szTitle$   ' Path of the Viewer title
  42. Global vwr%       ' Viewer handle
  43. Global hwndVwr%   ' Viewer Hwnd
  44.  
  45. ' F1 function key
  46. Global Const VK_F1 = &H70
  47.  
  48. Sub JumpTopic (sztopic$)
  49.   Dim temp
  50. ' attempt a jump to the topic...
  51.   temp = VwrCommand(vwr, szTitle$, "JumpID(qchPath,`" & sztopic$ & "')", cmdoptNONE)
  52.   If temp = 0 Then Exit Sub
  53. End Sub
  54.  
  55. Sub StartViewer ()
  56.   Dim msg$
  57.  
  58. ' See if Viewer's running.  If not, start it...
  59.   szTitle$ = "VWR_HELP.MVB"
  60.   vwr% = VwrFromMVB(szTitle$)
  61.   If vwr% = 0 Then
  62.   ' Viewer needs a command to get loaded so I use the BrowseButtons() command
  63.   ' with cmdoptHIDE to prevent flashing while JumpTopic brings up a topic...
  64.   vwr% = VwrCommand(0, szTitle$, "BrowseButtons()", cmdoptHIDE)
  65.     If vwr% = 0 Then
  66.       msg = "The file " + szTitle$ + " was not found in your system's PATH."
  67.       MsgBox msg, 48
  68.       Exit Sub
  69.     End If
  70.   End If
  71. End Sub
  72.  
  73.