Bernhard Hubl Jun 20, 2013
>But you can runYes, that's what we need. In our software we have 35.000 objects in our database including the RA/DE coordinates. So, the idea is that we include a button in our software. Whenever the user clicks on this button the existing instance of Guide is centered on the RA/DE coordinates of the object.
> into trouble if what you want to do is, say, tell Guide to center
> on NGC 3141
--- In guide-user@yahoogroups.com, Bill Gray <pluto@...> wrote:
>
> Hi Bernhard,
>
> > Starting Guide centered on our desired coordinates works already fine.
> > Is there a possiblity that Guide opens only just once? (only one instance).
> >
> > That means if an instance of Guide is already opened and we send a
> > command line then the already existing Guide window should be centered on
> > our desired object and no second Guide window should be opened.
> >
> > Is this possible?
>
> Hmmm... for this, you'd really want something a little different. If
> you simply invoked Guide again, it'll just generate another instance of
> the program; it won't simply affect the existing instance, which is what
> you really want.
>
> For that, what you'd really want would be some sort of interprocess
> communication, i.e., "find thus-and-such window and send it thus-and-such
> message." For simple situations, the following code will suffice. Save
> it as, say, 'xtrol_g.c' and compile it, start up Guide, and run the
> program you've just compiled as
>
> xtrol_g 2204
>
> If you look in the 'toolbar.dat' file, you will see that action 2204
> corresponds to 'center on Mars'. When you run the above, Guide should,
> in fact, recenter on Mars.
>
> The program works by using the EnumWindows function from the Windows
> API. This examines each window; if the window title starts with 'Guide
> 9.0', we assume we have the right one, and send it the command.
>
> You can do a lot with this little code snippet. As you'll see,
> 'toolbar.dat' has a long list of possible commands. But you can run
> into trouble if what you want to do is, say, tell Guide to center
> on NGC 3141, or set the date/time to 2017 Jul 13 02:14:50. Still
> looking into that one... Microsoft suggests nine different methods
> for interprocess communication :
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574%28v=vs.85%29.aspx
>
> The 'data copy' method looks somewhat promising for this situation,
> though I've hit a rough spot or two in it thus far.
>
> -- Bill
>
> #include <windows.h>
>
> BOOL CALLBACK enum_func( HWND hwnd, LPARAM lparam)
> {
> char title[80];
>
> GetWindowText( hwnd, title, sizeof( title));
> if( !memicmp( title, "Guide 9.0", 9))
> PostMessage( hwnd, WM_COMMAND, lparam, 0);
> return( TRUE);
> }
>
> int main( const int argc, const char **argv)
> {
> EnumWindows( enum_func, (LPARAM)atoi( argv[1]));
> return( 0);
> }
>