VC关于获得窗体标题的具体做法
来源:百度知道 编辑:UC知道 时间:2024/06/25 08:20:56
谢谢2位 不过我想补充下 当我使用了.
CString str;
HWND pWnd =::GetForegroundWindow();
::GetWindowText(pWnd,(LPTSTR)&str,256);
SetDlgItemText(IDC_ADDRESS,str);
捕捉了窗体标题以后窗体被自动强行关闭 不知道是什么原因 答案满意者我这100分就献上了 谢谢 也感谢2位
CString str;
HWND pWnd =::GetForegroundWindow();
::GetWindowText(pWnd,str.GetBuffer(256),256);
::SetDlgItemText(pWnd,IDC_ADDRESS,str);
----- 试试修改后的 -------
CString wndtext;
HWND pWnd = GetForegroundWindow();
ShowWindow(pWnd, nCmdShow);
UpdateWindow(pWnd);
GetWindowText(pWnd,(LPTSTR)&wndtext,1000);
1000是要COPY的最多字符数,你可以自己指定
上面是VC,VB的例程如下
Dim len As Integer = API.GetWindowTextLength(hWnd)
If len > 0 Then
Dim b As New System.Text.StringBuilder(ChrW(0), len + 1)
Dim ret = API.GetWindowText(hWnd, b, b.Capacity)
If ret <> 0
Then
Return b.ToString Else
Throw New API.Win32APIException End If Else
Dim ex As New API.Win32APIException
If ex.Nat