|
Workbooks |
Top Previous Next |
|
Workbooks
Now you can have multiple sheet in a workbook grid. The workbook was designed with an Excel flavor and is easy to use. Each of the possible 255 sheet can have it own grid dimensions or the currently selected sheet can be used as a template by using its dimensions, headers, and much of its columns formatting (only omitting checkbox and dropdown lists). The sheet tabs can be colored, be moved, and they can have there own context menu for maximum flexibility.
Cell data can be reference from any sheet at any time using the expand MLG_Put and MLG_Get functions. The message that the programmer uses to communicate to the worksheets are
%MLG_ADDSHEET %MLG_DELETESHEET %MLG_NAMESHEET %MLG_SELECTSHEET %MLG_SWAPSHEET %MLG_SHOWSHEETTABS 'Shows the sheet tab bar if hidden. %MLG_COLORSHEETTAB %MLG_GETSHEETINFO %MLG_SETSHEETUSER %MLG_GETSHEETUSER %MLG_SETWORKBOOKPROP %MLG_GETWORKBOOKPROP
To explain the inner working of the sheet mechanics would be to say it is a DBF table. As sheets are added they are added to the end of the table. If a sheet is deleted, it is marked a deleted and its slot will be used when a new sheet is added. The tab are displayed on the tab bar from 1 to the current number of tabs. If a tab is marked as deleted it is skipped over. When tab positions are changed, the sheet information is physically swapped from slot to slot. No linked lists are used. It is that simple. One note of caution, if you wish to access data in the array for the currently active sheet, it is suggested that you send the grid the %MLG_SELECTSHEET message with a zero in the wParam so the array gets updated. This is important with the MLG_GET and MLG_PUT functions. The active grid sheet may have recently been resized so the dimensions and pointer to the cell data may be out of date in the array.
All sheet data is kept track by its place in the array. When a new sheet is created, its place (slot number) in the array is returned from the SendMessage call. If sheets are never moved, deleted, (or rename) then its place slot number in the array will never change. Most messages, functions, and call to MLG are referenced by this array slot number so it is very important. With Version 1.09 more ways to move the tabs (by the user) are introduced making it more of a challenge to keep track of the real location of the sheet data in the array. New to version 1.09 is a unique sheet id number which is generated when a sheet is added. This sheet id should be retrieved when a sheet is added and store in a global variable so a particular sheet position can always be retrieved to be used in MLG workbook calls. This is done as follows:
sheetID2006=SendMessage(hGrid, %MLG_GETSHEETINFO, %MLG_SHEET_GETID,1) 'position 1
Then later when sheetID2006 needs to be accessed use:
sheetnum2006=SendMessage(hGrid, %MLG_GETSHEETINFO, %MLG_SHEET_GETNUMFROMID,sheetid2006)
MLG provide notifications so the programmer can moniter user action. Armed with these notification, the programmer can create a very flexible workbook grid.
%MLGN_SHEETRCLICK %MLGN_SHEETSELECT %MLGN_RCLICKTABMENU %MLGN_SHEETNAMECHANGE %MLGN_SHEETPOSCHANGE %MLGN_SHEETCOLORCHANGE %MLGN_SHEETADDED %MLGN_SHEETDELETED
New to Version 1.09 is the ability for the user to rename a tab and drag and drop a tab similiar to how Excel has those operations implemented. The programmer must set Workbook Properties as such to active those features:
SendMessage hGrid, %MLG_SETWORKBOOKPROP, %MLG_SETUSERTABEDIT,%TRUE SendMessage hGrid, %MLG_SETWORKBOOKPROP, %MLG_SETUSERTABMOVE,%TRUE
If TabEdit is activated then double clicking will allow the user change the tab's name by editing. The whole name is selected and the characters will be in blue while editing. Ascii values of 32 to 126 are recognized along with the backspace. Any other keystroke or mouse will end the editing. If the name is left blank, the name will be changed to "Sheet" & sheet id number.
If TabMove is activated, selecting the tab with a left button click (and keeping the button down) while hold down the shift key will change the cursor and allow a user drag and drop similar to Excel. The current tab will be dropped in front of the tab with the tick mark in the upper left corner of the tab the mouse is over. The tabs will scroll horizontally into view while moving the mouse to left (in the transport button area of the tab control) or to the right (in the resize button area of the tab control). As noted above, allowing the tab to change position while demand a little more care on the programmers part to keep track of sheet positioning.
Also new to Version 1.09 is the ability of the programmer to store information (limited to 4 bytes) in the sheet array for each sheet to be used later by the programmer.
SendMessage hGrid, %MLG_SETSHEETUSER,2,948 'store 948 in sheet slot number 2 mydata = SendMessage (hGrid, %MLG_GETSHEETUSER,2,0) 'returns 948 in mydata
A) Split Panes
New to MLG 2.00 is the ability to split the grid both horizontally and vertically to have the grid split into as many as 4 panes. The action is similar to that of Excel. The splitters are shown on a sheet by default. If you want to suppress the splitters on a given sheet then select that sheet and set the splitter attribute to 1.
SendMessage hGrid, %MLG_ALTERATTRIBUTE,%MLG_SHOWTHESPLITTERS,1
B) Freeze Panes (new to MLG 2.06)
The split panes can be frozen as in Excel by the following message in the panes have a split. If there is no split then the message is ignored.
SendMessage hGrid, %MLG_FREEZE,%MLG,FREEZEPANES,0
The panes can then be unfrozen with the message:
SendMessage hGrid, %MLG_FREEZE,%MLG,UNFREEZEALL,0
Sometimes the programmer would want to prefreeze the panes at a specific configuration for an entry form. This can be accomplished by setting TOPROW and LEFTCOL of the grid then sending the grid the freeze message with the number of frozen row and columns desired packed into a long variable. An example of prefreezing 5 rows starting at row 5 (thus ending at row 9) would be:
SendMessage hGrid, %MLG_SETTOPROW,%MLG,FREEZEPANES,5,0 SendMessage hGrid, %MLG_FREEZE,%MLG,FREEZEPANES,MAK(LONG,5,0)
This would preset the vertical splitter behind the scenes.
|