예제 #1
0
        private void ExpandNode(IntPtr Node)
        {
            int       position = 0;
            Stopwatch timer;
            int       left       = 0;
            int       top        = 0;
            int       right      = 0;
            int       bottom     = 0;
            int       imageIndex = -1;
            string    imageKey   = "";

            NM.tagRect clientRect = new NM.tagRect();

            // check if already expanded
            GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "IsExpanded", MemberTypes.Property);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
            GUI.m_APE.SendMessages(EventSet.APE);
            GUI.m_APE.WaitForMessages(EventSet.APE);
            // Get the value(s) returned MUST be done straight after the WaitForMessages call
            bool isExpanded = GUI.m_APE.GetValueFromMessage();

            if (isExpanded)
            {
                return;
            }

            for (int i = 0; i < 2; i++)
            {
                // Get bounds
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "EnsureVisible", MemberTypes.Method);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store3, "Bounds", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "Left", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Top", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Right", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Bottom", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store8, "ImageIndex", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store9, "ImageKey", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store8);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store9);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                left       = GUI.m_APE.GetValueFromMessage();
                top        = GUI.m_APE.GetValueFromMessage();
                right      = GUI.m_APE.GetValueFromMessage();
                bottom     = GUI.m_APE.GetValueFromMessage();
                imageIndex = GUI.m_APE.GetValueFromMessage();
                imageKey   = GUI.m_APE.GetValueFromMessage();

                NM.GetClientRect(Identity.Handle, out clientRect);

                if (left < 0 || top < 0 || bottom > clientRect.bottom)
                {
                    // Go round again
                }
                else
                {
                    break;
                }
            }

            if (right > clientRect.right)
            {
                right = clientRect.right;
            }

            bool waitForMove = false;

            if (bottom > clientRect.bottom)
            {
                waitForMove = true;
                bottom      = clientRect.bottom;
            }

            // Expand it
            if (m_ShowPlusMinus)
            {
                int stateImageWidth = 0;
                if (m_CheckBoxes)
                {
                    stateImageWidth = m_StateImageWidth;
                }

                int imageWidth = 0;
                if (imageIndex != -1 || imageKey != "")
                {
                    imageWidth = m_ImageWidth;
                }

                int expandImageWidth = m_ImageWidth;

                // Scroll the expand icon in to view if need be
                int x = left - imageWidth - stateImageWidth - expandImageWidth;
                if (x != 0)
                {
                    //get current scroll bar pos
                    position = NM.GetScrollPos(Identity.Handle, NM.SBS_HORZ);

                    //update the pos
                    position = position + x;
                    NM.SetScrollPos(Identity.Handle, NM.SBS_HORZ, position, false);

                    //send the message to move
                    IntPtr MessageResult;
                    IntPtr SendResult = NM.SendMessageTimeout(Handle, NM.WM_HSCROLL, new IntPtr(MakeLParam((int)NM.SB_THUMBPOSITION, position)), IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, (uint)GUI.GetTimeOut(), out MessageResult);

                    //update the bounds
                    GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store3, "Bounds", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "Left", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Top", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Right", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Bottom", MemberTypes.Property);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
                    GUI.m_APE.SendMessages(EventSet.APE);
                    GUI.m_APE.WaitForMessages(EventSet.APE);
                    // Get the value(s) returned MUST be done straight after the WaitForMessages call
                    left   = GUI.m_APE.GetValueFromMessage();
                    top    = GUI.m_APE.GetValueFromMessage();
                    right  = GUI.m_APE.GetValueFromMessage();
                    bottom = GUI.m_APE.GetValueFromMessage();
                }

                base.SingleClickInternal(left - imageWidth - stateImageWidth - (expandImageWidth / 2), top + ((bottom - top) / 2), MouseButton.Left, MouseKeyModifier.None);
            }
            else
            {
                base.DoubleClickInternal(right - 4, top + ((bottom - top) / 2), MouseButton.Left, MouseKeyModifier.None);
            }

            // Wait for it to be expanded
            bool isNowExpanded = false;

            timer = Stopwatch.StartNew();
            do
            {
                // Get if expanded
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "IsExpanded", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                isNowExpanded = GUI.m_APE.GetValueFromMessage();

                if (isNowExpanded)
                {
                    break;
                }

                if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                {
                    throw GUI.ApeException("Node failed to expand");
                }

                Thread.Sleep(15);
            }while (true);

            //left clicking on a node which is partially off the bottom of the window will scroll it
            if (waitForMove)
            {
                timer = Stopwatch.StartNew();
                do
                {
                    // Get bounds
                    GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "Bounds", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store2, DataStores.Store3, "Bottom", MemberTypes.Property);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store3);
                    GUI.m_APE.SendMessages(EventSet.APE);
                    GUI.m_APE.WaitForMessages(EventSet.APE);
                    // Get the value(s) returned MUST be done straight after the WaitForMessages call
                    bottom = GUI.m_APE.GetValueFromMessage();

                    if (bottom >= clientRect.bottom)
                    {
                        break;
                    }

                    if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                    {
                        throw GUI.ApeException("Node failed to scroll fully into view");
                    }

                    Thread.Sleep(15);
                }while (true);
            }

            // After clicking sleep for a bit to give time for the treeview to update
            Thread.Sleep(30);
        }
