Tuesday, September 16, 2003

Illustrator: Command locale

I haven't found a way to obtain the commands using the SDK interfaces (I'm talking about menu commands), so I come up with the following idea, I get the hwnd of the main window, ask for the menu handle and get info from it. Pretty simple.

You have to use the ADMWinHostSuite (that's not portable to the Mac side but there is an equivalent ADMMacHostSuite):

ADMWinHostSuite4* sADMWinHost = NULL;
error = sSPBasic->AcquireSuite(kADMWinHostSuite, kADMWinHostSuiteVersion4, (const void **)&sADMWinHost);

And then you can ask for the window:

HWND hwnd = (HWND)sADMWinHost->GetPlatformAppWindow();

Now you have all the things you need, if you call it in the plugin startup you may need to call getparent on that window to obtain the correct window holding the menu, anyway calling it from the plugin startup you will not be able to obtain the command in the correct locale because Illustrator use some sort of identifier in the menu that are translated to the correct values at runtime.

No comments: