.Reference: Functions

Category: Controls - MLG

Date: 02-16-2022

Return to Index


 
'The sheet parameter should not be used or set to zero for referencing the currently selected sheet. 
 
'%MLG_STYLE= %WS_VISIBLE OR %WS_BORDER OR %WS_CHILD OR %WS_VSCROLL OR %WS_HSCROLL
 
'DDT
MLG_Init
CONTROL ADD "MYLITTLEGRID", hDlg, %IDC_MLGGRID, "r25,5/c8/a1/i1/t2/m1First,Second,-,Third", 4, 14, 250, 150, %MLG_STYLE OR %WS_TABSTOP
CONTROL HANDLE hDlg, %IDC_MLGGRID TO hGrid 
 
'Internal Functions
MLG_ArrayRedim
 
'List of Internal Functions
 
1) FUNCTION MLG_ArrayRedim(BYVAL hGrid AS DWORDrow AS LONGcol AS LONG, rowdim AS LONG, coldim AS LONG)AS LONG
 
Purpose: To change the row and colummns available to the grid plus any dimensioning expansion room.
 
Parameters:
 
hGrid        handle to grid control
 
row        number of desired grid rows (1 to 2000000000)
 
col        number of desired grid cols (1 to 255)
 
rowdim        number of desired grid rows dimensioned. rowdim >= row
 
coldim        number of desired grid cols dimensioned. coldim >= col
 
Results: err code
 
0        no err
 
not 0 function failed. Failure flags 1 to 13 are commented on in the include file.        
 
 
 
Comments or Restrictions: If the function failed the memory data is left alone.  Dimensioning is never reduced only increased.  The message REDIMARRAY mirrors this function.
 
 
 
A special case of this function has been added to Version 1.10.  In order to easily snap back the total rows to the number of records in a table use the following parameters:
 
 
 
Parameters:
 
hGrid        handle to grid control
 
row        number of records in the table
 
col        -1
 
rowdim        -1
 
coldim        -1
 
 
 
 
 
2) FUNCTION MLG_Get(hGrid AS LONG,row AS LONG,col AS LONG,OPT sheetnum AS LONGAS STRING
 
Purpose: To retrieve the a 's string content.
 
Parameters:
 
hGrid        handle to grid control
 
row        number of desired grid rows (1 to 2000000000)
 
col        number of desired grid cols (1 to 255)
 
sheetnum number of the sheet in a multi workbook - uses selected sheet if                        omitted
 
Results: the results of the cell contents
 
       
 
Comments or Restrictions: The message %MLG_GETCELL may also be used to retrieve a 's string content.  Also header strings can retrieved be specifying a zero element.  For example:  MLG_Get(hGrid,1,0) will retrieve the first row's header string.
 
 
 
3) SUB MLG_GetEx (hGrid AS LONG,s() AS STRING)
 
Purpose: To retrieve a group of 's string contents.
 
Parameters:
 
hGrid        handle to grid control
 
s()        a dimensioned string array
 
Results: None
 
 
 
Comments or Restrictions: Powerbasic subroutine only.  The subroutine will fill the array with corresponding cell contents.  For example:
 
 
 
DIM s(4,5)
 
DIM hGrid AS DWORD
 
 
 
MLG_GetEx hGrid,s()
 
 
 
This will retrieve cells string contents in rows 1 to 4 and columns 1 to 5 plus have the header strings in their respective 0 elements of the array.  The lower bounds of the array can obviously be controls by dimensioning the array differently - such as
 
 
 
DIM s(1 TO 4,2 TO 5) 
 
 
 
 
 
4) SUB MLG_Init()
 
Purpose: To register the grid control with Windows on languages that can not static address MLG.DLL.
 
Parameters: None
 
Results: None
 
Comments or Restrictions: 
 
 
 
 
 
5) SUB MLG_Put(hGrid AS LONG,row AS LONG,col AS LONG, mystr AS STRING,refresh AS LONG ,OPT sheetnum AS LONG)
 
Purpose: To change a 's string contents.
 
Parameters:
 
hGrid        handle to grid control
 
row        number of desired grid rows (1 to 2000000000)
 
col        number of desired grid cols (1 to 255)
 
mystr        new cell content
 
refresh        0 do not refresh grid after call, 1 refresh grid
 
sheetnum number of the sheet in a multi workbook - uses selected sheet if                        omitted
 
Results: None
 
 
 
Comments or Restrictions: Use the %MLG_REFRESH message to refresh the grid if 0 is used for the refresh parameter. If the sheetnum option is used then the refresh is ignored since this is used to update cell data on non-selected sheets.
 
 
 
 
 
6) SUB MLG_PutEx(hGrid AS LONG,s()AS STRING,op AS LONG, refresh AS LONG)
 
Purpose: To change a group of cell string contents based on how the string array is dimensioned.
 
Parameters:
 
hGrid        handle to grid control
 
s()        a dimensioned string array
 
op                options:  if op equal x then
 
then replace the grid with array data only if nothing is out of bounds
 
then do not write over column headers
 
then do not write over row headers
 
then do not write over row or column headers
 
 
 
op is negative then resize the grid to fit the array.  Leave number of rows and number of columns to fit array bounds.  Expand grid dimensions only if necessary.    
 
refresh         0 do not refresh grid after call, 1 refresh grid
 
Results:        None
 
 
 
Comments or Restrictions: This is a Powerbasic only subroutine.  Use the %MLG_REFRESH message to refresh the grid if 0 is used for the refresh parameter. If the array dimensions are larger than the permitted max rows or max cols then the working array is truncated. Instead of using 2,3 or 4 using can honor headings by s(1 to 10, 1, to 20) lbound limit.         
 
 
 
 
 
List of Wrapper Functions
 
 
 
These function wrap some common message calls which some users might find easier to use.  In addition, the wrappers demonstrate how some of the messages are used.  These wrappers are located in the include file.  Many of these wrappers use optional parameters.  Unless they are altered, these optional parameters default to zero. Though not supplied, the user can easily make similar wrapper for row formating by duplicating the functions and change the message from
 
 
 
SendMessage hGrid, %MLG_SETCOLFORMAT,col,VARPTR(RC)
 
to
 
SendMessage hGrid, %MLG_SETROWFORMAT,col,VARPTR(RC)
 
 
 
 
 
SUB MLG_FormatColCheck(hGrid AS DWORD,col AS LONG)
 
Used to format a column (colas a checkbox.  This call is meant to only be used once for a column.
 
 
 
SUB MLG_FormatColCombo(hGrid AS DWORD,col AS LONG,liststr AS STRING,OPT BYVAL op AS LONG)
 
Used to format a column (colas a dropdown combobox. The liststr will be a comma delimited string of the combobox content and op = 1 for a non editable combobox and op=0 is for an editable combox (double click to enable to editable mode. This call is meant to only be used once for a column.  The dropdown is limited to 3 choices.
 
 
 
New to Version 2.066.  The first item in the comma delimited list is an optional string to define the number of choices in the dropdown.  It has the format of "|7/8" where "|is the flag,7 is for seven choices in the dropdown and 8 the number of pixels to adjust the dropdown when the choices are displayed above the cell.  This number will have to be played with to get the combobox looking right.  An example liststr could be:
 
 
 
"|7/8,xx1,xx2,xx3,xx4,xx5,xx6,xx7,xx8,xx9,xx10
 
 
 
SUB MLG_FormatColDate(hGrid AS DWORD,col AS LONG,datetype AS LONG,OPT BYVAL justify AS LONG,OPT BYVAL mycolor AS LONG,OPT BYVAL writelock AS LONG)
 
Used to format an edit column (col) specifically as a date.  The datetype is one of the many built in constants such as %MMDDYYYY. Optionally justification,text color(RGB), or making the grid column non user editable can be set. This call is meant to only be used once for a column.  See the include file for proper equates.
 
 
 
SUB MLG_FormatColNumber(hGrid AS DWORD,col AS LONG,n AS SINGLE,OPT BYVAL justify AS LONG,OPT BYVAL mycolor AS LONG,OPT BYVAL writelock AS LONG)
 
Used to format a edit column (col) specifically as a number.  The number format (n) is a floating point number with the digit count represented by the portion of the number left of the decimal point and the fractional digit count to the right of the decimal point. It can be set to zero. Optionally justification,text color (RGB), or making the grid column non user editable can be set.  This call is meant to only be used once for a column. See the include file for proper equates.
 
 
 
SUB MLG_FormatColEdit(hGrid AS DWORD,col AS LONG,mylength AS LONG,mycase AS LONG,OPT BYVAL justify AS LONG,OPT BYVAL mycolor AS LONG,OPT BYVAL writelock AS LONG)
 
Used to format a edit column (col).  The field mylength can be 2 to 255 characters and mycase set to upper or lower case. Optionally justification,text color (RGB), or making the grid column non user editable can be set.  This call is meant to only be used once for a column.  See the include file for proper equates. 
 
 
 
SUB MLG_FormatColTitles(hGrid AS DWORD,liststr AS STRING)
 
This function mirrors the "jswitch.  It takes a comma delimited string and inserts them in the column header starting with column 1 to the parameter count of the string.
 
 
 
SUB MLG_SetRowRecNo(hGrid AS DWORD,row AS LONG,RecNo AS LONG)
 
Sets a 32 bit number in the rowextra field of the formatting structure. Mostly used for a record number.
 
 
 
FUNCTION MLG_GetRowRecNo(hGrid AS DWORD,row AS LONG)AS LONG
 
Retrieves a 32 bit number from the rowextra field of the formatting structure. Mostly used as a record number.
 
 
 
SUB MLG_FormatGridex(hGrid AS DWORD,CellBkColorRGB AS LONG,WindowBkColorRGB AS LONG, CellLineColorRGB AS LONG, hFont AS LONG, hFontBold AS LONG, cyCharEx AS LONG,RCHiLiteRGB AS LONG,UserData AS LONGBYVAL OPT hFontItalic AS LONG)
 
If any of these fields are zero (except for UserData) they are ignored.  This subroutine is meant only to be called once since it will destroy object it is replacing.  The first time through these would be objects that MLG created so it would not be a problem but could be a problem is the programmer was not careful with their own objects.  See the Structure and Equates topic for more info. 
 
 
 
SUB MLG_FormatRowHighLight(hGrid AS DWORD,row AS LONG,OPT BYVAL hilite)
 
If the extra formating field is set to -1 (%MLG_HILITE) then the row will be hilighted using the RCHiLiteRGB color.  Leaving the hilite parameter off will set the extra formatting field back to zero.
 
 
 
SUB MLG_FormatColHighLight(hGrid AS DWORD,row AS LONG,OPT BYVAL hilite)
 
If the extra formating field is set to -1 (%MLG_HILITE) then the row will be hilighted using the RCHiLiteRGB color.  Leaving the hilite parameter off will set the extra formatting field back to zero.
 
 
 
SUB MLG_SetFormatOverrideRange(hGrid AS DWORD,row1 AS LONG,col1 AS LONG,row2 AS LONG, col2 AS LONG, MyRGB AS LONG,MyFont AS BYTE,MyBorder AS BYTE,MyUsing AS BYTE)
 
Retrieves the dimensioned rows and columns of the format override if it exists in the currently selected sheet.  The Borders are defined 'ing the first four bits of the BYTE.  This Subroutine will also recognize %MLG_BOX which will draw a border around the range and %MLG_GRID which will grid the entire range with darker lines. 
 
 
 
SUB MLG_CopyRowBlockToClipBoard(hGrid AS DWORD,CopyColHeader AS LONG,OPT BYVAL AllowAllRowsCols AS LONG)
 
Copies selected rows to the clipboard to be pasted in another program such as Excel.  It the CopyColHeader parameter is non zero, the column header will be the first line.  The second optional pararmeter will allow the copying of all rows.  The wrapper has a row limit variable which the user may want to alter.  Preparing a string to be placed on the clipboard can be time consuming.  Pressing the escape key during this process will abort it.
 
 
 
SUB MLG_HideColBlock(hGrid AS DWORD)
 
This subroutine will temporary hide the highlighted columns. The b switch has to set to either 2 or 3 in order for MLG to highlight a column block.  This subroutine will not hide the last column if all columns are selected.  The columns can be unhid with the %MLG_HIDECOLUMN message (with proper parameters)
 
 
 
SUB MLG_SetColMaxLen(BYVAL hGrid AS LONGcol AS LONG,OPT BYVAL ConsiderHeader AS LONG ) 
 
This subroutine will resize the column (colto fit the maximum text size.  The optional ConsiderHeader parameter will consider the length of the header in the resize if it is non-zero.
 
 
 
New to Version 3.00
 
 
 
FUNCTION MLG_GetChecked(mygrid AS LONGROW AS LONGCOL AS LONGOPT BYVAL sheet AS LONGAS LONG   
 
This function will return %TRUE (1) if a cell is checked.  It is assumed that the cell tested is of check type.  A check type cell is checked if its string length is non zero
 
 
 
SUB MLG_SetChecked(BYVAL mygrid AS LONGROW AS LONGCOL AS LONG, VALUE AS LONG, Refresh AS LONGOPT BYVAL sheet AS LONG)
 
This subroutine will put the ascii character 1 in a cell to check it.  It is assumed that the cell targeted is of check type.  A check type cell is checked if its string length is non zero
 
 
 
SUB MLG_SetPrintOptions(BYVAL mygrid AS LONG, ShowRowColHeaders AS LONG, PrintPageOrder AS LONG, PrintJustification AS LONG,SuppressGridLines AS LONG)
 
This subroutine will
 
 
 
SUB MLG_SetPrintDlg(mygrid AS LONG, NumCopies AS LONG, AutoClose AS LONG, PageFrom AS LONG,PageTo AS LONG)
 
   'Number of Copies = 1 to whatever
 
   'PrintFromPage zero to assume all pages
 
   'PrintToPage zero to assume all pages
 
   'AutoClose = 1 then PrintPreview will close upon printing action else PrintPreview stays open until manually closed 
 
This subroutine will set Print Dialog type attributes 
 
 
 
SUB MLG_SetPageSetupDlg(mygrid AS LONG, MyPaper AS LONG, MyTray AS LONG, MyOrientation AS LONG,MMFlag AS LONG)
 
   'MyPaper = 1 to 17 see documentation
 
   'MyTray 1 to 15 see documentation
 
   'MyOrientation 1 Portrait 2 Landscape
 
   'MMFlat 1 mm : zero inches 
 
This subroutine will set Page Setup Dialog type attributes        
 
 
 
SUB MLG_SetPrintHeaderFooter(mygrid AS LONG, HeaderText AS STRING, FooterText AS STRING)
 
This subroutine will set the data for the Header and Footer of the printed page.  Strings are $TAB delimited for left,center,right substrings. A substring can also be [DATE],[TIME],or [PAGEto autofill the substring with the date,time or page number.  An example of a header and  footer strings may be: 
 
 
 
HeaderText = "[PAGE]" + $TAB + "My Report" + $TAB + "[TIME]"
 
FooterText = "" + $TAB + "ACME Corporation" + $TAB + "
 
 
 
SUB MLG_SetGridFont(BYVAL hGrid AS DWORD, fname AS ASCIIZ * 40, fpoint AS LONG,OPT slot AS WORD,OPT MyStyle AS STRING
 
This subroutine will make a new font for font slots 7 to 15. If the slot is omitted then the default font will be made. The MyStyle string is combination of the characters "b,u,ito represent bold,underline, and italic.  The MyStyle string is only for slots 7 to 15. 
 
 
 
SUB MLG_SetDefaultGridFont(BYVAL hGrid AS DWORD, fname AS ASCIIZ * 40, fpoint AS LONG , OPT BYVAL RecalcNewDefaultRowHeightsAndColWidths AS LONG)
 
This subroutine will set the default slots (0,1,2,5,6).  It the RecalcNewDefaultRowHeightsAndColWidths parameter is specified as 1 then the row and column sizes will be recalculated to better handle the new font.
 
 
 
SUB MLG_FormatCellFont(BYVAL hGrid1 AS DWORD,BYVAL row1 AS LONG,BYVAL col1 AS LONG, MyFontSlot AS LONGOPT row2 AS LONG, col2 AS LONG)
 
 
 
This subroutine will set the font (slot 0 to 15) of the specified cell or range of cells if row2 and col2 are specified. This is a cell based action and the z switch must have been used to create the grid. If you specify slot 7 or above make sure the font is made for that slot.
 
 
 
 
 
SUB MLG_FormatCellBgndColor(BYVAL hGrid1 AS DWORD,BYVAL row1 AS LONG,BYVAL col1 AS LONG, MyColorSlot AS LONGOPT row2 AS LONG, col2 AS LONG)
 
       %CELLCOLORWHITE = 0  'default
 
       %CELLCOLORBLACK = 1
 
       %CELLCOLORRED   = 2
 
       %CELLCOLORSALMON = 3
 
       %CELLCOLORGREEN = 4
 
       %CELLCOLORLIGHTGREEN = 5
 
       %CELLCOLORBLUE = 6
 
       %CELLCOLORLIGHTBLUE = 7
 
       %CELLCOLORMAGENTA = 8
 
       %CELLCOLORDARKMAGENTA = 9
 
       %CELLCOLORCYAN = 10
 
       %CELLCOLORAQUAMARINE = 11
 
       %CELLCOLORKHAKI = 12
 
       %CELLCOLORBROWN = 13
 
       %CELLCOLORYELLOW = 14
 
       %CELLCOLORORANGE = 15   
 
This subroutine will color the cell background of the specified cell or range of cells if row2 and col2 are specified. This is a cell based action and the z switch must have been used to create the grid. Background slot colors can be modified with other messages.
 
 
 
SUB MLG_FormatCellTextColor(BYVAL hGrid1 AS DWORD,BYVAL row1 AS LONG,BYVAL col1 AS LONG, MyColorSlot AS LONGOPT row2 AS LONG, col2 AS LONG)
 
       %CELLCOLORWHITE = 1
 
       %CELLCOLORBLACK = 0  'default
 
       %CELLCOLORRED   = 2
 
       %CELLCOLORSALMON = 3
 
       %CELLCOLORGREEN = 4
 
       %CELLCOLORLIGHTGREEN = 5
 
       %CELLCOLORBLUE = 6
 
       %CELLCOLORLIGHTBLUE = 7
 
       %CELLCOLORMAGENTA = 8
 
       %CELLCOLORDARKMAGENTA = 9
 
       %CELLCOLORCYAN = 10
 
       %CELLCOLORAQUAMARINE = 11
 
       %CELLCOLORKHAKI = 12
 
       %CELLCOLORBROWN = 13
 
       %CELLCOLORYELLOW = 14
 
       %CELLCOLORORANGE = 15
 
 
 
This subroutine will color the cell text of the specified cell or range of cells if row2 and col2 are specified. This is a cell based action and the z switch must have been used to create the grid. Text slot colors can be modified with other messages.
 
 
 
SUB MLG_FormatCellWriteLock(BYVAL hGrid1 DWORD DWORD,BYVAL row1 DWORD LONG,BYVAL col1 AS LONG, MyLock AS LONGOPT row2 AS LONG, col2 AS LONG)
 
       %MLG_NOLOCK = 0
 
       %MLG_LOCK   = 1
 
This subroutine will write lock the specified cell or range of cells if row2 and col2 are specified. This is a cell based action and the z switch must have been used to create the grid. 
 
 
 
SUB MLG_FormatCellBorder(BYVAL hGrid1 AS DWORD,BYVAL row1 AS LONG,BYVAL col1 AS LONG, MyBorder AS LONGOPT row2 AS LONG, col2 AS LONG)
 
       '%MLG_CLEAR = 0
 
     '%MLG_TOP = 8
 
     '%MLG_LEFT = 4
 
     '%MLG_BOTTOM = 2
 
     '%MLG_RIGHT = 1
 
     '%MLG_OUTLINE = 16 
 
This subroutine will make a border on the specified cell or range of cells if row2 and col2 are specified.  The MyBorder parameter is 'ed with the TOP,LEFT,BOTTOM,RIGHT bits.  MLG_OUTLINE is used to frame a range of cells.
 
 
 
 
 
 
 
 
 
 
 
 


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm