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:

    |    |__0 <-- this is the menu i want to show* (code listed below)
    |    |__0

109 MENU
   POPUP "Check"
        MENUITEM "Check the Rendered Equip Image...",  110
        MENUITEM " Check Frame.",  32772
        MENUITEM "Change Color",  32775
        MENUITEM "Chage Font( \"font.ini\" )",  32889
        MENUITEM "Check the Wrong Tile Attr.",  32807
        MENUITEM "Right Mouse Button",  32811
   POPUP "Event"
        MENUITEM "Event View",  32773
... 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
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.

furmigaAuthor Commented:
I already deleted the Delphi one. increassed this one. Srry about breaking the rules.
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.
furmigaAuthor Commented:
thanks for the tip man !

btw, don't you have any idea how do i open this "in code" menu ?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

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...
furmigaAuthor Commented:
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).
furmigaAuthor Commented:
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:

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

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

procedure TForm1.Button1Click(Sender: TObject);

  wnd := FindWindow('TheProgram',nil);
  menu1 := LoadMenu(HInstance,MAKEINTRESOURCE(109));
  TrackPopupMenuEx(menu1, TPM_RIGHTBUTTON, 100, 100, wnd, nil); // if I change "wnd" to "application.handle", that means, my own handle, the menu works fine.
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.
furmigaAuthor Commented:
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


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.
furmigaAuthor Commented:
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 ?
I'll answer this number by number.

1 - This should be no problem at all if you just use a .res file, but make sure that you won't have any overlapping in the menu id's. Using loadLibrary would be more complicated.
2 - Again, shouldn't be a problem (remember there can't be overlapping id's).
3 - For this one, you need to do a few things:
Get the window handle for program2's main window.
Call SetParent(program2hwnd, program1hwnd).
Then, add WS_CHILD style to program2's window:
SetWindowLong(program2hwnd, GWL_STYLE, GetWindowLong(program2hwnd, GWL_STYLE) | WS_CHILD);
Finally, adjust program2's position using SetWindowPos and maybe show the window using the SWP_SHOWWINDOW flag so it is visible in program1.
4 - I would say, when you process the WM_COMMAND message, then if (HIWORD(wParam) == 0) you should PostMessage to program2's window with the exact same message.

Note: According to MSDN Library, SetParent will not work if the two windows do not belong to the same application. It might work anyway, I seem to remember it working for someone before. Otherwise, another option would be to call LoadLibrary on program2, then creating a new thread and launching program2 in the thread by calling it's WinMain function, effectively turning the other program into a part of your program. This last bit is all speculation, though; I don't know if it's actually possible to launch a program in a thread like that.

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
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.
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
Microsoft Development

From novice to tech pro — start learning today.