Skip to content

Instantly share code, notes, and snippets.

@CarlTBarnes
Created June 9, 2020 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlTBarnes/f86f6b695276b2b3327f5959e5c57682 to your computer and use it in GitHub Desktop.
Save CarlTBarnes/f86f6b695276b2b3327f5959e5c57682 to your computer and use it in GitHub Desktop.
Prop:CloseWindowHook Example Clarion
!An update program used MANY procedures and the tree was not well defined.
!Some were Process Templates that had a Cancel button showing. I wanted to hide the Cancel buttons.
!How to find the procedures?
!I used PROP:CloseWindowHook and checked for a PROGRESS and BUTTON that was Visible and Enabled
!------------------------------------------------------------------------------------------------
!My Templates have been modified after Open(Window) to store the procedure name in a user Property
!This is handy at times for Debug
!
! STANDARD.TPW
! #GROUP(%StandardWindowOpening)
! ...
! WindowOpened=True
! 0{'Proc_Name'}='%Procedure' <<<< Add
!------------------------------------------------------------------------------------------------
!Procedure code that starts update:
CloseWindowHook(1) !Hook Close(window)
RunBigUpdate()
CloseWindowHook(0) !UnHook Close(window)
!------------------------------------------------------------------------------------------------
CloseWindowHook PROCEDURE (BYTE Hook1_UnHook0=1) ! Declare Procedure
CODE ! Begin processed code
IF Hook1_UnHook0=0 THEN
SYSTEM{PROP:CloseWindowHook}=0
ELSE
SYSTEM{PROP:CloseWindowHook}=ADDRESS(CloseWindowHookHandler)
END
RETURN
!------------------------------------------------------------------------------------------------
CloseWindowHookHandler PROCEDURE (WINDOW Wnd) ! Declare Procedure
Feq LONG
HasProgress BOOL
HasButton BOOL
ButtonName PSTRING(16)
CODE ! Begin processed code
LOOP
Feq=Wnd{PROP:NextField,Feq}
IF ~Feq THEN BREAK.
CASE Feq{PROP:Type}
OF CREATE:progress
HasProgress=True
OF CREATE:button
IF Feq{PROP:Visible} AND Feq{PROP:Enabled} THEN
HasButton=True
ButtonName=Feq{PROP:Text}
END
END
END
DebugOut('CloseWindow "' & Wnd{PROP:Text} &'"' |
&' '& 'Proc_Name=' & Wnd{'Proc_Name'} | !Modified Templates store this User Property.
&' '& CHOOSE(~HasProgress,'',' *** Progress ***') |
&' '& CHOOSE(HasProgress AND HasButton,' *** Button ' & ButtonName & ' ***','') )
SYSTEM{PROP:CloseWindowHook}=0
CLOSE(Wnd)
SYSTEM{PROP:CloseWindowHook}=ADDRESS(CloseWindowHookHandler)
RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment