我要通过一个A程序控制另一个B程序,在B程序的界面上有一堆Static,全部用来做图片按钮操作,我现在的目的是要点击其中的一个按钮,里面的Static比较多,怎么能找到我想要的那个Static的句柄?如果找到了,怎么模拟鼠标点击?请大家详细一些,本人刚接触VC

解决方案 »

  1.   

    首先Static的默认id(IDC_STATIC)必须要改,随便改,可以改为IDC_STATIC1什么的,否则找不到。
    找到以后可以通过发消息来模拟。
    GetDlgItem(IDC_STATIC1)->SendMessage(WM_LBUTTONDOWN,0,0);
    注意后两个参数最好是你先用spy++捕捉一下,看看点上去是什么,然后照搬过来,不一定是0。
      

  2.   

    The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. HWND FindWindow( 
    LPCTSTR lpClassName, 
    LPCTSTR lpWindowName );The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search. SyntaxHWND FindWindowEx(          HWND hwndParent,
        HWND hwndChildAfter,
        LPCTSTR lpszClass,
        LPCTSTR lpszWindow
    );
      

  3.   

    GetDlgITem(ID);ID 为你想要的对话框的ID;这个函数就是返回静态框的句柄;