LOTUSSCRIPT 言語


例:%If 命令
この例では、Windows 3.1、Windows NT、または Windows 95 上でコンパイルして実行します。アプリケーションをコンパイルして実行するのが 16 ビット対応の Windows (Windows 3.1) 上か、32 ビット対応の Windows (Windows 95/98 または Windows NT) 上かによって、適切な Windows ハンドル変数と、2 つの Windows API 関数の適切なバージョンを宣言して使用する必要があります。

GetActiveWindow は、現在アクティブになっているウィンドウのハンドル (16 ビット対応の Windows では Integer 型、32 ビット Windows では Long 型) を返します。GetWindowText は、ウィンドウのタイトルバーのテキストを返します。

Dim winTitle As String * 80
%If WIN16                      ' 16-bit Windows
  Dim activeWin As Integer    ' Window handles are Integer.
  Declare Function GetActiveWindow% Lib "User" ()
  Declare Function GetWindowText% Lib "User" _
        (ByVal hWnd%, ByVal lpstr$, ByVal i%)
%ElseIf WIN32                  ' 32-bit Windows
  Dim activeWin As Long       ' Window handles are Long.
  Declare Function GetActiveWindow& Lib "User32" ()
  Declare Function GetWindowText% Lib "User32" _
         Alias "GetWindowTextA" _
     (ByVal hWnd&, ByVal lpstr$, ByVal i&)
%End If

' Print the name of the currently active window.
activeWin = GetActiveWindow()  ' Returns an Integer or a Long.
Call GetWindowText(ActiveWin, winTitle$, 80)
Print winTitle$

関連項目