Wednesday, October 8, 2008

[DotNetDevelopment] Re: Help! Move a control at runtime by using WM_NCHITTEST, weird behavior.

It seems that tab control performs layouting when Tab Page changes. Since you have moved the control through API, maybe its internal coordinates are NOT changed that is why Tab control again places it on its original location. Try changing its Left and Top properties when dragging and dropping finish.

On Tue, Oct 7, 2008 at 11:53 AM, 沈斌 <shenbinsc@gmail.com> wrote:
When I am trying to move a control at runtime in a tabPage by using WM_NCHITTEST,  though the control is seen dragged to a new location,
but when then tabPage is goes down and up again. the location of the previously dragged control goes back to its original location.
So what's wrong?

The control code:

class DraggablePicBox : PictureBox
 
   {
        private const int WM_NCHITTEST = 0x84;
        private const int HTCLIENT = 0x1;
        private const int HTCAPTION = 0x2;

        public bool DraggAble
        {
            get;
            set;
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (this.DraggAble && m.Msg == WM_NCHITTEST)
            {
                if ((int)m.Result == HTCLIENT)
                    m.Result = (IntPtr)HTCAPTION;
            }
        }

    }



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group.
To post to this group, send email to DotNetDevelopment@googlegroups.com
To unsubscribe from this group, send email to DotNetDevelopment-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/DotNetDevelopment

You may subscribe to group Feeds using a RSS Feed Reader to stay upto date using following url  

<a href="http://feeds.feedburner.com/DotNetDevelopment"> http://feeds.feedburner.com/DotNetDevelopment</a>
-~----------~----~----~----~------~----~------~--~---