Part 2: Modify the window. |
So far we have assembled all the code needed for us to modify an existing window and we have put it in a new emty file that we have named MyInvoiceWindow.hal and stored in a folder named halcust in the same folder as we have our Hansa World program. Let´s take a look at some of the most intresting parts in out invoice window definition! Some of the first lines look like this |
event DefineWindows begin Real h,h1,h2,h3,h4,h5,h6,h7,hs,hm,v,v3,l,vs,vm,f,t,x,v2; SetLangMode(LangEnglish,"ENG",0); WindowBegin("Invoice",IVDClass,CGview,-); |
All windows should be defined inside a DefineWindows section. This is between the begin that follows right after event Define windows and the corresponding end. The SetLangMode command is used to declare what the language of the window is. All windows definitions begin with the keyword WindowBegin, the first argument of the command is the window name, the second is an internal name that must be unique and is used to identify the window when referencing the window from HAL. The last part of there internal window names are always a letter followed by the work Class, for example DClass, LClass etc. Here are some of the most common window class codes and how they are used: - Detail windows like customer card end with DClass. - Browse (or list) windows end with LClass. - Report specification windows end with RClass. - Paste Special windows end with SClass. If we look a bit further down in our window definition we find the following lines: |
Tile(0,48+22,false,"",CustCode); EditField(75,vm=(v=6), 82,"No.",Normal,SerNr,false,TSerSClass); EditField(75,v+=20,95, "Customer",Normal,CustCode,false,CUSClass); |
The Tile function gives us a separate section in our invoice window. Tile numer 0 is alwyas visible in the window while the tiles 1, 2 etc can be show or hidden depending on what tile buttons you press in the window. The edit field function puts an edit field into the window. The arguments are horisontal position, vertical position, width, name to be displayed on the left side of the field, writeable or read only, database field name, left or right justification and finally the name of the Paste Special window to be activated from this field. To remove an edit field just add two forward slashes in front of the code line. To change the name displayed to the left of the edit field in the window just change the text in the 4th arugment of the EditField function. A bit futher down the following lines of code are found: |
MatrixBegin(4,v,-50,-49,-,200); MatTypedRow(stp); Flip(0); MatCol(t=1,32,"Item",0,ArtCode,false,INSClass); // MatCol(t,94,"Var",0,VARList,true,VARSClass); // MatCol(t,144,"Qty",0,Quant,true,0); |
This is where the invoice lines are shown. The function MatCol creates a column in the matrix where the invoice lines are displayed. For an invoice there are more than one type of matrix row. The most common row type is 1, this is a row with an item, quantity and price. There are other sorts of lines though for example the line on a credit invoice that shows the original invoice number. Special menu In the last part of the window definition the special menu commands are defined. |
SpecialMenu("Item Status",'I',0,"ItemStatusIVDsm"); SpecialMenu("Create Cash In",' ',1,"DoCLInFromIVD"); |
The last agument in the SpecialMenu function is the name of the HAL procedure that should be calld when that special menu command is activated. Try to make some changes in the window and store the file. Compile Hansa by using Command-Shift-K (on Mac) or Ctrl-F5 (on Windows) or by restarting Hansa. |