Beispiel #1
0
        public DesktopShareDlg()
        {
            InitializeComponent();
            this.CenterToScreen();

            rgbmodeComboBox.Items.Add("8-bit colors");
            rgbmodeComboBox.Items.Add("16-bit colors");
            rgbmodeComboBox.Items.Add("24-bit colors");
            rgbmodeComboBox.Items.Add("32-bit colors");
            rgbmodeComboBox.SelectedIndex = 3;

            intervalNumericUpDown.Value = (decimal)update_interval;

            int i = 0;
            IntPtr ptr = IntPtr.Zero;
            while (WindowsHelper.GetDesktopWindowHWND(i, ref ptr))
            {
                ShareWindow wnd = new ShareWindow();
                if (WindowsHelper.GetWindow(ptr, ref wnd))
                {
                    windowsComboBox.Items.Add(wnd.szWindowTitle);
                    windowHandles.Add(wnd.hWnd);
                }
                i++;
            }
            if (i > 0)
                windowsComboBox.SelectedIndex = 0;
        }
Beispiel #2
0
 /**
  * @brief Get the properties of a window from its window handle (HWND). */
 public static bool GetWindow(System.IntPtr hWnd,
     ref ShareWindow lpShareWindow)
 {
     return TTDLL.TT_Windows_GetWindow(hWnd, ref lpShareWindow);
 }
Beispiel #3
0
        public void TestDesktopHWND()
        {
            const string USERNAME = "******", PASSWORD = "******"; string NICKNAME = "TeamTalk.NET - " + GetCurrentMethod();
            const UserRight USERRIGHTS = UserRight.USERRIGHT_TRANSMIT_DESKTOP;
            MakeUserAccount(GetCurrentMethod(), USERNAME, PASSWORD, USERRIGHTS);
            TeamTalk ttclient = NewClientInstance();

            Connect(ttclient);
            Login(ttclient, NICKNAME, USERNAME, PASSWORD);
            JoinRoot(ttclient);

            int n_windows = 0;
            IntPtr hWnd = IntPtr.Zero;
            while (WindowsHelper.GetDesktopWindowHWND(n_windows++, ref hWnd))
            {
                ShareWindow shWnd = new ShareWindow();
                Assert.IsTrue(WindowsHelper.GetWindow(hWnd, ref shWnd));
            }
            
            Assert.IsTrue(n_windows > 0, "enum windows");
            
            hWnd = WindowsHelper.GetDesktopHWND();
            Assert.AreNotEqual(IntPtr.Zero, hWnd, "desktop hWnd");

            TTMessage msg = new TTMessage();
            int remain, tx;

            //RGB8 test
            tx = ttclient.SendDesktopWindowFromHWND(hWnd, BitmapFormat.BMP_RGB8_PALETTE, DesktopProtocol.DESKTOPPROTOCOL_ZLIB_1);
            Assert.IsTrue(tx > 0, "send desktop as 8bpp");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 20000, ref msg), "tx bmp started");
            remain = (int)msg.DataToObject();
            while (remain > 0)
            {
                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 10000, ref msg), "tx bmp started");
                remain = (int)msg.DataToObject();
            }

            Assert.IsFalse(ttclient.Flags.HasFlag(ClientFlag.CLIENT_TX_DESKTOP), "tx desktop done");
            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE), "desktop active");

            //RGB16 test
            tx = ttclient.SendDesktopWindowFromHWND(hWnd, BitmapFormat.BMP_RGB16_555, DesktopProtocol.DESKTOPPROTOCOL_ZLIB_1);
            Assert.IsTrue(tx > 0, "send desktop as 16bpp");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 20000, ref msg), "tx bmp started");
            remain = (int)msg.DataToObject();
            while (remain > 0)
            {
                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 10000, ref msg), "tx bmp started");
                remain = (int)msg.DataToObject();
            }

            Assert.IsFalse(ttclient.Flags.HasFlag(ClientFlag.CLIENT_TX_DESKTOP), "tx desktop done");
            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE), "desktop active");

            //RGB24 test
            tx = ttclient.SendDesktopWindowFromHWND(hWnd, BitmapFormat.BMP_RGB24, DesktopProtocol.DESKTOPPROTOCOL_ZLIB_1);
            Assert.IsTrue(tx > 0, "send desktop as 24bpp");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 20000, ref msg), "tx bmp started");
            remain = (int)msg.DataToObject();
            while (remain > 0)
            {
                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 10000, ref msg), "tx bmp started");
                remain = (int)msg.DataToObject();
            }

            Assert.IsFalse(ttclient.Flags.HasFlag(ClientFlag.CLIENT_TX_DESKTOP), "tx desktop done");
            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE), "desktop active");

            //RGB32 test
            tx = ttclient.SendDesktopWindowFromHWND(hWnd, BitmapFormat.BMP_RGB32, DesktopProtocol.DESKTOPPROTOCOL_ZLIB_1);
            Assert.IsTrue(tx > 0, "send desktop as 32bpp");

            Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 20000, ref msg), "tx bmp started");
            remain = (int)msg.DataToObject();
            while (remain > 0)
            {
                Assert.IsTrue(WaitForEvent(ttclient, ClientEvent.CLIENTEVENT_DESKTOPWINDOW_TRANSFER, 10000, ref msg), "tx bmp started");
                remain = (int)msg.DataToObject();
            }

            Assert.IsFalse(ttclient.Flags.HasFlag(ClientFlag.CLIENT_TX_DESKTOP), "tx desktop done");
            Assert.IsTrue(ttclient.Flags.HasFlag(ClientFlag.CLIENT_DESKTOP_ACTIVE), "desktop active");
        }