WinHelpの位置・サイズ指定          <TOP>


WinHelpの表示位置とサイズを指定します。

WinHelp WinHelpを呼び出す

 

例では、表示位置X,Y(左上)と幅、高さを指定してWinHelpを開きます。

 

'================================================================
'= WinHelpの位置・サイズ指定
'=    (WinHelp2.bas)
'================================================================
#include "Windows.bi"

Type INFOWINHELP
    lStructurSize As Long
    lPosX As Long
    lPosY As Long
    lWidthX As Long
    lHeightY As Long
    lMaximum As Long
    sWinName As String * 2
End Type

' ヘルプファイルを呼び出す
Declare Function Api_WinHelp& Lib "user32" Alias "WinHelpA" (ByVal hWnd&, ByVal lpHelpFile$, ByVal wCommand&, dwData As Any)

#define HELP_CONTEXT &H1          '特定ページ
#define HELP_QUIT &H2             'ファイルを閉じる
#define HELP_INDEX &H3            '目次ページ
#define HELP_HELPONHELP &H4       'ヘルプ使い方
#define HELP_SETINDEX &H5         'カレントインデックス
#define HELP_FINDER &HB           '目次ページ
#define HELP_KEY &H101            'キーワードに一致したヘルプを表示
#define HELP_PARTIALKEY &H105     '目次トピック呼出
#define HELP_SETWINPOS &H203

Var Shared HelpFileName As String

Var Shared Edit(3) As Object
Var Shared Text(3) As Object
Var Shared Button(1) As Object

For i = 0 To 3
    If i < 2 Then
        Button(i).Attach GetDlgItem("Button" & Trim$(Str$(i + 1))) : Button(i).SetFontSize 14
    End If
    Edit(i).Attach GetDlgItem("Edit" & Trim$(Str$(i + 1))) : Edit(i).SetFontSize 14
    Text(i).Attach GetDlgItem("Text" & Trim$(Str$(i + 1))) : Text(i).SetFontSize 14
Next

'================================================================
'=
'================================================================
Declare Sub ShowHelp(ByVal hWnd As Long, HelpFile As String, x As Long, y As Long, xWidth As Long, yHeight As Long)
Sub ShowHelp(ByVal hWnd As Long, HelpFile As String, x As Long, y As Long, xWidth As Long, yHeight As Long)
    Var tpWinHelp As INFOWINHELP
    Var Ret As Long

    HelpFile = HelpFileName

    tpWinHelp.lStructurSize = Len(tpWinHelp)
    tpWinHelp.lPosX = x             'x軸
    tpWinHelp.lPosY = y             'y軸
    tpWinHelp.lWidthX = xWidth      '幅
    tpWinHelp.lHeightY = yHeight    '高さ
    tpWinHelp.lMaximum = 1

    Ret = Api_WinHelp(hWnd, HelpFile, HELP_SETWINPOS, tpWinHelp)
End Sub

'================================================================
'=
'================================================================
Declare Sub HelpClose edecl ()
Sub HelpClose()
    Var Ret As Long

    Ret = Api_WinHelp(GethWnd, HelpFileName, HELP_QUIT, ByVal 0)
End Sub

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var x As Long
    Var y As Long
    Var w As Long
    Var h As Long

    x = Val(Edit(0).GetWindowText)
    y = Val(Edit(1).GetWindowText)
    w = Val(Edit(2).GetWindowText)
    h = Val(Edit(3).GetWindowText)

    ShowHelp GethWnd, "", x, y, w, h
End Sub

'================================================================
'=
'================================================================
Declare Sub Button2_on edecl ()
Sub Button2_on()
    HelpClose
End Sub

'================================================================
'=
'================================================================
Declare Sub MainForm_QueryClose(Cancel%, Mode%)
Sub MainForm_QueryClose(Cancel%, Mode%)
    HelpClose
    End
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End