ウィンドウのキャプションサイズを取得
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _
(ByVal hWnd As Long) As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" _
(ByVal hWnd As Integer) As Integer
int GetWindowTextLength(
HWND hWnd
);
引数
hWnd
ウィンドウのハンドル戻り値
正常終了のとき キャプションのバイト数備考
エラーのとき 0
キャプションのバイト数が不明のときサンプル
GetWindowText()関数を実行する前に実行すると有用。
ダウンロード(GetWindowText.lzh 1.61KB)
Private Sub Timer1_Timer() Dim Pos As PointApi, hWnd As Long Dim Temp As String, cch As Long 'マウスの位置を取得 Call GetCursorPos(Pos) 'ウィンドウのハンドルを取得 hWnd = WindowFromPoint(Pos.X, Pos.Y) cch = GetWindowTextLength(hWnd) cch = cch * 2 'バッファの作成 Temp = String(cch, Chr(0)) 'ウィンドウのキャプション取得 Call GetWindowText(hWnd, Temp, Len(Temp)) Me.Text1.Text = MidB(Temp, 1, cch) End Sub