Hello everyone,
I've a problem using SetCapture and MouseUp events.
I've done an app that is doing SetCapture(Handle) on a buttonclick
event and have a mouseup event that shows a MessageBox and then call
Releasecaptue and Setcapture(Handle):note that Handle is the same
called from Button and Mouseup event.
I'd expect that my app need only first time to press the button
because other time setcapture is called from mouseup event.This is not
true, because setcapture called from mouseup event does not
work(e.g.:you have to do:push button->mouse up->push button->mouse up
etc), so my question is:why SetCapture work on Button click event and
does not work from mouse event?Am I missing something?
This is the core of my simple app:
[SetCapture,releaseCapture definitions etc...]
public Form1()
{
InitializeComponent();
this.MouseUp+=new MouseEventHandler(Form1_MouseUp);
this.button1.Click+=new EventHandler(button1_Click);
}
[Standard Main,dispose and initialize component]
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
ReleaseCapture();
MessageBox.Show("I'm here!");
SetCapCall();
}
private void button1_Click(object sender, EventArgs e)
{
SetCapCall();
}
private void SetCapCall()
{SetCapture(Handle); //Handle is the same called from Button and
Mouse up event
}
}
Thanks in advance.