>>You might want to ignore my previous. If you're using MainhWnd(), then you're using Foxtools. In order to get the window handle of a given form, all you need are the functions I mentioned in the other post: _WhTohWnd() and _WFindTitl().
>
>Thanks, George; I hadn't considered them, but it looks like they might work (for Forms in _SCREEN).
You're welcome, Gerry. I've never seen the functions fail (except under the circumstances described below). They work for top-level forms also.
>>You mentioned that you use an underscore in to indicate a custom property. In keeping with that, the following, in a form's Init event will store its window handle to h_window:
This.h_window = _WhTohWnd(_WFindTitl(This.Caption))
The only thing you need to be careful of are forms with the same caption. This will cause the wrong value to be store in occurrences of the form after the first one. If that's a possibility, then an API based solution might be
>required.
>
>I'll evaluate both techniques and decide which is best under the circumstances (including VFP versions). To insure a unique Caption, I guess one can always flip it temporarily to something generated.
>
>As far as the "main VFP window handle" that can be used for "drawing", I had to resort to this to get the proper handle:
>
>
>IF VERSION( 4 ) = "07"
> _SCREEN.H_Window = _SCREEN.hwnd
>ELSE
> _SCREEN.H_Window = GetWindow( MAINHWND(), GW_CHILD )
> _SCREEN.H_Window = GetWindow( _SCREEN.H_Window, GW_HWNDLAST )
>ENDIF
>
That's exactly what I was going to suggest. If you decide to go with API calls, I'd suggest using a combination of FindWindowEx() and the form captions. While I haven 't tested it (yet) it should work fine.
George
Ubi caritas et amor, deus ibi est