Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

C# message handling problem!

Back to Forum: Tech Off
  • User profile image
    sojaner

    I wrote this code:

    private const int WM_NCLBUTTONDOWN = 0xA1;
    private const int WM_NCLBUTTONUP = 0xA2;

    protected override void DefWndProc(ref Message m)
            {
                if (m.Msg == WM_NCLBUTTONDOWN)
                {
                        return;
                    }
                }
                else if (m.Msg == WM_NCLBUTTONUP)
                {
                        return;
                    }
                }
                
                base.DefWndProc(ref m);
            }

    protected override void WndProc(ref Message m)
            {
                if (m.Msg == WM_NCLBUTTONDOWN)
                {
                        return;
                    }
                }
                else if (m.Msg == WM_NCLBUTTONUP)
                {
                        return;
                    }
                }

                base.WndProc(ref m);
            }


    I was to write a real event handler for minimize button click.
    When you click the minimize button, a message with the (Msg == 161) and (WParam == 8(it shows that mouse is on minimize button)) is sent to the window that defines the press event for it, and as I read in MSDN, a message that would be the release event of the button would be sent to the window with (Msg == 162) and (WParam ==Eye Rolling but the MSDN notes that if a window has captured the mouse, this message would not be sent to it!
    I use .Net 2.0 and C# 2.0, and I tried so many things like this.Capture = false in any part of the code, Used the MouseDown event handler(it works just when you click in the clientArea of the window!) and even MessageFilter class and Application.AddMessageFilter() but I coulden't do what I want.
    And I'm sure it's because of the mouse capture of the window, because when I filter/ignore the WM_NCLBUTTONDOWN message, and so the capture does not start, the WM_NCLBUTTONUP would be sent to the window and the event that I wrote, raises!
    Could you please help me solve this
    !Sad

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.