Who needs a recipe?
Raspberries: crush.
Lemonade: pour.
Drink!!
Seems like I have been through this before. What I want to do is hide and show something, depending on whether the mouse is inside of a certain area. For instance, I have a container of some sort with lots of controls on it. When the mouse is anywhere inside of the container, I want a link to be visible. I can't simply use the MouseEnter/MouseLeave events on the container, because MouseLeave is triggered when the mouse enters a child control and the MouseEventArgs don't say anything about what control is being entered.
I tried several things that turned out to not be very reliable. The method that seems to have turned out reliably is a combination of MouseEnter and MouseLeave events on the container, on its parent container and on its child controls.
In the constructor, wire up the events. (My container wasn't parented at that point, so I had to add a separate check and wire it up on the first MouseEnter detection.) For the parent containers, both MouseEnter and MouseLeave are wired up as "leave" events, because entering the parent is the same as leaving "my" container.
// Set up events for detecting MouseEnter/Leave AddMouseEventsToChildren(this); this.MouseEnter += this_MouseEnter; this.MouseLeave += this_MouseLeave;
And here are the recursive methods to wire up children and parents.
private void AddMouseEventsToChildren(Control parent) { foreach (Control child in parent.Controls) { child.MouseLeave += this_MouseLeave; child.MouseEnter += this_MouseEnter; AddMouseEventsToChildren(child); } } private void AddMouseEventsToParents(Control child) { if (child.Parent != null) { // connect both enter and leave to MouseLeave() child.Parent.MouseEnter += this_MouseLeave; child.Parent.MouseLeave += this_MouseLeave; AddMouseEventsToParents(child.Parent); } }
Finally, here are the events:
Control _parent; void this_MouseEnter(object sender, EventArgs e) { // since we haven't been added to a control at creation... if (_parent == null) { _parent = this.Parent; AddMouseEventsToParents(this); } lnkShowActions1.Visible = true; lnkShowActions2.Visible = true; } void this_MouseLeave(object sender, EventArgs e) { var pos = this.PointToClient(Cursor.Position); if (!this.ClientRectangle.Contains(pos)) { lnkShowActions1.Visible = false; lnkShowActions2.Visible = false; } }
Just because I don't want to have to look this up again. Windows 8's driver signing enforcement prevents installing GBridge's network drivers. I posted how to work around that on gbridge.net forums when I was testing the Windows 8 preview, but their forum is offline now.
This method works for Professional or Home versions.
I finally got a full harvest off of this vine (before birds, etc.) These grapes are pretty sour, if you just pick and eat. And seedy. However, I always thought they might make good jelly or something. So this year, I have lots of grapes to try something.
Basically, the process is:
We have a picnic on July 4 where we are supposed to bring a dish. An hour before the picnic... what should we bring? We have lots of fresh-picked raspberries and that vanilla pudding I got last week. After a few minutes of Google-searching for things that use those two ingredients (no results, except for baked items and stuff of the wrong kind), I am going to make my own recipe for this.
Who needs a recipe?
Raspberries: crush.
Lemonade: pour.
Drink!!
Starting with Windows 7, Windows limits the number of items that can be opened simultaneously. Refer to Microsoft's article Context menus are shortened when more than 15 files are selected.