General Questions

NJDubois

Well-known member
Joined
May 15, 2008
Messages
84
Programming Experience
Beginner
I have the buttons in my menu's generated at run time. And for sub menus, I create a form at run time, and add buttons to that form.

Here are my questions.

First, I have the forms just big enough to show the buttons in the menu, but I want the forms to auto hide when the mouse is not over after x amount of time. LostFocus does not appear to do anything, and MouseLeave works when the mouse is last over the form its self, but because the button left and width are aligned with the left and right of the form, I would have to write code to consider the buttons as well. Is there an easier way to determine when the user is no longer with in the menu? I was hoping that I could do something like My.Screen.mousemove But no such luck.

My next question, working with forms created at run time. When the user clicks on a menu item that has a sub menu, another form is created as already stated. When one of these forms is closed, does it no longer exist? Or is it still somewhere in memory? That being asked, is it better to have the menu hidden, or unloaded completely. I would think that leaving them all hidden would be a resource hog, while closing them and re-loading them every time the user wants something might delay the menu from displaying for a few seconds.

Next question. How do I work with a runtime created form? Say I wanted to mark its .visible as false?

I do this when I create a new sub menu

Sub draw_menu()
Dim aForm AS NEW Form

aForm.Name = "frm_Main"
aForm.Text = "Hello World"
aform.Show()

-insert code that add's buttons-
End Sub

but in another sub used to determine when and if the user is not in the menu
aForm.visible = false
obviously isn't going to work.

So I have the main menu, a sub menu, and another sub menu under that. The user leaves the last sub menu. How do I -in code- refer to that form?

This is the only forum I go to when I have a question. Everyone here has been very helpful and, I thank you all for taking the time to read this post and help guide me in the ways of vb.net!

Nick
 
Have you considered working with the standard ContextMenuStrip ?
 
Back
Top