Set or Change window size in Template code

Apologies for the neophyte question, but I am having difficulty with this problem. No luck with multiple permutations for %symbol, string, and variations of the new value.

   #Set(%symbol,Extract(string,'AT’))
   #Set(%symbol,Replace(string,'AT’,%variable))  
   #Set(%symbol,Extract(string,'AT’,4))
   #Set(%symbol,Replace(string,'AT’,'125',4))

The question is what actually goes into the symbol and what goes into the string. I’ve tried %window, %windowstatement, and even a declared %variable. Alll with no luck.

A corollary question is where is this best accomplished. Can this be in a #Control or #Extension and #AT?
Thanks for your patience in answering.

I think those values you’re trying to extract are the values set at design time. If you want to know the size of the window at run time you can just use the width and height properties.

What are you actually trying to do?

I don’t think you’ll be able to do that because the Window is generated inside ABWindow.TPW / Window.TPW by the last line in the code below where it uses %WindowStatement:

#EMBED(%DataSectionBeforeWindow,'Data Section, Before Window Declaration'),DATA,LEGACY
#IF(%WindowStatement)
  #SET(%NewWindowStatement, %WindowStatement)  #!<--- New = The App Window
  #IF(SUB(%WindowStatement,1,11) <> 'APPLICATION')
    #CASE(%WindowOperationMode)
    #OF('Normal')
      #SET(%NewWindowStatement, REPLACE(%NewWindowStatement, 'MDI', ''))
      #SET(%NewWindowStatement, REPLACE(%NewWindowStatement, 'MODAL', ''))
    #OF('MDI')
      #SET(%NewWindowStatement, REPLACE(%NewWindowStatement, 'MODAL', ''))
      #IF(NOT EXTRACT(%NewWindowStatement, 'MDI'))
        #SET(%NewWindowStatement, %NewWindowStatement & ',MDI')
      #ENDIF
    #OF('Modal')
      #SET(%NewWindowStatement, REPLACE(%NewWindowStatement, 'MDI', ''))
      #IF(NOT EXTRACT(%NewWindowStatement, 'MODAL'))
        #SET(%NewWindowStatement, %NewWindowStatement & ',MODAL')
      #ENDIF
    #!ELSE 'Use WINDOW setting'
    #ENDCASE
  #ENDIF
  #IF(EXTRACT(%NewWindowStatement,'ICON') AND NOT EXTRACT(%NewWindowStatement,'IMM'))
    #SET(%NewWindowStatement,%NewWindowStatement & ',IMM')
  #ELSIF(EXTRACT(%NewWindowStatement,'MAX') AND NOT EXTRACT(%NewWindowStatement,'IMM'))
    #SET(%NewWindowStatement,%NewWindowStatement & ',IMM')
  #ENDIF

%[20]Window %NewWindowStatement
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Above is the Window Code generated *********

You could try putting your code #AT(%DataSectionBeforeWindow),FIRST where you build your own %NewWindowStatement. Then #SET(%WindowStatement,%NewWindowStatement)` but I don’t know if you can change %WindowStatement. Try it.

You could add your own #Embed right before the %[20]Window %NewWindowStatement to allow an #AT() there to modify %NewWindowStatement but I’m not sure that %variable will be in scope.

Another way would be to generate Clarion code to Resize the Window into the Embed right after Open(Window) or right before Resize.


FYI there are some new in C11 properties:

PROP:OriginalWidth    EQUATE(7A80H)  ! Original Window Width (read only)
PROP:OriginalHeight   EQUATE(7A81H)  ! Original Window Height (read only)

Thanks for the advice, guys.
I am trying to create a consistent window design for certain procedures using a generic window. It is easy enough to populate the window with appropriate controls. I didn’t think it should be difficult to set its size. Setting %window{Prop:width} hasn’t worked either.
I’ll try the #Set(%newwindowstatement,…) approach.
I appreciate your responses.

