Preventing control movement

  • Thread starter Thread starter Fredo
  • Start date Start date
F

Fredo

I have a Panel derived class on a ScrollableControl derived class. When the
ScrollableControl scrolls, I don't want the panel to move.

I've tried everything I can think of and I can't make this happen. Seems
like it should be simple enough.

Moving it back to where I want it in OnMove or OnLocationChanged is no good
because of the visible jumping.

I've tried handling WM_MOVE in WndProc. I tried setting Result to 0 and 1
and passing it to DefWndProc and WndProc, but neither cancels the move. I've
tried eating the message and not passing it on, but to no avail.

I've tried the same with WM_WINDOWPOSCHANGING but that didn't work.

I'm just stumped. How do I keep this window from moving?

Thanks
 
In addition, I've tried the following in WM_WINDOWPOSCHANGING:

case (int) Win32.Msg.WM_WINDOWPOSCHANGING:
if (moveDisabled_ && m.HWnd == Handle)
{
Win32.WINDOWPOS winPos =
(Win32.WINDOWPOS)m.GetLParam(typeof(Win32.WINDOWPOS));
winPos.flags |= (int)Win32.SetWindowPosFlags.SWP_NOMOVE;
System.Runtime.InteropServices.Marshal.StructureToPtr(winPos,
m.LParam, false);
m.Result = (IntPtr) 0;
base.DefWndProc(ref m);
return;
}
break;


And this isn't working either.

I've tried removing the base.DefWndProc and I've tried base.WndProc as well.
None work.

Any help would be appreciated.
 
Why is the panel in the scrollable control, why cant it be hovering above it?

Ciaran O'Donnell
 
I've actually considered that as well.

The problem is that, if the parent of the controls is moved, the two
controls may move in a disjointed fashion and we'd like to avoid that. In
fact, one of the container controls we use (all of our controls are custom),
moves controls around in response to user input and we'd like this control
to move as one.

We could create a parent control to hold them all, but that's not feasible
either at this point. We're getting near shipping and that would break all
the existing code using the control in question.

So the best solution would simply be to prevent the panel from moving when
the control scrolls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top