I want to control an external program from Delphi, so I spawn a process using CreateProcess. Based on ideas I adopted from Neil Rubenking, I then create a menu tree using TTreeView. The items in this tree are clickable, and clicks can also be emulated by me sending keyboard events (menu shortcuts) to the external application. So far all is good. I now want to set up the external program to run in batch. One way that the external program communicates with the user to inform that it is ready for new input is by flashing info to screen, but this is probably hard to catch from Delphi. Another way is that different menu items are grayed out when data are processed and when the external program can accept new data.

My question is: How can I, from inside my Delphi application, read off the flag that holds information about the state of the various menu items of the external program. I have access to the ProcessID and a WndHandle to the external program, and I can reach the menu items from my TreeView i Delphi.

Peter (Peter.Juhlin@LSN.se)

Usually you can read it with GetMenuState or GetMenuItemInfo (and set with the SetXxx counterparts). But I'm not sure you can use this cross-process.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.