none
Unable to track the X,Y position of floated Custom task pane while dragging on the word document RRS feed

  • Question

  • Hi I am trying to create Word Add-in using custom pane.Here I am unable to get the position of floated custom pane While dragging.

    Requirement:-Custom task pane(CTP)

    There is one "Main CTP" where I am displaying Toolstrip's. When I am dragging out these toolstrip from "Main CTP"  I am converting them into floating CTP.Now I want to convert back the CTP into toolstrip but i am unable to get any such events in CTP by which i can track the position of floating CTP While dragging so that icould ci=onvert it when the TOP of CTP will enter into the "Main CTP" area.

    I tried these events..

    CTP.Control.DragEnter

    CTP.Control.MouseMove

    but non of them are firing since I have kept there  ctp.Control.AllowDrop = true;

    I also tried to use there DoDragDrop() event but not able to produce the result here is the code where I am trying to associate the drag drop events to the CTP at run time.....

    CodeFlow:-

                    

      private void ConvertToolStripToCustomPane(ToolStrip ts)
            {
                this.Invoke((MethodInvoker)delegate()
                {
                    UserControl uc = new UserControl();
                    FlowLayoutPanel flow = new FlowLayoutPanel();
                    flow.Dock = DockStyle.Fill;
                    ts.Height = 2000;
                    ts.CanOverflow = false;
                    int i = 0;
                    foreach (ToolStripItem ti in ts.Items)
                    {
                        i++;
                        Button b = new Button();
                        b.Text = ti.Text;
                        b.AutoSize = true;
                        b.Margin = new Padding(2);
                        b.Padding = new Padding(0);
                        b.FlatStyle = FlatStyle.Flat;
                        flow.Controls.Add(b);
                    }
                    uc.Controls.Add(flow);
                    Microsoft.Office.Tools.CustomTaskPane ctp = addinObj.CustomTaskPanes.Add(uc, "TP_" + Guid.NewGuid().ToString());
                    ctp.DockPosition = MsoCTPDockPosition.msoCTPDockPositionFloating;
                    ctp.Height = ts.Items.Cast<ToolStripItem>().Max(tsi => tsi.Height)+50;

                    ctp.Width = ts.Items.Cast<ToolStripItem>().Sum(tsi => tsi.Width)+50 ;
                    ctp.Height = 80;//ctp.Height * (i / 5);
                    ctp.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;
                    ctp.Control.AllowDrop = true;
                    ctp.Control.DragEnter += new DragEventHandler(Control_DragEnter);

                    ctp.Control.LocationChanged+=new EventHandler(Control_LocationChanged);                     ctp.Control.DragLeave += new EventHandler(Control_DragLeave);
                    ctp.DockPositionChanged += new EventHandler(ctp_DockPositionChanged);
                    ctp.Control.GiveFeedback += new GiveFeedbackEventHandler(Control_GiveFeedback);
                    ctp.Visible = true;

                    addedCTP = ctp;
                });
            }

    associated handlers to be fired:-

                                                    

     void Control_GiveFeedback(object sender, GiveFeedbackEventArgs e)
            {

                 AttachToolStripIfNeeded();
            }

            void Control_DragLeave(object sender, EventArgs e)
            {

                  AttachToolStripIfNeeded();

            }

            void Control_DragEnter(object sender, DragEventArgs e)
            {
              //  e.Data.GetData("Hi");
                AttachToolStripIfNeeded();

            }

    void Control_LocationChanged(object sender, EventArgs e)
            {
                AttachToolStripIfNeeded();
            }

    But non of these are firing.If any body can tell me how to fire these events while dragging of custom pane

    it would be really great help...


    Friday, April 26, 2013 5:34 AM

All replies

  • Hello,

    Thanks for your participation. I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated. Sorry for any inconvenience and have a nice day!

    Best Regards,


    Damon Zheng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 1, 2013 4:35 AM
    Moderator
  • Hi Damon,

    Thanks a lot, any help would be highly appreciated since I am completely stuck over here.

    Thanks

    Prakash

    Wednesday, May 1, 2013 7:05 AM
  • Hi Damon,

    Thanks a lot, any help would be highly appreciated since I am completely stuck over here.

    Thanks

    Prakash

    Hello Prakash,

    Your question falls into the paid support category which requires a more in-depth level of support.  Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Regards

    Pradip

    Wednesday, May 8, 2013 11:37 PM