Main Menu auto dropdown

Hi Guys,

Do you know how to create a program that will dropdown the MainMenu, automatically with Item selected specifically.

Please let me know

thanks in advance
HifigerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HifigerAuthor Commented:
example:

      Main menu                                   Button1.Onclick(sender:tobject)
           ... entry                                   begin     Mainmenu.dropdown
           ... edit                                         Mainmenu.dropdown
           ... delete                                      Mainmenu.select (item) = true
                                                         end;



      I don't know I how to do it in delphi that will click the button and the Menu will just dropdown
      and at the same time the item will be selected.

      Please help thanks

     
RadikalQ3Commented:
Hi,  Hifiger

procedure TForm1.Button1Click(Sender: TObject);

  procedure DropMenuAndSelectItem(MainMenuItemIndexAccel,ItemIndex:integer);
  var
    n : integer;
  begin
    //Activate MainMenu
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), 0, 0 );
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), KEYEVENTF_KEYUP, 0 );

    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), 0, 0 );
    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), KEYEVENTF_KEYUP, 0 );

    //Select MainMenuItem
    while (MainMenuItemIndexAccel>0) do begin
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), 0, 0 );
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), KEYEVENTF_KEYUP, 0 );
      Dec(MainMenuItemIndexAccel);
    end;

    //Select SubItem
    while (ItemIndex>0) do begin
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), 0, 0 );
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), KEYEVENTF_KEYUP, 0 );
      Dec(ItemIndex);
    end;
  end;
begin
  //Drop and select second item of the first MainMenuItem
  DropMenuAndSelectItem(0,2);
end;
RadikalQ3Commented:
Sorry, third Intem in the example (count begins in 0)
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

RadikalQ3Commented:
Again... (too many rums tonight...)

procedure TForm1.Button1Click(Sender: TObject);

  procedure DropMenuAndSelectItem(MainMenuItemIndex,ItemIndex:integer);
  var
    n : integer;
  begin
    //Activate MainMenu
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), 0, 0 );
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), KEYEVENTF_KEYUP, 0 );

    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), 0, 0 );
    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), KEYEVENTF_KEYUP, 0 );

    //Select MainMenuItem
    while (MainMenuItemIndex>0) do begin
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), 0, 0 );
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), KEYEVENTF_KEYUP, 0 );
      Dec(MainMenuItemIndex);
    end;

    //Select SubItem
    while (ItemIndex>0) do begin
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), 0, 0 );
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), KEYEVENTF_KEYUP, 0 );
      Dec(ItemIndex);
    end;
  end;
begin
  //Drop and select third item of the first MainMenuItem
  DropMenuAndSelectItem(0,2);
end;
HifigerAuthor Commented:
Hi RadikalQ3 ,

Yes, It works by clicking the button and the menu drops down. But what I mean, was how can I select a certain item... example I will going to select the 2nd item, what are the codes needed inorder for the item to be highlighted? : )
HifigerAuthor Commented:
example:

      Main menu                                   Button1.Onclick(sender:tobject)
           entry                                       begin    
           edit                                             MainMenu.('Edit').selected:=True
           delete                                      
                                                         end;



How do we do it, from your code?
RadikalQ3Commented:
An example of MainMenu:

File            Edit          Quit
-Open    
-Save
-Close

If you want DropThe MainMenu with File-Save Item Selected, then:

DropMenuAndSelectItem(0,1);  //0 for File, and 1 for File-Save Item...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HifigerAuthor Commented:
ops! yes, it was located at the bottom of your source code.

Thanks
RadikalQ3Commented:
too many rums too? jeejeje
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.