Sub MainWnd_CommandButton2_Click() 'クリップボードへ送る
Dim TLSeq As String '文字列バッファー確保
GetDlgItemTextStr(hMainWnd,Static1,TLSeq)'文字列取得
Dim pszCopyText As BytePtr 'メモリアドレス用変数
OpenClipboard(0) 'クリップボード開く
EmptyClipboard() 'クリップボードを空にする
pszCopyText = malloc(Len(TLSeq)+1)'文字列用メモリ確保
lstrcpy(pszCopyText,TLSeq) '文字列を格納
SetClipboardData(CF_TEXT,pszCopyText)'文字を送る
free(pszCopyText) 'メモリを開放
CloseClipboard() 'クリップボードを閉じる
End Sub
'イグトランス氏作の関数
Function GetWindowTextStr(hwnd As HWND, ByRef str As String) As Long
Dim Length As Long
Length = GetWindowTextLength(hwnd)
str = ZeroString(Length)
If Length = 0 Then
GetWindowTextStr = 0
Exit Function
End If
GetWindowTextStr = GetWindowText(hwnd, StrPtr(str), Length + 1)
SetDWord(StrPtr(str) - SizeOf (DWord), GetWindowTextStr)
End Function
Function GetDlgItemTextStr(hDlg As HWND, idDlgItem As Long, ByRef str As String) As Long
GetDlgItemTextStr = GetWindowTextStr(GetDlgItem(hDlg, idDlgItem), str)
End Function
Dim hMem As HGLOBAL
Dim lpStr As BytePtr
hMem=GlobalAlloc(GHND,lstrlen(TLSeq)+1)
If hMem Then
lpStr=GlobalLock(hMem)
If lpStr Then
lstrcpy(lpStr,TLSeq)
GlobalUnlock(hMem)
If OpenClipboard(0) Then
EmptyClipboard()
SetClipboardData(CF_TEXT,hMem)
CloseClipboard()
End If
End If
GlobalFree(hMem)
End If
Sub MainWnd_CommandButton2_Click() 'クリップボードへ送る
Dim TLSeq As String '文字列バッファー確保
GetDlgItemTextStr(hMainWnd,Static1,TLSeq)'文字列取得
Dim hMem As HGLOBAL
Dim lpStr As BytePtr
hMem=GlobalAlloc(GHND,lstrlen(TLSeq)+1)
If hMem Then
lpStr=GlobalLock(hMem)
If lpStr Then
lstrcpy(lpStr,TLSeq)
GlobalUnlock(hMem)
If OpenClipboard(0) Then
EmptyClipboard()
SetClipboardData(CF_TEXT,hMem)
CloseClipboard()
End If
End If
GlobalFree(hMem)
End If
End Sub
'イグトランス氏作の関数
Function GetWindowTextStr(hwnd As HWND, ByRef str As String) As Long
Dim Length As Long
Length = GetWindowTextLength(hwnd)
str = ZeroString(Length)
If Length = 0 Then
GetWindowTextStr = 0
Exit Function
End If
GetWindowTextStr = GetWindowText(hwnd, StrPtr(str), Length + 1)
SetDWord(StrPtr(str) - SizeOf (DWord), GetWindowTextStr)
End Function
Function GetDlgItemTextStr(hDlg As HWND, idDlgItem As Long, ByRef str As String) As Long
GetDlgItemTextStr = GetWindowTextStr(GetDlgItem(hDlg, idDlgItem), str)
End Function
Sub MainWnd_CommandButton1_Click()
hEdit = GetDlgItem(hMainWnd, EditBox1) 'エディットボックスのハンドルを取得
cOneLettSeq = GetWindowTextLength(hEdit) '文字列の長さを取得
'check = GetWindowText(hEdit,OneLettSeq, cOneLettSeq + 1) '文字列を取得
check = GetWindowTextStr(hEdit,OneLettSeq) '文字列をString型のまま取得
ThrLettSeq = ""
If check = 0 Then
MessageBox(0,"文字列を入力してください。","Err",MB_OK)
End If
'sOneLettSeq = MakeStr(OneLettSeq) '型変換BytePtr→String
For i = 1 to cOneLettSeq
'OneText = Mid$(sOneLettSeq,i,1)
OneText = Mid$(OneLettSeq,i,1)
Select Case OneText
Case "A","a"
ThrLettSeq = ThrLettSeq + "Ala"
Case Else
MessageBox(0,"指定のアルファベットを入れてください","Err",MB_OK)
Exit Sub
End Select
Next i
hText = GetDlgItem(hMainWnd,Static1)
SetWindowText(hText,ThrLettSeq)
End Sub