::FindWindow出错,新手
我的是vs2008我新建了一个mfc应用程序,基于对话框的,
在一个button里写下如下代码:(是网上抄写的,想测试下,)
void Ctest4Dlg::OnBnClickedOk()
{
HWND hWndId,hWndB1;
hWndId = ::FindWindow(NULL,_T("计算器"));本来这句也有错,但是我加了_T就没有了
if (hWndId!=0)
{
hWndB1=::FindWindowEx(hWndId,0,"Button","7");
if (hWndB1!=0 )
{
::PostMessage(hWndB1,WM_LBUTTONDOWN,0,0);
::PostMessage(hWndB1,WM_LBUTTONUP,0,0);
}
hWndB1=::FindWindowEx(hWndId,0,"Button","1");
if (hWndB1!=0 )
{
::PostMessage(hWndB1,WM_LBUTTONDOWN,0,0);
::PostMessage(hWndB1,WM_LBUTTONUP,0,0);
}
hWndB1=::FindWindowEx(hWndId,0,"Button","9");
if (hWndB1!=0 )
{
::PostMessage(hWndB1,WM_LBUTTONDOWN,0,0);
::PostMessage(hWndB1,WM_LBUTTONUP,0,0);
}
}
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
错误提示:
错误 1 error C2664: “FindWindowExW”: 不能将参数 3 从“const char [7]”转换为“LPCWSTR” d:\My Documents\Visual Studio 2008\Projects\test4\test4\test4Dlg.cpp 163 test4
错误 2 error C2664: “FindWindowExW”: 不能将参数 3 从“const char [7]”转换为“LPCWSTR” d:\My Documents\Visual Studio 2008\Projects\test4\test4\test4Dlg.cpp 169 test4
错误 3 error C2664: “FindWindowExW”: 不能将参数 3 从“const char [7]”转换为“LPCWSTR” d:\My Documents\Visual Studio 2008\Projects\test4\test4\test4Dlg.cpp 175 test4