Skip to content

Instantly share code, notes, and snippets.

@MarkGoldberg
Last active August 29, 2015 13:56
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 MarkGoldberg/9235043 to your computer and use it in GitHub Desktop.
Save MarkGoldberg/9235043 to your computer and use it in GitHub Desktop.
Clarion For Windows - class that uses REGISTER - in this case for EVENT:Notify
MEMBER()
MAP
END
INCLUDE('ctNotifyHandler.inc'),ONCE
ctNotifyHandler.CONSTRUCT PROCEDURE()
CODE
ctNotifyHandler.DESTRUCT PROCEDURE()
CODE
SELF.Kill()
ctNotifyHandler.INIT PROCEDURE(UNSIGNED NotifyCode)
CODE
SELF.NotifyCode = NotifyCode
REGISTER(EVENT:Notify, ADDRESS(SELF.OnNotify), ADDRESS(SELF))
ctNotifyHandler.KILL PROCEDURE()
CODE
UNREGISTER(EVENT:Notify, ADDRESS(SELF.OnNotify), ADDRESS(SELF))
ctNotifyHandler.OnNotify PROCEDURE()!,LONG,VIRTUAL !A Registered Method
NotifyCode UNSIGNED,AUTO
NotifyThread SIGNED,AUTO
NotifyParameter LONG,AUTO
RetVal BYTE(LEVEL:OK)
CODE
NOTIFICATION(NotifyCode,NotifyThread,NotifyParameter)
IF NotifyCode = SELF.NotifyCode
RetVal = SELF.HandleNotify(NotifyCode,NotifyThread,NotifyParameter))
END
RETURN LEVEL:OK
ctNotifyHandler.HandleNotify PROCEDURE(UNSIGNED NotifyCode, SIGNED NotifyThread,LONG NotifyParameter)!,LONG
CODE
RETURN LEVEL:OK
INCLUDE('ErrorLevels.equ'),ONCE
ctNotifyHandler CLASS,TYPE,MODULE('ctNotifyHandler.clw'),LINK('ctNotifyHandler.clw')
NotifyCode UNSIGNED
CONSTRUCT PROCEDURE()
DESTRUCT PROCEDURE()
INIT PROCEDURE(UNSIGNED NotifyCode)
KILL PROCEDURE()
OnNotify PROCEDURE(),LONG,VIRTUAL !A Registered Method
HandleNotify PROCEDURE(UNSIGNED NotifyCode, SIGNED NotifyThread,LONG NotifyParameter),LONG,VIRTUAL
END
OMIT('+++ equates already exist',LEVEL:User)
! INCLUDE('ABERROR.INC')
! Severity of error
Level:Benign EQUATE(0) !Register(): Calls any other handlers and the ACCEPT loop, if available.
Level:User EQUATE(1)
Level:Program EQUATE(2)
Level:Fatal EQUATE(3) !Register(): Doesn't call other handlers or the ACCEPT loop. This is like executing BREAK when processing the event in an ACCEPT loop.
Level:Cancel EQUATE(4)
Level:Notify EQUATE(5) !Register(): Doesn't call other handlers or the ACCEPT loop. This is like executing CYCLE when processing the event in an ACCEPT loop.
!end-OMIT('+++ equates already exist',LEVEL:User)
OMIT('+++ MG +++', Level:Break > 0)
!-- MG Levels
Level:OK EQUATE(Level:Benign) !Register
Level:Cycle EQUATE(Level:Notify) !WindowManager.Ask
Level:Break EQUATE(Level:Fatal ) !WindowManager.Ask
!-- MG Levels
!END-OMIT('+++ MG +++', Level:Break > 0)
Level:Invalid EQUATE(255)
OMIT('+++ MG +++', IfDef_LevelType)
IfDef_LevelType EQUATE(1)
LevelType EQUATE(BYTE) !DataType
!END- '+++ MG +++'
INCLUDE('ctNotifyHandler.inc'),ONCE !--- MUST be at a global more module scope
!Inside of a procedure with a window
NotifyHandler CLASS(ctNotifyHandler),CLASS
HandleNotify PROCEDURE(UNSIGNED NotifyCode, SIGNED NotifyThread,LONG NotifyParameter),LONG,DERIVED
END
NotifyHandler.HandleNotify PROCEDURE(UNSIGNED NotifyCode, SIGNED NotifyThread,LONG NotifyParameter)!,LONG,DERIVED
CODE
!do stuff
RETURN LEVEL:OK
!AFTER OPEN(Window)
NotifyHandler.Init( NCODE:ForSomeFeature )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment