现在需要做一个窗体程序,
需求:在一个电脑上连接两个显示器A和B,A显示器在控制室,B显示器在大厅墙上挂着。
用我做的程序控制外面的B显示器播放的内容,在B播放的时候A显示器该做什么都行,等需要设置时,在A显示器上打开我的程序设置B要放的内容。
在网上看的资料是需要用到API函数SetWindowPos,这个怎么用?
有做过这方面的大虾指教一下!

解决方案 »

  1.   

    其实就是设置显示位置的问题 
    假如每个显示器的分辨率800*600,
    设置窗体的location=(800,0),
    就到另一个显示器上去了然后通过窗体句柄用API SetWindowPos
    控制把他拉回来,送回去
      

  2.   

    你说的“设置窗体的location=(800,0)”这个我理解了,
    最后一句“控制把他拉回来,送回去”这个不太理解。
    我找到了SetWindowPos了,具体是用哪个方法或属性?有这方面的资料最好!
    谢谢!
      

  3.   


            /// <summary>
            /// 设置在第几个屏幕上启动。
            /// </summary>
            /// <param name="screen">屏幕(从0开始)</param>
            /// <param name="form">要启动的程序。</param>
            public void FormStartScreen(int screen, Form form)
            {
                if (Screen.AllScreens.Length <= 1 | Screen.AllScreens.Length < screen)
                {
                    SetStartPosition(Screen.AllScreens[0], form);
                }
                else
                {
                    SetStartPosition(Screen.AllScreens[screen], form);
                }
            }
            private void SetStartPosition(Screen screen, Form form)
            {
                form.StartPosition = FormStartPosition.Manual;
                form.Location = new System.Drawing.Point(screen.Bounds.X, screen.Bounds.Y);
                form.Size = screen.WorkingArea.Size;
            }//窗体构造函数时调用  
     myPosition.FormStartScreen(1, this);
      

  4.   

     [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true)]
     private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
    如下面的X,Y就是控制位置的相当于location=(800,0)
    SetWindowPos(hWndInsertAfter, (IntPtr)(0), 800, 0, 800, 600, 0x0040);