short int ypos = 8;
short int xpos = 27;
short int down_message = WM_LBUTTONDOWN;

LRESULT mouse;
mouse = SendMessage( tv_handle, WM_MOUSEACTIVATE, (WPARAM) mainwindow_handle, down_message << 16 | 1 );

mouse = SendMessage( tv_handle, WM_LBUTTONDOWN, MK_LBUTTON , ypos << 16 | xpos ); /**** Hangs on this call, until mouse enters main window area */
printf( " Mouse Down %d\n" , mouse );

mouse = SendMessage( tv_handle, WM_LBUTTONUP, MK_LBUTTON , ypos << 16 | xpos );
printf( " Mouse up %d\n" , mouse );

mouse = SendMessage( tv_handle, WM_MOUSELEAVE, 0, 0);
printf( " Mouse leave %d\n" , mouse );

----------------------------------------

I am new to win32 programming.
The code above is an experiment with automating windows. This code runs from a seperate process ( a console app ). It uses FindWindow() to find the main window handle, then uses EnumChildWindows() to inspect the main windows contents.
I am trying to set/unset a checkbox in a SysTreeView32. The target application is a wxWindows app. I found the relative x,y positions by using MS Spy++. These messages are trying to simulate the messages I see when clicking the checkbox.

I've tried TreeView_SelectItem() and TreeView_SetCheckState() with no luck.

Does anybody know why the call commented above might hang until the mouse moves over the window? I'm at my end.

Thanks,
wil