Sometimes it’s important to be able to detect if your program has gained or lost focus
For instance I have a Toolbox window in my program which I want to hide when my program doesn’t have focus. Note: I also have a system in place that detects when the Frame receives event:iconized / event:restored and sends a similar hide/unhide message to the toolbox.
Declare at a scope that Frame_WndProc can see
glo:FrameOrigWndProc LONG,AUTO
After you open the AppFrame
glo:FrameOrigWndProc = AppFrame{PROP:WndProc}
AppFrame{WndProc} = ADDRESS(Frame_WndProc)
You will need these equates, if you don’t already have them
LPARAM EQUATE(LONG)
LRESULT EQUATE(LONG)
HANDLE EQUATE(LONG)
HWND EQUATE(HANDLE)
UINT EQUATE(UNSIGNED)
The prototype for the Frame_WndProc
MAP
MODULE('Frame_WndProc.clw')
Frame_WndProc( HWND xHWND, UINT xMessage, WPARAM xWParam, LPARAM xLParam),LRESULT,PASCAL
END
END
The Replacement WndProc will need to call CallWindowProc (see module filename above in the map)
MEMBER('YourGlobalModule') !<--- change this
MAP
CallWindowProc(LONG lpPrevWndProc, HWND xHWND, UINT xMessage, WPARAM xwParam, LPARAM xLParam),LRESULT,PASCAL,NAME('CallWindowProcA')
END
FRAME_WndProc Procedure(HWND xHwnd, UINT xMessage, WPARAM xWParam, LPARAM xLParam) !LRESULT,PASCAL
_WM_ACTIVATEAPP EQUATE(28)
RetVal LRESULT
CODE
CASE xMessage
OF _WM_ACTIVATEAPP
IF xWParam
oGlo.OnGainFocus()
ELSE oGlo.OnLoseFocus()
END
END
RetVal = CallWindowProc(glo:FrameOrigWndProc , xHwnd, xMessage, xWParam, xLParam)
RETURN RetVal