Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Menu handler is 0 for Explorer folder main menu
#1
Not Solved Toungue 
Hi,

Can anyone help me to find out why handler to the context menu is 0 for Windows Explorer folder’s main menu.
Let’s say you open My Documents folder and it is necessary to get File->New->Folder item state (if it is enabled or disabled).

Below is part of code from the book (p. 41) http://www.scribd.com/doc/6678471/Codes, which really works for WordPad, but when I try to do the same for Win Expl folder – FileMenuHandle is 0

Code:
Extern.Declare micLong,"GetMenu", "user32.dll", "GetMenu",micHwnd
Extern.Declare micLong, "GetSubMenu", "user32.dll", "GetSubMenu", micLong, micInteger

‘// My Documents should be opened
strWin = "My Documents"
Window("regexpwndtitle:="&strWin).Activate
wait 1

' Get the Handle of the window.
WinHandle = Window("regexpwndtitle:="&strWin).GetROProperty("hwnd")  

' Window("regexpwndtitle:="&strWin).WinToolbar("regexpwndclass:=ToolbarWindow32","windowstyle:=1442895949") ‘// menu bar where actually main menu is located

' Get Handle Of Main Menu ( e.g File, Edit, View. etc )
MenuHandle = Extern.GetMenu ( WinHandle )

' Get Handle Of "File" Menu ( 0= File, 1=Edit, 2=View etc )
FileMenuHandle = Extern.GetSubMenu ( MenuHandle, 0 ) ‘// And here I get “0”
Reply
#2
Not Solved
I guess it wont work until unless you click on the Menu of which submenu you want to get the handle.
Try to click the menu and then get the submenu handle.

let me know if it works.

Reply
#3
Not Solved
Thank you a lot for the idea, but it looks like it is not the cause of the problem:
1. If I run this part of code WordPad it retrieves all handlers successfully
' Get the Handle of the main window. Make sure you launch wordpad.exe before you run this example (insted of folder window)
WinHandle = Window("title:=.* - WordPad", "index:=0").GetROProperty("hwnd")

2. I click on File menu (and still the problem is the same)
Window("regexpwndtitle:="&strWin).WinToolbar("regexpwndclass:=ToolbarWindow32","windowstyle:=1442895949").Press "&File"

My guess here is that the problem is because of objects hierarhy (our menu context is on the menu bar) and it seems that MenuHandle = Extern.GetMenu(WinHandle) is not the handler to the main menu.
When I try to spy the menu the handler is not the same I get from the script Sad

What do you think about this? Will be really appreciate any thoughts.
Reply
#4
Not Solved
Yes you are right Andriana, these menus are implemted as toolbarwin32 class. As this is not a standard menu, it can not be handled using GetMenu API. may be using WM_INITMENU will help. I will just check and get back.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to perform click operation on MDI menu/sub menu (Infragistics) with UFT 12 Mahen1108 0 3,449 06-17-2015, 05:29 PM
Last Post: Mahen1108
  Problem with menu object (UFT) Marta79 4 4,145 05-07-2015, 12:44 PM
Last Post: Marta79
  QTP 11 is not working for Internet Explorer 10 Niraj 5 10,113 08-14-2013, 01:34 PM
Last Post: Niraj
  Explorer Crash - when UFT 11.5 is open sriramb 2 3,769 07-08-2013, 05:18 PM
Last Post: Ankur
  create drop Down list or menu in qtp abansal 0 3,936 09-07-2012, 05:36 PM
Last Post: abansal

Forum Jump:


Users browsing this thread: 1 Guest(s)