Link to home
Start Free TrialLog in
Avatar of furmiga
furmiga

asked on

Forcing a specific menu to show (no listed in process)

Hi guys, I found a interest program that alow me to see some resources of another programs.

normaly, the resources are listed in a process viewer like WinSight32 and others but in this specific program, there is a menu (popup menu) that I can see in the resource program but when it is running, it is not listed in the process viewer (not even hidden).


The menu, in the resource program is listed as:

+Cursor
+Icon
-Menu
    |__109
    |    |__0 <-- this is the menu i want to show* (code listed below)
    |__227
    |    |__0
    |__1315
         |__0
+Dialog
+...
+...

*
109 MENU
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
   POPUP "Check"
   {
        MENUITEM "Check the Rendered Equip Image...",  110
        MENUITEM " Check Frame.",  32772
        MENUITEM "Change Color",  32775
        MENUITEM "Chage Font( \"font.ini\" )",  32889
        MENUITEM SEPARATOR
        MENUITEM "Check the Wrong Tile Attr.",  32807
        MENUITEM "Right Mouse Button",  32811
   }
   POPUP "Event"
   {
        MENUITEM "Event View",  32773
        MENUITEM SEPARATOR
   }
... And so on
}

I was wondering if there is a chance to locate this resource and then force it to show like using a sendmessage or whatever.


ty in advance
Avatar of furmiga
furmiga

ASKER

I already deleted the Delphi one. increassed this one. Srry about breaking the rules.
Avatar of jkr
No problem. Thanks for fixing that yourself. BTW, there's nothing wrong with posting a 20pts pointer question in the Delphi TA with a link to this one here.
Avatar of furmiga

ASKER

thanks for the tip man !

btw, don't you have any idea how do i open this "in code" menu ?
Well, I do have an idea about displaying/inserting such a menu using the usual Win32 paths, but: Why? If the target app does not have command handlers that are responsible for executing the commands bound to the menu entries, that keeps me scratching my head...
Avatar of furmiga

ASKER

All i want is activate the menu, using  another program or injecting a code to force it to open. The menu is a normal menu "file - etc - etc - about" but this menu only exists inside the EXE. It never shows. When you use some resource app you can see the menu inside it but, again, it never really shows. The app don't allocate handlers for the menu either. I'm just wondering if there is a possibility to show this menu (or inject a code to force it to open). There is no possibility to change the code in the app since all i have is it's executable.
In C++, you can do the following to show the menu as a popup menu:

HMENU menu = LoadMenu(hInstance, MAKEINTRESOURCE(109));

TrackPopupMenuEx(menu, TPM_RIGHTBUTTON, 100, 100, hwnd, NULL);

Let hwnd be the handle to the window that you want to own the window, and let hInstance be the handle to the module (dll or exe) that contains the menu resource.

This will create the menu at 100 pixels down and the the right of the top left (I think).
Avatar of furmiga

ASKER

I guess we are almost there griffin, but its not happening when I change hwnd to anything diferent then my own handle.

here the code:

var
  Form1: TForm1;
  menu1 : HMENU;
  wnd  : HWND;
implementation

{$R *.dfm}
{$R Menu_109.res}

procedure TForm1.Button1Click(Sender: TObject);

begin
  wnd := FindWindow('TheProgram',nil);
  menu1 := LoadMenu(HInstance,MAKEINTRESOURCE(109));
  showmessage(inttostr(wnd));
  TrackPopupMenuEx(menu1, TPM_RIGHTBUTTON, 100, 100, wnd, nil); // if I change "wnd" to "application.handle", that means, my own handle, the menu works fine.
end;
When the TrackPopupMenuEx fails, could you call GetLastError() and post the return value here to see what the problem is?

Also, try adding TPM_NONOTIFY to the flags, which will prevent the menu from sending messages to its owner, and that might be worth a shot is the application is intentionally not showing it.
Avatar of furmiga

ASKER

TPM_NONOTIFY didn't change anything

GetLastError returns only 0 :( well, if I turn the program off and try to open the menu, it return 1401 guess it's working lol.

Another thing. The menu shows like a little vertival bar with no names. only when you pass the mouse over this little bar the itens come.
That's strange behavior. It's possible the program is altering that particular menu resource, which would explain why it doesn't show up in the process viewer.

One final thing I'd try if you're really trying to coax out that menu is to use LoadLibrary to manually load the program into memory without executing it, then load the menu from there. Again, in C++:

HMODULE hModule = LoadLibrary(progname); // progname should be the string specifying the program's location

HMENU menu = LoadMenu(hModule, MAKEINTRESOURCE(109));

Also, FreeLibrary(hModule) when you're done.
I just was reviewing a program where I used TrackPopupMenuEx and I noticed that I called

SetForegroundWindow(hwnd);

before TrackPopupMenuEx and

PostMessage(hwnd, WM_NULL, 0, 0);

afterwards, where hwnd is the owner window for the menu. That might be necessary for a properly functioning popup menu.
Avatar of furmiga

ASKER

damn... not working... and in my program it just blinks.

Lemmi ask you something:

Is it possible to:

program1 - mine
program2 - the one I want to change

1 - copy the menu I want from program2 by loadLibrary or just adding a .res
2 - make a normal TmainMenu in program 1 and load the menu to it (from the resource)
3 - Load the program2 inside program1 (like a frame in HTML) - Both will be working
4 - Try to send menu messages to the program2

Is it possible ?
ASKER CERTIFIED SOLUTION
Avatar of griffin36
griffin36

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have just verified that indeed, SetParent does work on windows from different applications, so my note of warning at the bottom of the last message is unnecessary.