Re: Drag and drop labels in a panel



On 30 Gen, 17:19, "Stoitcho Goutsev \(100\)" <1...@xxxxxxx> wrote:
Vincent,

Derive from the label control and override its WndProc

private const int WM_NCHITTEST = 0x84;
private const int HTCAPTION = 0x2;
private const int HTCLIENT = 0x1;

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

}

That should work for any control

--
HTH
Stoitcho Goutsev (100)"Blkpower" <webmas...@xxxxxxxxxxxxxxx> wrote in message

news:1170166801.793786.142540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Hi,

thanks for your answer.
What I need to do is to move the whole control, not only the text.
Any ideas about how to do this?

Thanks
Vincent

On 24 Gen, 16:40, "Stoitcho Goutsev \(100\)" <1...@xxxxxxx> wrote:
Hi,

DnD is used to move data around, for example you select a text in one
application and you move it to some other application - you move the
data.
The same effect you can get by copy/paste the text to/from the clipboard
If grab a window by its caption and start moving it around this has
nothing
to do with drag and drop; there is no data that has been moved around.

So what you want to do - move the label's data (I guess the text) or you
want to move the lable control around just like you would move a window
by
grabing it handle?

--
Stoitcho Goutsev (100)

"Blkpower" <webmas...@xxxxxxxxxxxxxxx> wrote in
messagenews:1169567028.197125.144710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi to all,

I'm writing a windows form application that has a panel with some
labels in it.
I need to let the user move these labels with drag and drop inside the
panel. How can I do it?
I now how to drag and drop for example the text contained in a textbox,
but not the whole control.
I read an article called "Fake drag and drop" that works without
dragdrop event and it's not so good.

Thanks in advance.
Vincent- Nascondi testo tra virgolette -- Mostra testo tra virgolette -- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -

Hi, thanks.
I tried as you suggested but was not able to see it working.
This is my class:

namespace UtilityConfigManager
{
public class MovingLabel: Label
{

private const int WM_NCHITTEST = 0x84;
private const int HTCAPTION = 0x2;
private const int HTCLIENT = 0x1;

public MovingLabel()
{
}

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

and this is my form where I try to use the control:

public class Form2 : System.Windows.Forms.Form
{
private UtilityConfigManager.MovingLabel mlabel1;
private System.ComponentModel.Container components = null;

public Form2()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.mlabel1 = new UtilityConfigManager.MovingLabel();
this.SuspendLayout();
//
// mlabel1
//
this.mlabel1.AllowDrop = true;
this.mlabel1.Location = new System.Drawing.Point(72, 48);
this.mlabel1.Name = "mlabel1";
this.mlabel1.TabIndex = 1;
this.mlabel1.Text = "mlabel1";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.mlabel1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);

}
}

Where Am I wrong?

Thanks

.



Relevant Pages

  • Re: Figure out when mouse cursor enters/leaves form
    ... private void SetEventHandlers(Control control, EventHandler mouseEnter, ... EventHandler mouseLeave) ... private const int WM_NCHITTEST = 0x0084; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scrolling Control Container
    ... I ended up using a panel control with AutoScroll set to true and then ... private const int WM_NCCALCSIZE = 0x0083; ... > a scrolling container that can hold up to about 100 of them and that I can ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Scrolling Control Container
    ... Yes I tried the HScroll and VScroll properties of the panel and they ... way I found to get rid of them for good so I could do the scrolling myself, ... >> I ended up using a panel control with AutoScroll set to true and then ... >> private const int WM_NCCALCSIZE = 0x0083; ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • RE: ToolTip - controlling duration of display
    ... You need to use the SendMessage API using the TTM_SETDELAYTIME constant. ... private const int WM_USER = 0x0400; ... > Is there any way to control the tooltip of a control so that it doesn't ... I know there are tooltip controls available, ...
    (microsoft.public.dotnet.framework.aspnet)
  • EventValidation razzle dazzle
    ... hides a label and shows a textbox in its place. ... I event tried code 2 in the control. ... protected override void Render ...
    (microsoft.public.inetserver.asp.components)