Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BindEvent, DisplayOrientation
Message
From
17/10/2018 19:37:48
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Application:
Desktop
Miscellaneous
Thread ID:
01662559
Message ID:
01662652
Views:
68
Thank you Borislav.

>>>>Hello all,
>>>>
>>>>My form needs to adjust it's position based on the _screen.DisplayOrientation. It has do so for users using a tablet.
>>>>
>>>>The sad thing is that it looks like there are no alternatives to using TopLevel forms (ShowWindow=2)
>>>>
>>>>Looks like I'll have to learn to manage those top level forms with ShowWindow, HideWindow and the others. Unless someone can tell me how this binding could work with ShowWindow in screen instead of top level.
>>>
>>>
>>>https://msdn.microsoft.com/en-us/library/ms812142.aspx
>>>check VB 6.0 examples, you can translate them easily to VFP.
>>>Use BINDEVENT to WM_DISPLAYCHANGE and handle it :-)
>>
>>Hello Borislav,
>>
>>I never used VB. So perhaps it's easy for you to translate this code but to me it's not. I just hope that someone will be able to help me with fox code.
>>
>>Regards,
>>Denis
>Something like that:
>(not tested)
>
>#define WM_DISPLAYCHANGE 126
>#define GWLP_WNDPROC      -4
>
>
>oHandler = CREATEOBJECT([oEventHandler])
>BINDEVENT(0, WM_DISPLAYCHANGE, oHandler, [WindowProc], 4+1)
>READ EVENTS
>
>DEFINE CLASS oEventHandler AS Custom
>     WndProc = 0
>
>     PROCEDURE Init
>         DECLARE INTEGER GetWindowLong IN win32api INTEGER, INTEGER
>         DECLARE INTEGER CallWindowProc IN WIN32API LONG    lpPrevWndFunc, ; 
>                                                    INTEGER hWnd, ; 
>                                                    LONG    Msg, ; 
>                                                    INTEGER wParam, ; 
>                                                    INTEGER lParam 
>         WndProc = GetWindowLong(_vfp.HWnd, GWL_WNDPROC)
>     ENDPROC
>
>     PROCEDURE WindowProc(hw As INTEGER, uMsg As INTEGER, wParam As INTEGER, lParam As INTEGER)
>     DO CASE
>        CASE uMsg == WM_DISPLAYCHANGE
>             *** Display Orientation is changed
>              IF (lParam % 0x10000) > (lParam \ 0x10000)
>                 *Run the application in landscape, for example:
>              ELSE
>                 *Run the application in portrait, for example:
>              ENDIF
>     ENDCASE
>     m.lnResult  = CallWindowProc(This._VFPWndProc, m.tnHWnd, m.tnMsg, m.tnwParam, m.tnLparam)
>
>    Return m.lnResult
>
>ENDDEFINE
>
*******************************************************
Save a tree, eat a beaver.
Denis Chassé
Previous
Reply
Map
View

Click here to load this message in the networking platform