Setting %Window{Prop:Width} in your code should absolutely work.
You need to show us the “generated code”. Post the ThisWindow.Init method with you code in context.
Is your statement coming before the window is opened?
Do you have the default save/restore window position application option enabled? If so, are you setting prop:width after the restore window position call?
If not, the your prop:width assignment will get overwritten by the restore window code. You can disable that feature on this particular procedure.

While using %window{Prop:width} = ### in code did work once I had disabled the restore window setting.
Thanks for that suggestion.

1 Like

In case you don’t know, you can edit the \Libsrc\Defaults.clw file to define windows with whatever dimensions you want and then when designing new procedures those dimensions will be used for that new procedure. (Existing windows won’t be changed)

Changing the dimensions of windows at runtime can be “interesting”, depending on how the resize templates you are using are configured.

1 Like

If you want to do this retrospectively, export the window procedures in question to a TXA and edit the TXA (search and replace) and then reimport the editted TXA.

If you want to use a New Procedure > [Proc Name]> Template Tab > select template type and thus window, then the suggest @PurpleEdge2214 mentions using \LibSrc\Defaults.clw should work.

If you use the template wizards to build a browse or form window, then whilst there are a couple of template vars declared

#DECLARE(%WindowWidth,LONG)
#DECLARE(%WindowHeight,LONG)

So you could experiment by adding Sets below the #Declare in abwizard.tpl but…

#set(%WindowWidth,400)
#Set(WindowHeight,640)

Looking in other templates, these vars seem to be controlled by the width of the browse and sheet/tab controls, so you might not have much luck.

Another possibility is to edit the template ABWindow.tpw and search for

      #PROMPT('Restrict Minimum Window Size',CHECK),%RestrictMinSize,DEFAULT(%False),AT(5)
      #ENABLE(%RestrictMinSize)
        #BOXED('Minimum Window Size')
          #PROMPT('Minimum Width:',@n5),%WindowMinWidth
          #PROMPT('Minimum Height:',@n5),%WindowMinHeight

and change it to

      #PROMPT('Restrict Minimum Window Size',CHECK),%RestrictMinSize,DEFAULT(%True),AT(5)
      #ENABLE(%RestrictMinSize)
        #BOXED('Minimum Window Size')
          #PROMPT('Minimum Width:',@n5),%WindowMinWidth,Default(400)
          #PROMPT('Minimum Height:',@n5),%WindowMinHeight,Default(640)

This would change the Window Resize template to default to Yes to restrict the min window size and the default size would/should kick in as specified in the Default() code additions or whatever you want it to be.

This assumes you would want to resize the window and enforce a min size.

Another possibility you might want to experiment with in ABWindow.tpw is to add some template code to fix the size.
Search for

#MESSAGE('Standard Window Generation',3)
#EMBED(%DataSectionBeforeWindow,'Data Section, Before Window Declaration'),DATA,LEGACY
#IF(%WindowStatement)
  #SET(%NewWindowStatement, %WindowStatement)
  #IF(SUB(%WindowStatement,1,11) <> 'APPLICATION')

Look at the code there, and add some template code to search for the size and fix the size to what you want it to be.

ABWizard.tpl also a section where it “imports” a procedure as if it was a TXA.
Search for

#GROUP(%GenerateWindow)

and the section

[window]

where you’ll see multiple instances for different types of windows.

The only other thing you could search for in the templates is

#window
#endwindow

and see what it says about these in the template code help.

I havent been through the shipping templates in any great details so only scanned through them briefly tonight for your particular requirement but I do edit the shipping templates myself to customise them to my requirements.

Wow, thanks for all those suggestions. All are helpful and educational and, I am sure, investments of your time. I am very grateful and will investigate the options to see what works best.
This forum recently had a “Shout out to the Clarion Community,” which I will second. The Clarion community is, indeed, a true community of people freely willing to spend time and energy to assist and to share their knowledge and expertise.
Thanks from a lifelong neophyte.