Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is the easiest way to get Window handle value?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00051377
Message ID:
00052085
Views:
75
George,

All I was trying to do originally was to get a handle (hWnd) to a
form that I could feed to a DLL call to point to where the display
output of my Video Capture card was shown in...

After many tries to get just a regular handle to a form/window,
it looks like MS is not supplying that information to us for VFP.

It looks like I'm going to have to try using the FoxHWnd control
as my capture window....That will probably work....

As for the SetFocus() Win32 API call, I was just using it to test if
I had the correct Window Value...Being that that didn't work, I had
to Get the title to see which window handle it pointed to...
I think MS doesn't want us to get to that low of a level and just
make everyone do OOP...


Apparently the only valid Window handles you can get for VFP are the
Main Window and Form windows.....All the other controls are handled
in a different manner in VFP.....(Some kind of a bitmap thing...I don't
know the details..)

As I said before, the only call that gets the correct handle for a
Define Window is the GetWindow call...

I wonder if VBasic and VC++ are destined to go this route or what...


Jon
(Thanks for all your work on this issue....)
---------------------------------------------



>>George,
>>
>>That's the problem....Maybe I didn't make myself clear on that point...
>>
>>If you define two windows and get the correct handle # for the first
>>while positioned in the second, SetFocus(hWnd1) will not reset the
>>focus....
>>
>>This can all be done from the command window (or 2 small .prg files)
>>after the Declares for the Win32 API calls....
>>
>>It looks like a bug to me....:)
>>
>>Thanks for double checking....I thought I was going nuts....
>>
>>Jon
>
>Jon,
>
>I'm no longer exactly sure of what it is that you're trying to do, get a window handle for the child or programmatically change the focus. Under the assumption that it's the latter, here's a solution.
>
>You're right about using the SetFocus API call. I've been able to change the focus of a window using it. Here's how:
>
>I dropped a FoxHWnd control on the form. In the form's activate event I assigned the HWnd property to an element in a global array. I created an identical form and did the same thing, simply changing the element number. In the click event of the command button on each form, I called the SetFocus API call, using the element of the array that applied to the other form. I'm sure you get the idea of how to apply this.
>
>As a side note, I previously tried retrieving the window handle using the GetTopWindow API call in the form's Activate event. Surprisingly, the window handles for the two elements of the array were identical. I'd like someone to explain that one to me.
>
>I hope that this will help you solve your problem.
>
>George
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform