In VC6.0, if I push Button1, Button2 will be run 500 times automatically, just like I push Button1, and then I push Button2 500 times.怎么实现?

解决方案 »

  1.   

    In VC6.0, if I push Button1,(but I do not push Button2), Button2 will be run 500 times automatically, just like I push Button1, and then I push Button2 500 times.怎么实现?
      

  2.   

    onclick_Button1:for (int i=0; i<500; i++)
     SendMessage( hButton2, BN_CLICKED, 0, 0)
      

  3.   

    1,如果你只要执行OnButton2(),你可以调用OnButton2() 500次啊
    2,另一种方法是:发送Button2被按下的消息,共500次
      

  4.   

    OnClickButton1()
    {
         for (int i=0; i<500; i++)
         SendMessage( ((CButton*) GetDlgItem(IDC_BUTTON2)).GetSafeHwnd(), BN_CLICKED, 0, 0)
    }
      

  5.   

    SDI/MDI
    void CTwobuttonDlg::OnButton1() 
    {
        for (int i=0; i<10; i++)
         SendMessage( ((CButton*) GetDlgItem(IDC_BUTTON2)).GetSafeHwnd(), BN_CLICKED, 0, 0);
    }void CTwobuttonDlg::OnButton2() 
    {
    ......
    }Compiling...
    twobuttonDlg.cpp
    D:\temp\twobutton\twobuttonDlg.cpp(177) : error C2228: left of '.GetSafeHwnd' must have class/struct/union type
    D:\temp\twobutton\twobuttonDlg.cpp(177) : error C2660: 'SendMessageA' : function does not take 4 parameters
    Error executing cl.exe.
    onclick_Button1:for (int i=0; i<500; i++)
     SendMessage( hButton2, BN_CLICKED, 0, 0)
    Compiling...
    twobuttonDlg.cpp
    D:\temp\twobutton\twobuttonDlg.cpp(177) : error C2065: 'hButton2' : undeclared identifier
    Error executing cl.exe.
      

  6.   

    void CTwobuttonDlg::OnButton1() 
    {
        for (int i=0; i<10; i++)
         SendMessage( ((CButton*) GetDlgItem(IDC_BUTTON2)).GetSafeHwnd(), BN_CLICKED, 0, 0);
    }void CTwobuttonDlg::OnButton2() 
    {
    ......
    }
      

  7.   

    void CButtonClickMessageDlg::OnButton1() 
    {
    HWND hWnd=((CButton*)GetDlgItem(IDC_BUTTON2))->GetSafeHwnd();
    for(int i=0;i<10;i++)
    {
    ::SendMessage(hWnd,WM_LBUTTONDOWN,0,0);          ::SendMessage(hWnd,WM_LBUTTONUP,0,0);
    }
    }void CButtonClickMessageDlg::OnButton2() 
    {
        //TRACE("-|");
    }
      

  8.   

    ((CButton*) GetDlgItem(IDC_BUTTON2)).GetSafeHwnd()
    改为((CButton*) GetDlgItem(IDC_BUTTON2) )->GetSafeHwnd()
      

  9.   

    同意zfr(zfr) suping() ( )