BuildingCoder.Press.PostMessage C# (CSharp) Метод

PostMessage() приватный Метод

private PostMessage ( IntPtr hWnd, uint msg, uint wParam, uint lParam ) : bool
hWnd System.IntPtr
msg uint
wParam uint
lParam uint
Результат bool
        public static extern bool PostMessage(
            IntPtr hWnd, uint msg, uint wParam, uint lParam);

Usage Example

        void OnDocumentChanged(
            object sender,
            DocumentChangedEventArgs e)
        {
            ICollection <ElementId> idsAdded
                = e.GetAddedElementIds();

            int n = idsAdded.Count;

            Debug.Print("{0} id{1} added.",
                        n, Util.PluralSuffix(n));

            // This does not work, because the handler will
            // be called each time a new instance is added,
            // overwriting the previous ones recorded:

            //_added_element_ids = e.GetAddedElementIds();

            _added_element_ids.AddRange(idsAdded);

            if (_place_one_single_instance_then_abort &&
                0 < n)
            {
                // Why do we send the WM_KEYDOWN message twice?
                // I tried sending it once only, and that does
                // not work. Maybe the proper thing to do would
                // be something like the Press.OneKey method...
                //
                //Press.OneKey( _revit_window.Handle,
                //  (char) Keys.Escape );
                //
                // Nope, that did not work.
                //
                // Answer: When you place instances with
                // PromptForFamilyInstancePlacement, the previous
                // one remains selected just until you drop the
                // next one. The first esc key hit removes that
                // selection while still allowing you to continue
                // adding instances to the model. Only a second
                // esc hit aborts the command.

                //Press.PostMessage( _revit_window.Handle,
                //  (uint) Press.KEYBOARD_MSG.WM_KEYDOWN,
                //  (uint) Keys.Escape, 0 ); // 2018

                //Press.PostMessage( _revit_window.Handle,
                //  (uint) Press.KEYBOARD_MSG.WM_KEYDOWN,
                //  (uint) Keys.Escape, 0 ); // 2018

                Press.PostMessage(_revit_window,
                                  (uint)Press.KEYBOARD_MSG.WM_KEYDOWN,
                                  (uint)Keys.Escape, 0); // 2019

                Press.PostMessage(_revit_window,
                                  (uint)Press.KEYBOARD_MSG.WM_KEYDOWN,
                                  (uint)Keys.Escape, 0); // 2019
            }
        }