Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get a window handle (hWnd)
Message
From
21/04/1998 09:33:51
 
 
To
21/04/1998 01:24:37
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00093155
Message ID:
00093639
Views:
33
>>>>>I'd like to know how to get a window handle (hWnd) in order to pass to Win32 API from VFP 5.0a.
>>>>>
>>>>>The below C-code is what I've been read from one of the thread:
>>>>>
>>>>>void GetObjectWHandle(ParamBlk *parm)
>>>>>{
>>>>> HWND hWnd;
>>>>> MHANDLE mhWnd;
>>>>>
>>>>> mhWnd=_WGetObjectWindow(&(parm->p[0].val));
>>>>> hWnd=_WhToHwnd(mhWnd);
>>>>> _RetInt((LONG)hWnd,8);
>>>>>}
>>>>>
>>>>>Then, what is the parameter type sould be specified in the FoxInfo ?
>>>>>
>>>>>FoxInfo myFoxInfo[] = {
>>>>> {"GETHWND",(FPFI) GetObjectWHandle, 1, "I"},
>>>>>};
>>>>>
>>>>>Once the .Fll have been created, what should I pass to it from a VFP form ?
>>>>>
>>>>>In Visual FoxPro:
>>>>>
>>>>>Set library to fll.fll
>>>>>hWnd=GETHWND(Thisform) && doesn't work, type miss match
>>>>>
>>>>>hWnd=GETHWND(_screen.activeform) && doesn't work. 'ACTIVEFORM' is not && an object
>>>>>
>>>>>Thanks in advance.
>>>>
>>Hi,
>> Your code will work with a couple of changes.
>>#1. Specify the parameter type as "O" for object reference in FoxInfo. This will stop your type mismatch errors.
>>#2. If I remember correctly, _RetInt() truncates large #'s such as window handles.
>>I use the following construct instead.
>>_RetFloat((double)(UINT)lhwnd, 20, 0);
>>where lhwnd is the variable that holds the object handle to be returned.
>>
>>Hope this helps,
>>Ned
>
>
>Well, if this is the case, I'd like to know how to pass the form object to the API function.
>
>hWnd=GETHWND(_screen.activeform)
>or
>hWnd=GETHWND(This)
>
>Thanks for your response.

Just pass in an object reference, GETHWND(_SCREEN) should return the handle to VFP's main application window. Check out _WGetObjectClientWindow() if you want handles for child windows. What Win32 API calls do you want to make anyway?
Ned

Reality is.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform