Simple Message question...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • craig.kelly

    #1

    Simple Message question...

    I'm experimenting with the message object in C#. If I try to move the
    window by clicking on the client area, why does this work:

    private void baseForm_MouseD own(object sender, MouseEventArgs e)
    {
    Capture = false;
    Message message = Message.Create( Handle, 161, (IntPtr)2, IntPtr.Zero);
    WndProc(ref message);
    }

    but if I do the same thing from an object on the form:

    private void label1_MouseDow n(object sender, MouseEventArgs e)
    {
    Capture = false;
    Message message = Message.Create( Handle, 161, (IntPtr)2, IntPtr.Zero);
    WndProc(ref message);
    }

    it doesn't work?



  • Dmytro Lapshyn [MVP]

    #2
    Re: Simple Message question...

    Hi Craig,

    I think it would be easier to override WndProc, handle WM_NCHITTEST and once
    the pointer is over the label, return HTCAPTION in response to WM_NCHITTEST.

    --
    Sincerely,
    Dmytro Lapshyn [Visual Developer - Visual C# MVP]


    "craig.kell y" <craig.kelly@ro gers.com> wrote in message
    news:zNqdnXTa8o MVAw3fRVn-ig@rogers.com.. .[color=blue]
    > I'm experimenting with the message object in C#. If I try to move the
    > window by clicking on the client area, why does this work:
    >
    > private void baseForm_MouseD own(object sender, MouseEventArgs e)
    > {
    > Capture = false;
    > Message message = Message.Create( Handle, 161, (IntPtr)2, IntPtr.Zero);
    > WndProc(ref message);
    > }
    >
    > but if I do the same thing from an object on the form:
    >
    > private void label1_MouseDow n(object sender, MouseEventArgs e)
    > {
    > Capture = false;
    > Message message = Message.Create( Handle, 161, (IntPtr)2, IntPtr.Zero);
    > WndProc(ref message);
    > }
    >
    > it doesn't work?
    >
    >
    >[/color]

    Comment

    Working...