Rizluak, your tray menu example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Roboblue
    Forum Member
    • Dec 2003
    • 892

    Rizluak, your tray menu example

    See if this works for you and get back to me.
    Menus populated from image files from folder
    Right Click Tray menu popup.
    On button event Popup
    Right Click on App window popup
    Attached Files
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    #2
    Wow robo, i cant thank you enough for this, cheers :yes
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    • bobbie
      Forum Member
      • Feb 2005
      • 770

      #3
      Just for fun I added a image to the page and it loads the image from the menu to the image on the page.
      Attached Files

      Comment

      • RizlaUK
        Indigo Rose Customer
        • May 2006
        • 5552

        #4
        hey robo, i got a error when i click exit or restore on the tray menu, on line 45,
        argument 1 must be a type of string

        44.pFile = tImages[nTrayMenu]
        45.File.Open(pFile, "", SW_SHOWNORMAL);

        i just cant figer it, only happend on exit and restore, images load fine
        Embrace change in your life, you never know, it could all work out for the best

        Comment

        • Roboblue
          Forum Member
          • Dec 2003
          • 892

          #5
          While I was testing, I forgot to set the limit of ID's to look for the other menu items besides the Images menu
          this
          Code:
          if nTrayMenu >= 1 then
          should be this
          Code:
          if nTrayMenu >= 1 and nTrayMenu < 3000 then
          try it again
          Attached Files

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5552

            #6
            Yup, that got it, Cheers Robo :yes

            this app is coming along nicely now

            for anyone else thats useing this code:

            in the "PopupMenu()" function

            change this
            nTrayMenu = Application.ShowPopupMenu(X, Y, tblMenu, TPM_RIGHTALIGN, TPM_BOTTOMALIGN, true, false);
            to this
            SMouse = System.GetMousePosition(true);
            nTrayMenu = Application.ShowPopupMenu(SMouse.X, SMouse.Y, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true);
            and the menu will appers where the mouse is like a proper right context click menu
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            • Roboblue
              Forum Member
              • Dec 2003
              • 892

              #7
              Darn it, I had to do that once. I forgot about that.
              Now, if you do what Rizluak showed above, you can't use the same Popupmenu Function for all the popups. You would have to have two different functions to do an event and a Right click
              Here is a way to use the PopupMenu() for both the right click in window AND an event like a button click.
              in the Global, replace the Popupmenu function with this
              Code:
              function PopupMenu()
              ImagSubMen()
                ---Main Menu
                 tblMenu = {};
                 tblMenu[1] = {};
                 tblMenu[1].Text = "Images";
                 tblMenu[1].ID = 100;
                 tblMenu[1].Checked = false;
                 tblMenu[1].Enabled = true;
                 tblMenu[1].SubMenu = tblPopUp2;
                    
                  if isRC == 1 then
                  SMouse = System.GetMousePosition(true);
                  nTrayMenu = Application.ShowPopupMenu(SMouse.X, SMouse.Y, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true); 
                  isRC = 0
              	else
                  nTrayMenu = Application.ShowPopupMenu(e_X, e_Y, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true); 
                 end
               ---depending on how many files are in the images table (tImages) set
               ---any other Menu ID to be above expected number
               ---Set in the Main Menu above, and on the action call below
               ---here, to be safe, I am using 3000 and hope there's not more
               ---than 2999 images in the folder   
                if(nTrayMenu ~= -1)then  
               	if nTrayMenu >= 1 and nTrayMenu < 3000 then
               	---use nTrayMenu to get the file path from the images table (tImages)
               	---created in the ImagSubMen() function above.
                	pFile = tImages[nTrayMenu]
               	File.Open(pFile, "", SW_SHOWNORMAL);
              	end
               end
               end
              and on the Page-On Mouse event
              replace what's there with this
              Code:
              if(e_Type == RIGHT_BUTTON_DOWN)then
              isRC = 1
              PopupMenu()
              end
              This will not work with the Tray right click as it is a function, itself.

              Comment

              • RizlaUK
                Indigo Rose Customer
                • May 2006
                • 5552

                #8
                OK, i got another neat trick for you guys to customize this example a little more

                to dynamicly change the "Restore" text to "Maximize" and have the function change as required,

                find this bit of code in globals
                tblMenu[2] ={};
                tblMenu[2].Text = "&Restore";
                tblMenu[2].ID = 3000;
                tblMenu[2].Checked = false;
                tblMenu[2].Enabled = true;
                and change it to this
                local WindowState = DLL.CallFunction(_SystemFolder.."\\user32.dll", "IsWindowVisible", Application.GetWndHandle(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
                WindowState = String.ToNumber(WindowState);
                if WindowState == 0 then
                tblMenu[2] ={};
                tblMenu[2].Text = "&Maximize";
                tblMenu[2].ID = 3000;
                tblMenu[2].Checked = false;
                tblMenu[2].Enabled = true;
                else
                tblMenu[2] ={};
                tblMenu[2].Text = "&Minimize";
                tblMenu[2].ID = 3000;
                tblMenu[2].Checked = false;
                tblMenu[2].Enabled = true;
                end
                then find this line of code
                elseif(nTrayMenu == 3000) then
                Application.Restore();
                and change it to this
                elseif(nTrayMenu == 3000) then
                if WindowState == 0 then
                Application.Restore();
                else
                Application.Minimize();
                end
                or just download the edited example
                Last edited by RizlaUK; 02-01-2009, 11:35 AM.
                Embrace change in your life, you never know, it could all work out for the best

                Comment

                • Roboblue
                  Forum Member
                  • Dec 2003
                  • 892

                  #9
                  Pretty good
                  You can do a lot of stuff with the menu's as long as you don't put something in that stops the code.
                  The limitations are the statements that the AMS internal menu functions have to see to create the menus.
                  Text
                  ID
                  Enabled
                  Checked
                  Submenu
                  Wait for Return
                  and add these for Popups
                  Position (X-Y)
                  Alignment
                  Client Coordinates

                  A few more would be nice, like
                  Icons
                  Text properties
                  Multi variable outputs (like adding the parent ID to submenu ID to make it easier to call submenus dynamically created)

                  Think of anymore?
                  Last edited by Roboblue; 01-18-2007, 10:17 AM.

                  Comment

                  • RizlaUK
                    Indigo Rose Customer
                    • May 2006
                    • 5552

                    #10
                    well, some kind of icon support in the tray menu is something iv wanted for a while, i think its been subbmited to the suggestions database

                    i have an idea for a app but it just wont work without tray icon support, i was going to make it with something else but ams is just so easy to work with that i dont realy want to use anything else

                    the only other thing i want out of the tray menu right now is the abilty to add a "seperator", iv been "------------" but it still highlights like its going to do something and it looks ulgy
                    Embrace change in your life, you never know, it could all work out for the best

                    Comment

                    • Roboblue
                      Forum Member
                      • Dec 2003
                      • 892

                      #11
                      Originally posted by RizlaUK View Post
                      the only other thing i want out of the tray menu right now is the abilty to add a "seperator", iv been "------------" but it still highlights like its going to do something and it looks ulgy
                      Just use three "---"
                      That will tell it to use all available space.

                      I would also like to see customizable borders around the menu
                      Last edited by Roboblue; 01-18-2007, 01:29 PM.

                      Comment

                      • bobbie
                        Forum Member
                        • Feb 2005
                        • 770

                        #12
                        Little icons for each app in the menu would be nice .

                        Comment

                        • RizlaUK
                          Indigo Rose Customer
                          • May 2006
                          • 5552

                          #13
                          wow, that tidyed my menus up a bit, great tip :yes

                          yeah, customizable borders would be cool, and background images (think im asking to much there, lol)


                          Little icons for each app in the menu would be nice .
                          yeah, i agree, that would be awesome
                          Embrace change in your life, you never know, it could all work out for the best

                          Comment

                          • bobbie
                            Forum Member
                            • Feb 2005
                            • 770

                            #14
                            Like this how they have it in true launch bar.
                            Attached Files

                            Comment

                            • jfxwave
                              Forum Member
                              • Mar 2006
                              • 145

                              #15
                              With the help of worms mouse dll we can right click and the menu will show up next to the mouse.
                              Attached Files

                              Comment

                              Working...
                              X