예제 #2
0
        private void CheckNode(IntPtr Node, bool Check)
        {
            int       position = 0;
            Stopwatch timer;
            bool      isChecked  = false;
            int       left       = 0;
            int       top        = 0;
            int       right      = 0;
            int       bottom     = 0;
            int       imageIndex = -1;
            string    imageKey   = "";

            NM.tagRect clientRect = new NM.tagRect();

            // Check for checkbox style
            if (!m_CheckBoxes)
            {
                throw GUI.ApeException("TreeView does not have checkbox style");
            }

            // Check for if its already in the correct state
            // Get state and bounds
            GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "Checked", MemberTypes.Property);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
            GUI.m_APE.SendMessages(EventSet.APE);
            GUI.m_APE.WaitForMessages(EventSet.APE);
            // Get the value(s) returned MUST be done straight after the WaitForMessages call
            isChecked = GUI.m_APE.GetValueFromMessage();

            if (isChecked == Check)
            {
                return;
            }

            // Treeviews have a habbit of scrolling the last selected node back into view so clicking the
            // Node we want to check to select it is a good idea although not in thoery needed
            ClickNode(Node, MouseButton.Left);

            do
            {
                // Get state and bounds
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "EnsureVisible", MemberTypes.Method);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store3, "Bounds", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "Left", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Top", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Right", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Bottom", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store8, "ImageIndex", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store9, "ImageKey", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store8);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store9);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                left       = GUI.m_APE.GetValueFromMessage();
                top        = GUI.m_APE.GetValueFromMessage();
                right      = GUI.m_APE.GetValueFromMessage();
                bottom     = GUI.m_APE.GetValueFromMessage();
                imageIndex = GUI.m_APE.GetValueFromMessage();
                imageKey   = GUI.m_APE.GetValueFromMessage();

                NM.GetClientRect(Identity.Handle, out clientRect);

                if (top == 0)
                {
                    if (bottom > clientRect.bottom)
                    {
                        bottom = clientRect.bottom;
                    }
                }

                if (left < 0 || top < 0 || bottom > clientRect.bottom)
                {
                    // Go round again
                }
                else
                {
                    break;
                }
            }while (true);

            if (right > clientRect.right)
            {
                right = clientRect.right;
            }

            int imageWidth = 0;

            if (imageIndex != -1 || imageKey != "")
            {
                imageWidth = m_ImageWidth;
            }

            int stateImageWidth = m_StateImageWidth;

            // Scroll the checkbox in to view if need be
            int x = left - imageWidth - stateImageWidth;

            if (x != 0)
            {
                //get current scroll bar pos
                position = NM.GetScrollPos(Identity.Handle, NM.SBS_HORZ);

                //update the pos
                position = position + x;
                NM.SetScrollPos(Identity.Handle, NM.SBS_HORZ, position, true);

                //send the message to move
                IntPtr MessageResult;
                IntPtr SendResult = NM.SendMessageTimeout(Handle, NM.WM_HSCROLL, new IntPtr(MakeLParam((int)NM.SB_THUMBPOSITION, position)), IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, (uint)GUI.GetTimeOut(), out MessageResult);

                //update the bounds
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store3, "Bounds", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "Left", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Top", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Right", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Bottom", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                left   = GUI.m_APE.GetValueFromMessage();
                top    = GUI.m_APE.GetValueFromMessage();
                right  = GUI.m_APE.GetValueFromMessage();
                bottom = GUI.m_APE.GetValueFromMessage();
            }

            base.SingleClickInternal(left - imageWidth - (stateImageWidth / 2), top + ((bottom - top) / 2), MouseButton.Left, MouseKeyModifier.None);

            // Wait for it to be checked / unchecked
            bool isNowChecked = !Check;

            timer = Stopwatch.StartNew();
            do
            {
                // Get the checked state
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "Checked", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                isNowChecked = GUI.m_APE.GetValueFromMessage();

                if (isNowChecked == Check)
                {
                    break;
                }

                if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                {
                    throw GUI.ApeException("Failed to check / uncheck node");
                }

                Thread.Sleep(15);
            }while (true);

            // After clicking sleep for a bit to give time for the treeview to update
            Thread.Sleep(30);
        }
예제 #3
0
        private void ExpandNode(IntPtr Node)
        {
            int       Position = 0;
            Stopwatch timer;
            int       Left   = 0;
            int       Top    = 0;
            int       Right  = 0;
            int       Bottom = 0;

            NM.tagRect ClientRect = new NM.tagRect();

            // check if already expanded
            GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "IsExpanded", MemberTypes.Property);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
            GUI.m_APE.SendMessages(EventSet.APE);
            GUI.m_APE.WaitForMessages(EventSet.APE);
            // Get the value(s) returned MUST be done straight after the WaitForMessages call
            bool IsExpanded = GUI.m_APE.GetValueFromMessage();

            if (IsExpanded)
            {
                return;
            }

            for (int i = 0; i < 2; i++)
            {
                // Get bounds
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "EnsureVisible", MemberTypes.Method);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store3, "Bounds", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "Left", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Top", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Right", MemberTypes.Property);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Bottom", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                Left   = GUI.m_APE.GetValueFromMessage();
                Top    = GUI.m_APE.GetValueFromMessage();
                Right  = GUI.m_APE.GetValueFromMessage();
                Bottom = GUI.m_APE.GetValueFromMessage();

                NM.GetClientRect(Identity.Handle, out ClientRect);

                if (Left < 0 || Top < 0 || Bottom > ClientRect.bottom)
                {
                    // Go round again
                }
                else
                {
                    break;
                }
            }

            if (Right > ClientRect.right)
            {
                Right = ClientRect.right;
            }

            bool WaitForMove = false;

            if (Bottom > ClientRect.bottom)
            {
                WaitForMove = true;
                Bottom      = ClientRect.bottom;
            }

            // Expand it
            if (m_ShowPlusMinus)
            {
                int CheckBoxModifier = 0;
                if (m_CheckBoxes)
                {
                    CheckBoxModifier = 12;
                }

                // Scroll the expand icon in to view if need be
                int X = Left - 7 - CheckBoxModifier - 5;
                if (X < 0)
                {
                    //get current scroll bar pos
                    Position = NM.GetScrollPos(Identity.Handle, NM.SBS_HORZ);

                    //update the pos
                    Position = Position + X;
                    NM.SetScrollPos(Identity.Handle, NM.SBS_HORZ, Position, false);

                    //send the message to move
                    IntPtr MessageResult;
                    IntPtr SendResult = NM.SendMessageTimeout(Handle, NM.WM_HSCROLL, new IntPtr(MakeLParam((int)NM.SB_THUMBPOSITION, Position)), IntPtr.Zero, NM.SendMessageTimeoutFlags.SMTO_NORMAL, (uint)GUI.GetTimeOut(), out MessageResult);

                    base.SingleClickInternal(5, Top + ((Bottom - Top) / 2), MouseButton.Left, MouseKeyModifier.None);
                }
                else
                {
                    base.SingleClickInternal(Left - 7 - CheckBoxModifier, Top + ((Bottom - Top) / 2), MouseButton.Left, MouseKeyModifier.None);
                }
            }
            else
            {
                base.DoubleClickInternal(Right - 4, Top + ((Bottom - Top) / 2), MouseButton.Left, MouseKeyModifier.None);
            }

            // Wait for it to be expanded
            bool IsNowExpanded = false;

            timer = Stopwatch.StartNew();
            do
            {
                // Get if expanded
                GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "IsExpanded", MemberTypes.Property);
                GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
                GUI.m_APE.SendMessages(EventSet.APE);
                GUI.m_APE.WaitForMessages(EventSet.APE);
                // Get the value(s) returned MUST be done straight after the WaitForMessages call
                IsNowExpanded = GUI.m_APE.GetValueFromMessage();

                if (IsNowExpanded)
                {
                    break;
                }

                if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                {
                    throw new Exception("Node failed to expand");
                }

                Thread.Sleep(15);
            }while (true);

            //left clicking on a node which is partially off the bottom of the window will scroll it
            if (WaitForMove)
            {
                timer = Stopwatch.StartNew();
                do
                {
                    // Get bounds
                    GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "NodeFromHandle", MemberTypes.Method, new Parameter(GUI.m_APE, Node));
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "Bounds", MemberTypes.Property);
                    GUI.m_APE.AddQueryMessageReflect(DataStores.Store2, DataStores.Store3, "Bottom", MemberTypes.Property);
                    GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store3);
                    GUI.m_APE.SendMessages(EventSet.APE);
                    GUI.m_APE.WaitForMessages(EventSet.APE);
                    // Get the value(s) returned MUST be done straight after the WaitForMessages call
                    Bottom = GUI.m_APE.GetValueFromMessage();

                    if (Bottom >= ClientRect.bottom)
                    {
                        break;
                    }

                    if (timer.ElapsedMilliseconds > GUI.m_APE.TimeOut)
                    {
                        throw new Exception("Node failed to scroll fully into view");
                    }

                    Thread.Sleep(15);
                }while (true);
            }

            // After clicking sleep for a bit to give time for the treeview to update
            Thread.Sleep(30);
        }