CWnd* pWnd=GetDesktopWindow();
CWnd *pChildWnd = pWnd->GetWindow(GW_CHILD);
CString strWndTitle ;
CWnd *pPopoTalkWnd = NULL;while ( pChildWnd )
{
    pChildWnd->GetWindowText( strWndTitle);
    if ( strWndTitle.GetLength() )
    {
         int nPos = strWndTitle.ReverseFind('-');
CString strTmp = strWndTitle.Right(nPos);
strTmp = strWndTitle ;
if ( strTmp.Compare("登录POPO2004")==0)
// if ( (nPos>0) && (strTmp.Compare("对话")==0))
{
     pPopoTalkWnd = pChildWnd ;
     {
CWnd *pEditWnd = pPopoTalkWnd->GetWindow(GW_CHILD);
while ( pEditWnd )
{
    if ( GetWindowLong( pEditWnd->m_hWnd, GWL_STYLE) & ES_PASSWORD )
    {
if ( pEditWnd->IsKindOf( RUNTIME_CLASS( CEdit ) ) )
{
           int x = 0 ;//这句永远也执行不到,好奇怪
}
char szPass[255]; 
pEditWnd->SetWindowText("12345");
// pEditWnd->PostMessage(WM_SETTEXT, 0, (LPARAM)"hello");
CRect rect ;
pEditWnd->GetClientRect(rect);
pPopoTalkWnd->InvalidateRect( &rect, TRUE);
pEditWnd->SendMessage(WM_GETTEXT, 255,(LPARAM)szPass);
                           //szPass为空,奇怪??
     }
     pEditWnd->GetWindowText( strWndTitle);//strWndTitle 为空
     pEditWnd = pEditWnd->GetWindow(GW_HWNDNEXT);
}
     }
}
    }
    pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
}不知道哪里有问题,就是不能想密码框填充密码,另外,泡泡对话是, 跟对方聊天的编辑框,如何得到其内容?

解决方案 »

  1.   

    if ( pEditWnd->IsKindOf( RUNTIME_CLASS( CEdit ) ) )
    {
              int x = 0 ;//这句永远也执行不到,好奇怪,就这么一行,没做什么实际工作,被编译器优化掉了吧。
    }
      

  2.   

    to DentistryDoctor(雅克医生(潜心修内功)) :不会的,我经常在调试中这么写的.用来判断某个条件是否满足
      

  3.   

    定义一个CEdit类型的变量m_ctrEdit;
    m_ctrEdit.SetPasswordChar('*');就可以使编辑框成为密码框了。
    关于得到内容的问题要用到UpdateData(TRUE);语句其内容就保存到编辑框的成员变量重量。
    可以用AfxMessageBox(m_strValue);//m_strValue是编辑框的成员变量
    试试!
      

  4.   

    to adventure007(adventure):
    你没看明白我的程序的目的吧,老兄!我是通过查找窗口访问其他程序的控件,怎么定义变量?