MiniMenu.dll, a context menu for the device.

Discussion in 'Additional Libraries' started by taximania, Feb 22, 2009.

  1. taximania

    taximania Well-Known Member Licensed User

    I know that FormLib.dll has a contextmenu in it,
    But this is short and neat and may be of interest to someone.

    mini.New1("?")
    '?' is any object in your app. Form1, Label1, Textbox1 etc.

    The contextmenu has 3 items in it.
    The default text for the items can be read or changed by
    the relevant mini.Item'x'text method.

    sub mini_PopUp is fired before the menu is displayed,
    but after the menu has been initiated, 'right click or
    stylus touch on the 'control' defined in the New1("?")

    Hence the use of the timer1 in the Sub mini_PopUp

    If a menu item is not clicked,
    mini.RespText returns the string "null"
    mini.RespValue returns the int 0

    If the menu is clicked,
    mini.RespText returns the 'preset' or 'set' text for the Item
    mini.RespValue returns the 'preset' Int for item, 1 - 3.



    Code:
    Sub Globals
       
    'Declare the global variables here.
    End Sub

    Sub App_Start
       Form1.Show
       mini.New1(
    "Form1")
    End Sub

    Sub mini_PopUp
    timer1.Interval=
    2000
    timer1.Enabled=
    True
    End Sub

    Sub Timer1_Tick
    timer1.Enabled=
    False
    Msgbox(mini.RespText,mini.RespValue)
    End Sub
    Ive added the .dll, .sbp source example and the Class1.cs C# file.

    @whoever knows, how do I get the MenuItem.Click event to work :confused:
     

    Attached Files:

    Last edited: Feb 23, 2009
  2. agraham

    agraham Expert Licensed User

    Get rid of that timer! I haven't run this but it looks OK to me. I put an extra txt extension as I couldn't be bothered to zip it.
     

    Attached Files:

  3. taximania

    taximania Well-Known Member Licensed User

    Timer gone, many thanks AGraham, :icon_clap: new working lib in 1st post.

    'sub mini_Click' now returns the selected menu item.

    Edit: As an afterthought, the mini_Popup event is still triggered before the menuitem
    options are shown. I'll leave it there for now. You don't have to use it.
    At least you have the option to know a menu item can be selected before it actually is ;-)

    Now for the biggie >> ?? :sign0060: Watch this space :sign0082:
     
    Last edited: Feb 23, 2009
  4. agraham

    agraham Expert Licensed User

    It's better than that. In the Popup event you can change the menu item text, add new menu items etc. It is an opportunity to tailor the context menu to the present situation rather than having to do it pre-emptively in advance.
     
  5. taximania

    taximania Well-Known Member Licensed User

    I've just realised the code you translated for me doesn't use the
    Show(this, contextmenu bla bla bla) bit of code.
    I'm sure it existed in my original code, what fires the menu to display ?

    I haven't got a copy of my original code to look what I had wrote !
    I overwrote? it with your working code :sign0148:
     
  6. agraham

    agraham Expert Licensed User

    You did have the following but I removed it as it did nothing because you hadn't added it to the Form MouseDown event and it's not needed anyway.
    Code:
    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        
    if (e.Button == MouseButtons.Right)
        {
            mnu.Show(frm, new 
    Point(e.X, e.Y));
        
    }
    }
    The users' right click, you just get called along the way as long as you have added the events. Show lets you display a ContextMenu by other means, such as a button press, if you want to.
    Tut!
     
  7. taximania

    taximania Well-Known Member Licensed User

    Tut!

    Now that's a lesson for all of us. Save a copy of your code if it partially works or not.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice