我想编写一个程序,给其它的应用程序(如IE,Word等)发消息,使我的程序可以控制这些应用程序,使其滚动窗口.急用,请大家帮帮忙,谢谢!

解决方案 »

  1.   

    这个似乎不是界面而是COM的内容阿,去ATL/ActiveX/COM版问吧
      

  2.   

    先得到句柄,再发送消息:
    PostMessage(滚动条窗体或滚动条句柄,WM_HSCROLL/WM_VSCROLL,CSM_PAGEUP/CSM_PAGEDOWN/CSM_LINEUP.....,0);
    /表示选择其一,如果为CSM_SETPOS,这wParam这一项必须为你想要的位置。
    example:
    SendMessage(hWnd, WM_VSCROLL,SB_PAGEDOWN,0);
    参考:
    http://search.csdn.net/Expert/topic/514/514868.xml?temp=1.581973E-02
      

  3.   

    根据得到的窗口句柄,发送WM_VSCROLL,WM_HSCROLLSB_BOTTOM Scrolls to the lower right. 
    SB_ENDSCROLL Ends scroll. 
    SB_LINEDOWN Scrolls one line down. 
    SB_LINEUP Scrolls one line up. 
    SB_PAGEDOWN Scrolls one page down. 
    SB_PAGEUP Scrolls one page up. 
    SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. 
    SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. 
    SB_TOP Scrolls to the upper left. 
      

  4.   

    请看滚动栏消息定义:
    WM_HSCROLL 
    nScrollCode = (int) LOWORD(wParam);  // scroll bar value 
    nPos = (short int) HIWORD(wParam);   // scroll box position 
    hwndScrollBar = (HWND) lParam; 如果用父窗体默认滚动栏,则hwndScrollBar为NULL,否则是自定义的滚动栏,hwndScrollBar不为NULL,
    很多程序都使用自定义的滚动栏,应此
    SendMessage(hWnd,WM_HSCROLL,SB_LEFT,0)也许为引发该程序的内部的运行错误,不是安全的做法
      

  5.   

    首先要用FindWindow或者FindWindowEx 一层层枚举到具有滚动条的控件句柄,注意这里IE和Word或者notepad 等等的控件类型各自都是不同的然后用  SendMessage( hWnd, WM_HSCROLL, SB_PAGEDOWN, 0 ); 这样的函数给它发滚动消息就OK了
    ^_^具体消息内容见楼上几位
      

  6.   

    FindWindow
    SendMessage
    呵呵。师父也在啊
      

  7.   

    FindWindow和SendMessage我也知道,可是问题是:
    1,如何知道哪个窗口包含滚动条?
    2,SendMessage应该发送给ScrollBar还是其父窗口,还是其它?
      

  8.   

    举个例子吧,比如想让当前这个窗口滚动,大概的代码可以这样获得窗口句柄的方法有很多,这里随便用一个了CWnd* ParentWnd1 = FindWindow(NULL,"请帮忙:如何编程控制其它的应用程序,使之滚动窗口???");CWnd* ParentWnd2 = FindWindowEx( ParentWnd1->m_hWnd, 0, "Shell DocObject View", 0 );CWnd* TargetWnd = FindWindowEx( ParentWnd2->m_hWnd, 0, "Internet Explorer_Server", 0 );TargetWnd->SendMessage(WM_VSCROLL, SB_PAGEDOWN, 0 );就可以了,你可以试一下,很简单的^_^具体类型可以通过Spy++知道
      

  9.   

    根据得到的窗口句柄,发送WM_VSCROLL,WM_HSCROLLSB_BOTTOM Scrolls to the lower right. 
    SB_ENDSCROLL Ends scroll. 
    SB_LINEDOWN Scrolls one line down. 
    SB_LINEUP Scrolls one line up. 
    SB_PAGEDOWN Scrolls one page down. 
    SB_PAGEUP Scrolls one page up. 
    SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. 
    SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. 
    SB_TOP Scrolls to the upper left. 试一试
      

  10.   

    获得窗口句柄,然后SendMessage();
      

  11.   

    找到窗口句柄,然后给他PostMessage
      

  12.   

    获得窗口句柄(因该是你有滚动条的窗口),然后SendMessage();
      

  13.   

    如果你想确切的使某个控件的滚动条滚动,还可以这样CRichEditCtrl m_RichEdit2;m_RichEdit2.SendMessage(WM_VSCROLL,SB_BOTTOM,0);