Menu Form Animation

skea

Newcomer
Joined
Nov 25, 2009
Messages
22
Hi folks,
I have an issue and i need some help. i would like to create a menu that scrolls "offScreen" and back like this Screen shot Utility by Arman. the source files are in VB.NET but i had to convert the what i think is the necessary code to C#.
i have got something working but It's giving me hardtime to keep the form with bottom pixel at the screen top and unhiding it(hide and unhide it). I have attached something.
Please take a look at it.
Any help will be appreciated. thanks.
 

Attachments

This code seems to work as far as keeping the edge on-screen:
Code:
private void MenuTimer_Tick(object sender, EventArgs e) {
    const int distanceOnScreen = 1; [COLOR="Green"]// Possible problem. Try 4.[/COLOR]
    int finalPosition = Screen.PrimaryScreen.Bounds.Top - this.Height + distanceOnScreen;
    if (this.InstantMenu) {
        if (this.Top > finalPosition) {
            this.Top -= 1;
        } else {
            this.MenuMotionOn(false, true);
        }
    } else {
        if (this.Top > finalPosition) {
            this.Top -= 1;
        } else {
            this.MenuMotionOn(false, true);
        }
    }
}
One problem here is that you are showing your form in the MouseEnter event. This event is raised when the mouse enters the client region, which does not include the borders or title bar. You either need to leave more of the form on the screen (see the comment in the code) or get rid of the border (or detect the mouse another way).
 
Back
Top