|
Structures and Equates |
Top Previous Next |
|
Structures and Equates plus Formatting
How to Format Grid Colors and Fonts
MLG fills in all the grid default colors and fonts etc. upon creatation of a grid. If these are not to the programmer's taste then substitutions can be made. This is done by filling in a GridInit structure and using the %MLG_SETGRIDEXSTYLE message. Only structure fields that are none zero will be used (except for the user data field). Be aware that when a grid is destroyed it will destroy all the objects it is using. This is an issue with fonts. It is advisable to only use programmer adhoc fonts created just for use with a particular grid if a built-in font does not suitable the need. MLG uses 3 built-in fonts: Arial, Courier, and Times Roman.
How to Format a Row or Column
Row and columns can be designated to be of five main types 1) General Textbox, 2) Combobox, 3) Checkbox, 4) Date textbox and 5) Number textbox. Numbers and Dates are just specialized Textboxes. Columns are typically formatted to be a certain way as a result of a database field type so most of the time only columns will be custom formatted. On specialized grids, sometimes rows need to have a particular format. A row format is alway superior to a column format.
The information for formats of a row or column is held in a RowColDataType structure. Each row and each column stores this information. Typically, zero is the default behavior. If the programmer needs to alter the structure after it has been set, it may be better to use the message %MLG_GETROWFORMAT or %MLG_GETCOLFORMAT first to first a temporary RowColDataType structure so the previous settings are not lost upon update. Some messages like %MLG_SETROWEXTRA are careful about this.
New in Version 1.08 is flexible display formatting of Number formats. Beside the ability to define the number of digits and decimal places as before, now you can define the display of a number in a cell using the power of Powerbasic's FORMAT$ function. The programmer can use up to 20 masks or which 5 have been predefined. A typical mask definition could be:
SendMessage hGrid, %MLG_SETNUMFORMATSTR ,6,"0000.00"
for putting the mask "0000.00" in mask slot number 6.
The use the %MLG_SETROWFORMAT message with the PrintUsing field set to 6 of the RowColDataType structure to set the Row or Column to the display format (assuming that the FormatNumber field is also set. See Formatting to review mask options.
How to Override the Format of a Row or Column
Also new to Version 1.08 is the ability to override formatting on a row or column level, to a cell level. By creating a Format Override Array, any cell within that array can be defined to have its individual Font display (normal,bold, or italics), RGB Color, Border (top,line,bottom, or right heavy lines), and PrintUsing mask which will assume that a valid number will be in the cell or zero will be displayed. The maximum size of the override array is the currently sized sheet (up to 65,000 rows). Only one Format Override Array can be defined per sheet and it can not be resized dynamically. It would have to be deleted and a new one created if a resize is necessary. New to version 2.00 is the z switch, which will automatically set up a formatoverride array to match the size of your dimensioned grid up to 65,000 rows. The steps to set up a Format Override Array to alter cell 2,6 would be:
LOCAL fo AS FormatOverride SendMessage hGrid ,%MLG_CREATEFORMATOVERRIDE,35,6 'set up a 35 row by 6 column array
fo.MyRGB=%YELLOW fo.MyFont=2 'Italic fo.MyUsing=%MLG_CURRENCY
SendMessage hGrid, %MLG_SETFORMATOVERRIDE ,MAKLNG(2,6),VARPTR(fo)
------------------------------------------------------------ Main format types and their attributes
General Textbox Type Color Justification WriteLock Text Length Text Case Date Textbox Type Color Justification WriteLock Date Format Number Textbox Type Color Justification WriteLock Number Format PrintUsing (for display only) NEW TO VERSION 1.08 Combobox Type Editable or NonEditable Checkbox Type None
Notes:
1)Double click Editable Combobox to edit text
--------------------------------------------------------------- List of Equates %FALSE = 0 %TRUE = 1
'Cell Types %MLG_TYPE_EDIT = 0 'default - may be overridden %MLG_TYPE_DRAW = 1 %MLG_TYPE_CHECKBOX = 2 %MLG_TYPE_COMBOSTATIC = 3 %MLG_TYPE_COMBOEDIT = 4 %MLG_TYPE_USERBUTTON = 5 %MLG_TYPE_DATE = 6 %MLG_TYPE_NUMBER = 7
'Write Lock %MLG_NOLOCK = 0 %MLG_LOCK = 1 %MLG_LOCK_SKIPROW = -1 'Will not allow a locked row to be selected 'Hilight %MLG_HILTE =-1 %MLG_NOHILITE = 0 'Case Formats %MLG_NOCASE = 0 %MLG_UCASE = 1 %MLG_LCASE = 2 %MLG_MCASE = 3 'Justification formats %MLG_JUST_LEFT = 0 %MLG_JUST_RIGHT = 1 %MLG_JUST_CENTER = 2 %MLG_JUST_WORDWRAP = 3 'Date formats %MMDDYYYY = 1 %MMDDYYYYH = 2 'dot instead of a slash %DDMMYYYY = 3 %DDMMYYYYH = 4 'dot instead of a slash %MMYYYY = 5 %MMYYYYH = 6 'dot instead of a slash %YYYYMMDD = 7 %YYYYMMDDH = 8 'dot instead of a slash %YYYYMM = 9 %YYYYMMH = 10 'dot instead of a slash
'Redimensioning Error Constants %MLG_ERR_TOTROWS1 = 1 'Requested Total Rows is less than 1 %MLG_ERR_TOTROWS65000 = 2 'Requested Total Rows is more than allowable total rows (65000) %MLG_ERR_TOTCOLS1 = 3 'Requested Total Columns is less than 1 %MLG_ERR_TOTCOLS255 = 4 'Requested Total Columns is more than allowable total columns (255) %MLG_ERR_DIMROWS1 = 5 'Requested Dimensioned Rows is less than 1 %MLG_ERR_DIMROWS65000 = 6 'Requested Dimensioned Rows is more than allowable total rows (65000) %MLG_ERR_DIMCOLS1 = 7 'Requested Dimensioned Columns is less than 1 %MLG_ERR_DIMCOLS255 = 8 'Requested Dimensioned Columns is more than allowable total columns (255) %MLG_ERR_TOTROWSDIMROWS = 9 'Requested Total Rows is greater than Dimensioned Rows %MLG_ERR_TOTCOLSDIMCOLS = 10 'Requested Total Columns is greater than Dimensioned Columns %MLG_ERR_GRIDMEM = 11 'Access to the grid memory block failed %MLG_ERR_STRMEMREALLOCATION = 12 'ReAllocation of string memory failed %MLG_ERR_ROWMEMREALLOCATION = 13 'ReAllocation of row formatting memory failed
'WorkSheet Information NEW TO VERSION 1.08 %MLG_SHEET_GETNUM = 1 'Get slot number of a sheet given the its name %MLG_SHEET_GETNAME = 2 'Get the name of a sheet given the slot number %MLG_SHEET_GETTOT = 3 'Get count of sheets %MLG_SHEET_GETRIGHT = 4 'Get sheet slot number directly to the right of given sheet %MLG_SHEET_GETLEFT = 5 'Get sheet slot number directly to the left of given sheet %MLG_SHEET_GETFIRST = 6 'Get sheet slot number of first sheet %MLG_SHEET_GETLAST = 7 'Get sheet slot number of last sheet %MLG_SHEET_GETID = 8 'Get the Sheet ID number given the sheet slot number %MLG_SHEET_GETNUMFROMID = 9 'Get sheet slot number given the sheet id number
'Format Override Borders NEW TO VERSION 1.08 %MLG_TOP = 1 %MLG_LEFT = 2 %MLG_BOTTOM = 4 %MLG_RIGHT = 8 %MLG_BOX = 99 ' to be used with MLG_SetFormatOverrideRange wrapper only %MLG_GRID = 100 ' to be used with MLG_SetFormatOverrideRange wrapper only
'Format Masks of the Format Using NEW TO VERSION 1.08 %MLG_NODECIMAL = 1 '"#" %MLG_COMMAS = 2 '"#," %MLG_COMMASDECIMAL = 3 '"#,.00" %MLG_CURRENCY = 4 '"$* #,.00" %MLG_PERCENT = 5 '"0.0%
'Workbook Properties %MLG_USERTABMOVE = 1 %MLG_USERTABEDIT = 2
'Format Override Borders %MLG_TOP = 8 %MLG_LEFT = 4 %MLG_BOTTOM = 2 %MLG_RIGHT = 1
'Font %MLGSYSFONTNORM = 0 %MLGSYSFONTBOLD = 1 %MLGSYSFONTITAL = 2 %MLGSYSFONTTABNORM = 3 %MLGSYSFONTTABBOLD = 4 %MLGSYSFONTNORMVERT = 5 %MLGSYSFONTBOLDVERT = 6 %MLGSYSFONTRES = 7
%MLG_FONT_USER = 0 %MLG_FONT_ARIAL = 3 %MLG_FONT_COURIERNEW = 1 %MLG_FONT_TIMESNEWROMAN = 2
%MLG_FONT_SIZE8 = 0 %MLG_FONT_SIZE10 = 1 %MLG_FONT_SIZE12 = 2 %MLG_FONT_SIZE14 = 3 %MLG_FONT_SIZE16 = 4 %MLG_FONT_SIZE20 = 5 %MLG_FONT_SIZE24 = 6 %MLG_FONT_SIZE36 = 7
'CellColors %CELLCOLORWHITE = 0 %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
'Callbacks %MLG_DRAWCALLBACK = 1 %MLG_FORMULACALLBACK = 2 %MLG_NUMBERCALLBACK = 3 %MLG_LISTBOXCALLBACK = 4 %MLG_DATECALLBACK = 5 %MLG_SHEETTYPECALLBACK = 6
'Format Override Cell Attribute Types %MLG_TYPE_CELLTYPE = 0 'default - may be overridden %MLG_TYPE_WRITELOCK = 1 %MLG_TYPE_USING = 2 %MLG_TYPE_FONT = 3 %MLG_TYPE_BKGCOLOR = 4 %MLG_TYPE_FGCOLOR = 5 %MLG_TYPE_BORDER = 6 %MLG_TYPE_CASE = 7 %MLG_TYPE_JUST = 8
List of Structures
TYPE RowColDataType 'A Row Format is superior to a Column Format CellType AS LONG 'Default(text) = 0 , text= 1,checkbox=2,dropdownlist=3,editable 'dropdownlist=4 VisWidth AS LONG 'if column, this is the width in pixels (zero is hidden) FormatExtra AS LONG 'if negative then the row or column will be high lighted. May have ' 'future uses also. WriteLock AS LONG 'locked <> 1 , unlocked = 0 FormatColor AS LONG 'RGB of the text (foreground color) of the cell - zero is black FormatCase AS LONG 'No case formatting = 0 , upper case > 0 , lower case < 0 FormatLength AS LONG 'No Length restriction (%MLG_MAXCELLLEN max) = 0 or max characters (2 'characters minimum) FormatJustify AS LONG 'Left = 0 (default), Right = 1, Center = 2 FormatNumber AS SINGLE 'Integer portion is count left of decimal point, decimal is portion 'right of decimal point ie "8.3" Note-a comma is also recoginized 'as a dot in the display of the grid. Extra AS LONG 'Anything you want, could be used as Record Number in Row List AS ASCIIZ PTR 'Used for the list box. Reserved FormatDate AS LONG ' 0=mm/dd/yyyy etc. TempHide AS LONG 'Internal SortExtra AS LONG 'Internal PrintUsing AS LONG 'PrintUsing on Numeric Fields 1 to %MLG_NUMFORMATSTR END TYPE
TYPE GridInit hFont AS DWORD 'Cell Font hFontBold AS DWORD 'Header Font for column and row headers hFontItalic AS DWORD 'Italic for option format override NEW TO VERSION 1.08 cyCharEx AS LONG Deprecated in version 2.00 CellBkColorRGB AS LONG 'Cells Background Color CellLineColorRGB AS LONG 'Cell Line Color WindowBkColorRGB AS LONG 'Window Background Color outside of cell area RCHiLiteRGB AS LONG 'The color to high light a row or column UserData AS LONG 'Use for anything you wish END TYPE
CHANGED IN VERSION 2.00 TYPE FormatOverRide CellFont AS BYTE '255 bits 1 2 3 size 4 5 font name 6 7 8 Bold Italic Underline zero is automatic CellType AS BYTE 'bits 1 2 3 is cell type 'bit 4 is writelock 'bits 5 6 7 8 list pointers 1 to 15 'Cell Type 0 automatic (text) = Justify Case 'Cell Type 1 text with wordwrap = Justify Case DT_WORDBREAK 'Cell Type 2 checkbox = not used 'Cell Type 3 combo static = 1 to 15 lists 'Cell Type 4 combo edit = 1 to 15 lists 'Cell Type 5 user button = not used 'Cell Type 6 date = 1 to 15 date formats 'Cell Type 7 number = 1 to 15 number formats CellFormatExtra AS BYTE 'bit 1 2 3 4 border bit 5 6 case bit 7 8 justify CellColor AS BYTE '16 Background colors, 16 text colors END TYPE
|