ValNear




Declare Function Winhelp Lib% "User" (ByVal hWnd%, _
ByVal lpHelpFile$, ByVal wCommand%, ByVal dwData As Any)

Global Const HELP_CONTEXT = &H1
Global Const HELP_QUIT = &H2
Global Const HELP_INDEX = &H3
Global Const HELP_CONTENTS = &H3
Global Const HELP_HELPONHELP = &H4
Global Const HELP_SETINDEX = &H5
Global Const HELP_SETCONTENTS = &H5
Global Const HELP_CONTEXTPOPUP = &H8
Global Const HELP_FORCEFILE = &H9
Global Const HELP_KEY = &H101
Global Const HELP_COMMAND = &H102
Global Const HELP_PARTIALKEY = &H105

' Displaying the Help file Contents topic:

' In the appropriate event, add this code:

Dim R As Integer

' Change the 1st param to your form name and the 2nd param

' to your Help file name.

R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_CONTENTS, CLng(0))

' Displaying the Help - Search dialog:

' In the appropriate event, add this code:

Dim R As Integer

' Change the 1st param to your form name and the 2nd param

' to your Help file name.

R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_PARTIALKEY, "")

' Displaying WinHelp's "How to Use Help" topic:

' In the appropriate event, add this code:

Dim R As Integer

' Change the 1st param to your form name

R = Winhelp(Form1.hWnd, "", HELP_HELPONHELP, CLng(0))
' Displaying the Help via a HelpContextID:

' In the appropriate event, add this code:


Dim R As Integer
' Change the 1st param to your form name, the 2nd param

' to your Help file name and the last param to topic's Context ID.


R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_CONTEXT, CLng(34))
' Displaying the Help via a Help - Keyword:

' Display a topic based on a predefined Keyword (last param)

' for that topic. Keywords are the ones that appear in the Search

' dialog box.

' In the appropriate event, add this code:


Dim R As Integer
' Change the 1st param to your form name, the 2nd param

' to your Help file name and the last param to actual Keyword.


R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_KEY, "Calculator")
' Displaying a Help topic in a Popup window: ( *Really neat!* )

' Works well in the control's MouseDown event (Right button)

' In the appropriate event, add this code:


Dim R As Integer
' *** Special Note: ***

' *** Be aware that if the user attempts to choose another ***

' jump, popup or hot spot, that is displayed on the

' Popup window, that Winhelp will GPF!!!

' This should only be used to display topics that

' have none of these.

' Change the 1st param to your form name, the 2nd param

' to your Help file name and the last param to topic's Context ID.


R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", _
HELP_CONTEXTPOPUP,CLng(14))
' Changing a Help file's "Contents" topic at runtime:

' In the event that you may have one Help file for a number

' of applications, you may want to change the Help file's

' Contents topic at run time. This can be done only while

' the Help file is active (open).

' In the appropriate event, add this code:


Dim R As Integer
' Change the 1st param to your form name, the 2nd param

' to your Help file name and the last param to topic's Context ID.


R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", _
HELP_SETCONTENTS,ByVal CLng(61))
' When the user selects the "Contents" button, the new Contents

' topic is displayed. Once the Help file is closed, it reverts back

' to the original Contents topic.

' Changing the window size of the Help file:

' In the event you do not wish the Help file to completely

' cover your app, you may want alter the size of the Help

' file window.

' Add this Type and API to a .Bas module:


Type HELPWININFO
'12 bytes + length of rgchMember

wStructSize As Integer
x As Integer
y As Integer
dx As Integer
dy As Integer
wMax As Integer
rgchMember As String * 2
'Length varies depending on the window name

End Type

Global Const HELP_SETWINPOS = &H203
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Global Const SW_SHOWNOACTIVE = 4
Global Const SW_SHOW = 5
Global Const SW_MINIMIZE = 6
Global Const SW_SHOWMINNOACTIVE = 7
Global Const SW_SHOWNA = 8
Global Const SW_RESTORE = 9

' Declare the WinHelpType API:

Declare Function WinHelpType Lib "User" Alias "WinHelp" _
(ByVal hWnd As Integer, ByVal lpHelpFile As String, _
ByVal wCommand As Integer, dwData As Any) As Integer
' Remember, the co-ordinates for WinHelp are

' based on 1024 by 1024 grid, no matter what

' resolution is being used.

' In the appropriate event, add this code:


Dim R As Integer
Dim NewPos As HELPWININFO

NewPos.wStructSize = 12
NewPos.x = 0 ' Left
NewPos.y = 0 ' Top
NewPos.dx = 700 ' Height
NewPos.dy = 810 ' Width
NewPos.wMax = SW_SHOWNORMAL
NewPos.rgchMember = ""

' Call the Help file at the Contents topic:

' Change the 1st param to your form name and the 2nd param

' to your Help file name.

R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_CONTENTS, CLng(0))

' Now, position to the defined co-ordinates

'** May not always produce the best results **

' as some paragraphs may not word wrap.

' Change the 1st param to your form name and the 2nd param

' to your Help file name.

R = WinHelpType(Form1.hWnd, App.Path & "\MYHELP.HLP", _
HELP_SETWINPOS,NewPos)
' Closing a Help that was left open by the user:

' To make sure the Help file gets closed when the

' application gets closed, use the code below:


Sub Form_Unload (Cancel As Integer)
' Close the help file, if open still open

Dim R As Integer
' Change the 1st param to your form name and the 2nd param

' to your Help file name.

' If the Help file is not open, no error occurs.

R = Winhelp(Form1.hWnd, App.Path & "\MYHELP.HLP", HELP_QUIT, CLng(0))
End Sub











( valnear.html )- by Paolo Puglisi - Modifica del 17/12/2023