VB Tips Vol.65
ウィンドウのタイトルを変更する
| Option Explicit Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hWnd As Long, _ ByVal lpString As String) As Long Private Sub Command1_Click() Dim wndtaskid As Long ' メモ帳を起動する Shell "Notepad.exe", vbNormalFocus Command1.Enabled = False End Sub Private Sub Command2_Click() Dim wndcname As String Dim wndh As Long Dim ret As Long ' ウィンドウハンドルを取得 wndcname = "Notepad" wndh = FindWindow(wndcname, vbNullString) ' ウィンドウハンドルの取得に成功したら ' ウィンドウのタイトルを変更する If wndh <> 0 Then ret = SetWindowText(wndh, Text1.Text) End If End Sub |
サンプルプログラムのダウンロード(5.09KB)
※このページの内容とサンプルプログラムのコードは多少異なる場合があります。