Form events taking precedence over control events and forwarding events?
-
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely. Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected. But for that I'd need to have the form's mouse events take precedence over all control mouse events. Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or? I need to fire the form's mouse event at all times and ignore the control's events instead. What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked? Thank you!
-
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely. Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected. But for that I'd need to have the form's mouse events take precedence over all control mouse events. Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or? I need to fire the form's mouse event at all times and ignore the control's events instead. What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked? Thank you!
Hi, I don't exactly remember what it is you wanted to achieve three months ago, and I sure can't tell from today's message. I have several suggestions for you: 1. create a new app, as simple as possible, that poses the problem you have, and experiment with it, not with the real app which by now must be too large and convoluted to understand anyhow. If you then still don't succeed, clearly explain that simple app, what it does, and how that differs from what you want. 2. In a wild guess you want all controls to be non-functional as far as mouse operations go, have you tried
myForm.Capture=true;
? 3. In an equally wild guess, if you were to want to know the position of the mouse at all times, say for displaying it (I have an editor that does that), then you could use a timer that periodically (say 10Hz) gets Control.MousePosition, that is the mouse position in screen coordinates, which can be easily transformed using myForm.PointToClient(). 4. read my sig. :)Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely. Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected. But for that I'd need to have the form's mouse events take precedence over all control mouse events. Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or? I need to fire the form's mouse event at all times and ignore the control's events instead. What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked? Thank you!
The problem is the WM_MOUSEMOVE message (0x200) only gets passed to the control the mouse is over. Even overriding WndProc won't solve that. What is it that you're wanting to achieve exactly?
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
The problem is the WM_MOUSEMOVE message (0x200) only gets passed to the control the mouse is over. Even overriding WndProc won't solve that. What is it that you're wanting to achieve exactly?
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)You too haven't been paying attention the last three months? :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely. Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected. But for that I'd need to have the form's mouse events take precedence over all control mouse events. Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or? I need to fire the form's mouse event at all times and ignore the control's events instead. What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked? Thank you!
It's not very clear what you tried to achieve.... In both WinForm and WPF you can capture mouse event with (in a control) Capture() then you 'll get mouse event until, mmh... I'm not sure.. usually I always release the mouse on Mouse Up event... Other than that you can try to write a mouse hook http://support.microsoft.com/kb/318804[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
You too haven't been paying attention the last three months? :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
I only visit a couple of dozen times throughout the day and evening. Note to self - must spend more time on CP! My Mrs will love that, and so will my boss ;)
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus) -
I'm still hung up on that selection, for 3 months now. Nothing I try and no code others provide works even remotely. Now I think I might use a transparent form that changes size according to mouse movement and check if it's client rectangle intersects with controls that can be selected. But for that I'd need to have the form's mouse events take precedence over all control mouse events. Normally, when the mouse is over a control, only the control's mouse events are fired and the form's own mouse events aren't touched, or? I need to fire the form's mouse event at all times and ignore the control's events instead. What happens if no control on the form (at least in the area that matters, menus are fine) has any event specified, will the form's events fire then or are they still blocked? Thank you!
Thanks. But now that I think of it, I probably don't need it anymore. What I'm trying to do for about 3 months now is implementing an Excel like selection for a collection of PictureBoxes that are arranged in a grid, similar to cells in Excel. I don't want to select independent boxes with ctrl, just selecting a region while the mouse button is held down. I asked about this many times here and on msdn, but I either got ignored or code that didn't work at all. The latest code I got from msdn also doesn't work, but gave me an idea. I'm trying to use a half transparent form to draw the selection rectangle and use the MouseEnter and MouseLeave events of PictureBoxes to fire the Form's events (passing the MouseArgs) to change the selection form's size and location and store the coordinates of the PictureBoxes in a collection (which will be used after selection is finished). It looks like this: http://i28.tinypic.com/einihz.jpg[^] The cursor is above box 16 and the selection form is in the upper left corner outside the form. I searched, but couldn't find a working way to get the mouse coordinates not for the whole screen, but only for the form, so that the selection form will displayed correctly. I use this code for the Main Form's MouseDown event:
private void OnFormMouseDown(object sender, MouseEventArgs e)
{
select = true;
selectform = new F_selection();
selectform.Size = new Size(4, 4);
selectform.Location = new Point(e.X, e.Y);
selectstart = new Point(e.X, e.Y);
selectform.Show();
}And this code for the MouseMove event
private void OnFormMouseMove(object sender, MouseEventArgs e)
{
int width = 0;
int height = 0;if (select)
{
width = selectstart.X - e.Location.X;
if (width < 0)
{
width *= -1;
}height = selectstart.Y - e.Location.Y;
if (height < 0)
{
height *= -1;
}selectform.Location = new Point(e.X, e.Y);
selectform.Size = new Size(width, height);
}
}Is there a better way to retrieve a number's value, independent from its algebraic sign thn checking if it's < 0 and multiplying with -1? I think in mathematics it was
| x |
. (damn smileys) And would you know how to make it look like the mouse cursor is always at the far edge of the selection form, i.e. if you select something below and left of the current box, it's at the lower left corne