Set Window Properties

Hi.

I would like to be able to change all/most windows from ThisWindow.Request = InsertRecord to ThisWindow.Request = ViewRecord if required

Is there anyway of making this change globally instead of going and setting it on every window

The reason I would like to set this:

  • The client no longer pays for the package so they cannot add records but can still view records

  • The Client no longer pays but is able to insert records only on certain windows (eg: receipting)

Would you know how to do this, or maybe if there is another way I could do this

Thanks so much

Hi @brad, and welcome the ClarionHub.

This is going to depend on how this is going to affect your code base for other clients.

The Self.Request is set from GlobalRequest in the ThisWindow.init method, which is called from ThisWindow.Run method (That will be called from the Parent.Run in your code)

So you could have some logic you put in place before that call with a template, or derive the window manager and put your code in there.

The other option would be to edit ABWindow.tpw and change the generated code there.

#AT(%WindowManagerMethodCodeSection,'Init','(),BYTE'),PRIORITY(4900),AUTO,DESCRIPTION('Snap-shot GlobalRequest')
SELF.Request = GlobalRequest                                    #<! Store the incoming request

So as I said, this is going to be dependant on your needs for other clients.

Editing the template will obviously mean down the line when you upgrade clarion, you would need to make sure you make the changes again.

Deriving the window manager isn’t too difficult, you would then go into the global actions for each application and change the window manager to use yours.

You could also create a template that populates all form procedures and sets GlobalRequest to view record before the Parent.Run call.

I hope this helps a little.

Mark

1 Like

I did something as a template a while (long time) back. I created a little template and as I recall it was rather easy. I was only worried about your first case; but, I imagine with some ingenuity, it could be made to work for both. I have long since lost the code; but, I modified the People.app to get the original affect. I am including it so you can play. I added a global variable and a little window to set it at startup.

PEOPLE.zip (2.2 MB)

1 Like

A template would be the go for this. You can make them such that it auto populates every form, or you can make one that you add to each form as required.

Templates really are not that hard, but like anything the first step is the hardest.
Have a look at some #Extension templates to get the idea.

Here’s something to get you started

#EXTENSION(ControlPropOnOpen, 'Configure Controls property when opened on diff Actions'),PROCEDURE
#!
#BUTTON('Open &Action for ' & %Control),FROM(%Control, %Control & ' - ' & %SMHInsertAction),INLINE
  #PROMPT('&Insert Action:', DROP('None|Hide|Disable|Enable|ReadOnly|Set Properties')),%SMHInsertAction,DEFAULT('None')
  #PROMPT('&Update Action:', DROP('None|Hide|Disable|Enable|ReadOnly|Set Properties')),%SMHUpdateAction,DEFAULT('None')
  #PROMPT('&Delete Action:', DROP('None|Hide|Disable|Enable|ReadOnly|Set Properties')),%SMHDeleteAction,DEFAULT('None')
  #BOXED('Open Action Insert Property Settings'),WHERE(%SMHInsertAction = 'Set Properties')
    #BUTTON('Property Assignments'),MULTI(%SMHInsPropertyAssignments, '{ ' & %CtrlProperty & ' } = ' & %CtrlValue),INLINE,AT(,,,50)
      #PROMPT('&Property:', @s80),%InsCtrlProperty,REQ
      #PROMPT('New &Value:', @S255),%InsCtrlValue,REQ
    #ENDBUTTON
  #ENDBOXED
  #BOXED('Open Action Update Property Settings'),WHERE(%SMHUpdateAction = 'Set Properties')
    #BUTTON('Property Assignments'),MULTI(%SMHUpdPropertyAssignments, '{ ' & %CtrlProperty & ' } = ' & %CtrlValue),INLINE,AT(,,,50)
      #PROMPT('&Property:', @s80),%UpdCtrlProperty,REQ
      #PROMPT('New &Value:', @S255),%UpdCtrlValue,REQ
    #ENDBUTTON
  #ENDBOXED
  #BOXED('Open Action Delete Property Settings'),WHERE(%SMHUpdateAction = 'Set Properties')
    #BUTTON('Property Assignments'),MULTI(%SMHDelPropertyAssignments, '{ ' & %CtrlProperty & ' } = ' & %CtrlValue),INLINE,AT(,,,50)
      #PROMPT('&Property:', @s80),%DelCtrlProperty,REQ
      #PROMPT('New &Value:', @S255),%DelCtrlValue,REQ
    #ENDBUTTON
  #ENDBOXED
#ENDBUTTON
#!
#!
#AT(%WindowManagerMethodCodeSection, 'Init', '(),BYTE'),PRIORITY(8100),DESCRIPTION('Configure Controls for Open by action')
  #SUSPEND
#?CASE SELF.Request                                #<! Configure controls for open action
#?  OF InsertRecord
  #FOR(%Control)
    #CASE(%SMHInsertAction)
      #OF('Disable')
      DISABLE(%Control)
      #OF('Enable')
      ENABLE(%Control)
      #OF('Hide')
      HIDE(%Control)
      #OF('ReadOnly')
      %Control{PROP:ReadOnly} = True
      #OF('Set Properties')
      #FOR(%SMHInsPropertyAssignments)
      %Control{%InsCtrlProperty} = %InsCtrlValue
      #ENDFOR
    #ENDCASE
  #ENDFOR
#?  OF ChangeRecord
  #FOR(%Control)
    #CASE(%SMHUpdateAction)
      #OF('Disable')
      DISABLE(%Control)
      #OF('Enable')
      ENABLE(%Control)
      #OF('Hide')
      HIDE(%Control)
      #OF('ReadOnly')
      %Control{PROP:ReadOnly} = True
      #OF('Set Properties')
      #FOR(%SMHUpdPropertyAssignments)
      %Control{%UpdCtrlProperty} = %UpdCtrlValue
      #ENDFOR
    #ENDCASE
  #ENDFOR
#?  OF DeleteRecord
  #FOR(%Control)
    #CASE(%SMHDeleteAction)
      #OF('Disable')
      DISABLE(%Control)
      #OF('Enable')
      ENABLE(%Control)
      #OF('Hide')
      HIDE(%Control)
      #OF('ReadOnly')
      %Control{PROP:ReadOnly} = True
      #OF('Set Properties')
      #FOR(%SMHDelPropertyAssignments)
      %Control{%DelCtrlProperty} = %DelCtrlValue
      #ENDFOR
    #ENDCASE
  #ENDFOR
#?END
  #RESUME
#ENDAT
#!
#!
#GROUP(%GetDefaultOpenAction, %Ctrl),PRESERVE
  #FIX(%Control, %Ctrl)
#!  #CASE(%ControlType)
  #RETURN('None')
#!
#!
1 Like