Date: 02-16-2022
Return to Index
created by gbSnippets
%MLGN_RETURN
%MLGN_DELETE
%MLGN_PASTE
%MLGN_TAB
%MLGN_CHARPRESSED
%MLGN_ESCAPEPRESSED
%MLGN_ROWDIRTY
%MLGN_CELLDIRTY
%MLGN_ROWALTERED
%MLGN_CELLALTERED
%MLGN_DATEPROBLEM
%MLGN_CHECKCHANGED
%MLGN_COMBOCHANGED
%MLGN_COLWIDTHCHANGED
%MLGN_SELCHANGE
%MLGN_ROWCHANGE
%MLGN_ROWSELCHANGE
%MLGN_COLSELCHANGE
%MLGN_ROWCOLALLBLOCKSEL
%MLGN_REDIMFAILED
%MLGN_WANTNEWREC
%MLGN_MADENEWREC
%MLGN_RIGHTCLICK
%MLGN_RCLICKMENU
%MLGN_SHEETRCLICK
%MLGN_RCLICKTABMENU
%MLGN_SHEETSELECT
%MLGN_SHEETSELECTCHANGING (new in version 1.14)
%MLGN_SHEETNAMECHANGE
%MLGN_SHEETPOSCHANGE
%MLGN_SHEETCOLORCHANGE
%MLGN_SHEETADDED
%MLGN_SHEETDELETED
%MLGN_COLSIZEDOUBLECLICK
%MLGN_THEMECHANGED
%MLGN_COLDOUBLECLICK
%MLGN_ROWDOUBLECLICK
%MLGN_SETFOCUS
%MLGN_KILLFOCUS
%MLGN_ROWINSERT
%MLGN_COLINSERT
%MLGN_ROWDELETE
%MLGN_COLDELETE
%MLGN_SHEETSELECTCHANGING
%MLGN_ROWHEIGHTCHANGED
%MLGN_MULTICELLCHANGE
%MLGN_USERBUTTON
%MLGN_COMBOBUTTON
%MLGN_SPLITTERCHANGE
%MLGN_SELECTEDCELLLOCKED
%MLGN_PRINTAREASET
%MLGN_REPEATROWSSET
%MLGN_REPEATCOLUMNSSET
%MLGN_RCLICKINFOBARMENU
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
#Include "mlg.inc"
Enum Equates Singular
IDC_Grid = 500
End Enum
Global hDlg, hGrid As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "MLG Example",300,300,600,350, %WS_OverlappedWindow To hDlg
MLG_Init
Control Add "MyLittleGrid", hDlg, %IDC_Grid, "r10/c4", 10,10,580,330, %MLG_STYLE
Control Handle hDlg, %IDC_Grid To hGrid
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local w,h As Long
Select Case Cb.Msg
Case %WM_InitDialog
Case %WM_Command
Case %WM_Size
Dialog Get Client hDlg To w,h
Control Set Size hDlg, %IDC_Grid, w-20, h-20
Control ReDraw hDlg, %IDC_Grid
Case %WM_NOTIFY
Select Case CB.NmID
Case %IDC_Grid
Mlgn = CB.lParam
Select Case CB.Nmcode
Case %MLGN_RETURN
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The enter key has been pressed. The grid will dismiss the edit box if it had focus and will move the cell selection box according to the "e" switch.
Case %MLGN_DELETE
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The delete key has been pressed.
Case %MLGN_PASTE
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'Data has been pasted into the edit box. Check for formatting of a date, number,
'Case, or length if desired.
Case %MLGN_TAB
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The tab key has been pressed. The grid will dismiss the edit box if it had focus
'and will move the cell selection box according to the "t" switch.
Case %MLGN_CHARPRESSED
hEdit=@MLGN.Param4 'edit box handle
mychar=@MLGN.Param3 'character
mycol=@MLGN.Param2 'current column
myrow=@MLGN.Param1 'current row
'The character key has been pressed. This may be handy for validation.
'NOTE: a problem may occur if too much time is taken to process this
'notification because the edit box could get out of sync. With the handle
'to the edit box and the Windows API call of GetWindowText and the message
'EM_GETSEL, then mychar can be inserted into the edit string and evaluated.
'Return non zero if you do not want the character entered in the cell. ie FUNCTION=1.
Case %MLGN_ESCAPEPRESSED
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The escape key has been pressed.
Case %MLGN_ROWDIRTY
myrow=@MLGN.Param1 'previous row
mycol=@MLGN.Param2 'previous col
'The cell selection has changed rows and something on the row has changed since
'the cell selction entered the row. The record needs to be updated in the database.
'A handy place to keep the record number (a LONG INTEGER) is with the record by using
'the %SETROWEXTRA message. This record number can be retrieved with the %GETROWEXTRA
'message. If the "i" switch is set, the row header should be darken showing that the
'row is dirty and is in need of updating.
Case %MLGN_CELLDIRTY
myrow=@MLGN.Param1 'previous row
mycol=@MLGN.Param2 'previous col
'The cell selection has changed cells and something in the cell has changed since
'the cell selction was made. This may be a good time for validation checks. If
'the "i" switch is set, the row header should be darken showing that the row is
'dirty and is in need of updating.
Case %MLGN_ROWALTERED
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The row has just become dirty and may be in need of updating at some point. If
'the "i" switch is set, the row header should be darken showing that the row is
'dirty and is in need of updating.
Case %MLGN_CELLALTERED
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'The cell has just become dirty and may be in need of updating at some point and
'validation. If the "i" switch is set, the row header should be darken showing
'that the row is dirty and is in need of updating.
Case %MLGN_DATEPROBLEM
myrow=@MLGN.Param1 'previous row where the problem occured
mycol=@MLGN.Param2 'previous col where the problem occured
'If a cell formatted as a date, a mistyping occurred and MLG made an alteration
'to the cell data. A manual validation of the cell data may be in order. This
'notification is only sent if a date was materially changed like 40 was entered
'for the day and MLG changed it to 31. If 4 was entered for the day and MLG reformatted
'it to 04 then no notification will be sent.
Case %MLGN_CHECKCHANGED
mychar=@MLGN.Param3 'before toggle - if contains "0" then unselected else is selected
mycol=@MLGN.Param2 'column of check change
myrow=@MLGN.Param1 'row of check change
'If a cell formatted as a checkbox, the check has been toggled. If the checkbox is in
'the unchecked state, the cell will hold a "0". If the cell is in a checked state it
'will hold anything else.
Case %MLGN_COMBOCHANGED
myrow=@MLGN.Param1 'current row
mycol=@MLGN.Param2 'current col
'If a cell formatted as a combobox, the listbox had been dropped down or dismissed.
Case %MLGN_COLWIDTHCHANGED
mycol=@MLGN.Param2 ' column of mouse
I=@MLGN.Param1 ' new width
'If the user manually changes a column width with the mouse.
Case %MLGN_SELCHANGE
myrow=@MLGN.Param1 'previous row
mycol=@MLGN.Param2 'previous col
visrows=@MLGN.Param3 'visible rows (includes partial rows)
viscols=@MLGN.Param4 'visible cols (includes partial columns)
'The cell selection has changed. With LeftCol and Top Row and MLG_GETSELECTED you can
'determine if the selected cell is visible
Case %MLGN_ROWCHANGE
myrow=@MLGN.Param1 'current row
oldrow=@MLGN.'previous row
'The row selection has changed. May need to load a record into the application
Case %MLGN_ROWSELCHANGE
mystart=@MLGN.Param1 'start row
myend=@MLGN.Param2 'end row
'If the block selection has been enabled with the "b" switch, the user has changed a row selection.
Case %MLGN_COLSELCHANGE
mystart=@MLGN.Param1 'start col
myend=@MLGN.Param2 'end col
'If the block selection has been enabled with the "b" switch, the user has changed a col selection.
Case %MLGN_ROWCOLALLBLOCKSEL
mytotalrows=@MLGN.Param1 'total rows
mytotalcols=@MLGN.Param2 'total cols
'If the block selection has been enabled with the "b" switch, the user has selected the whole grid.
Case %MLGN_REDIMFAILED
I=@MLGN.Param1 'What calling function or messages when the problem occurred
J=@MLGN.Param2 'What part of the REDIMARRAY function failed (see err codes)
'MLG has tried to get more memory for the grid but failed. If I>2 then the action failed while
'in an INSERTCOLAFTER, INCOLBEFORE, INSERTROWAFTER, or INSERTROWBEFORE messages. I will contain
'the message constants. If I=1 then the action failed while in a PutEX function. If I=2 the action
'failed while rrying to append a row . J can be 1 to 13. Check the error codes section of the
'MLGPB.Inc fial to see what part of the redimarray function failed.
Case %MLGN_WANTNEWREC
mytotalrows=@MLGN.Param1
'If the auto row append mode has been enabled with the "e3" switch, MLG is asking if it is OK to
'append a row to the bottom of the grid. The user can prevent the append by sending a
'%MLG_SETSKIPRECFLAG message if a validation fails.
Case %MLGN_MADENEWREC
mytotalrows=@MLGN.Param1
'If the auto row append mode has been enabled with the "e3" switch, MLG has just appended a
'row to the bottom of the grid.
Case %MLGN_RIGHTCLICK
myrow=@MLGN.Param1 'Current row
mycol=@MLGN.Param2 'Current col
skey=@MLGN.Parma3 'Is the shift key pressed. Zero is NO
'A cell has been right clicked. If any changes are needed to the right click menu
'(such as greying a selection), then do it now.
Case %MLGN_RCLICKMENU
myitem=@MLGN.Param3 ' menu item
mycol=@MLGN.Param2 ' column of mouse
myrow=@MLGN.Param1 ' row of mouse
skey=@MLGN.Param4 'is the shiftkey pressed? Zero is NO
'If the right click menu has been enabled with the "m1" switch, the user has made a menu item selection.
Case %MLGN_SHEETRCLICK
mytab=@MLGN.Param1 'Which tab was clicked
'A sheet tab has been right clicked. If any changes are needed to the right click menu
'(such as greying a selection), then do it now.
Case %MLGN_RCLICKTABMENU
mytab=@MLGN.Param2 ' which tab was clicked
myitem=@MLGN.Param1 ' which menu item
'If the sheet tab right click menu has been enabled with the "m2" switch, the user has made
' a menu item selection.
Case %MLGN_SHEETSELECT
myoldsheet=@MLGN.Param2 'which tab is being deselected
mynewsheet=@MLGN.Param1 'which tab is being selected
myoldrow=@MLGN.Param3
myoldcol=@MLGN.Param4
'A sheet tab has been selected. This is sent after the sheet has changed.
Case %MLGN_SHEETSELECTCHANGING (new in version 1.14)
myoldsheet=@MLGN.Param2 'which tab is being deselected
mynewsheet=@MLGN.Param1 'which tab is being selected
myoldrow=@MLGN.Param3
myoldcol=@MLGN.Param4
'A sheet tab has been selected. This is sent before the sheet has changed.
Case %MLGN_SHEETNAMECHANGE
mytab=@MLGN.Param1 ' which menu item
'The sheet tab mytab was just renamed.
Case %MLGN_SHEETPOSCHANGE
myarrayslot1=@MLGN.Param2 ' which tab was clicked
myarrayslot2=@MLGN.Param1 ' which menu item
'Swap tab sheet array slot numbers. One of the sheets may be the actively selected workbook sheet.
Case %MLGN_SHEETCOLORCHANGE
mynewcolor=@MLGN.Param2 ' the color
mytab=@MLGN.Param1 ' which tab is being recolored
'A tab has just been assigned a new RGB color
Case %MLGN_SHEETADDED
mynewsheet=@MLGN.Param1 ' which tab is being selected
'A new sheet has just been added and mynewsheet is the sheet array slot number assigned..
Case %MLGN_SHEETDELETED
mytab=@MLGN.Param1 ' the is being deleteed
'This is the sheet number that just got deleted. The array slot is marked as deleted.
'The actively selected workbook sheet MAY NOT be deleted.
Case %MLGN_COLSIZEDOUBLECLICK
mycol=@MLGN.Param1 ' the is columns resize bare being cclicked
skey=@MLGN.Param2 ' the is shift key is down
ckey=@MLGN.Param3 ' the is control key is down
'This cursor is an EW cursor shape in the column header and is double clicked.
'Excel uses this action to fit the column to the data size. The programmer may want
'to use the wrapper MLG_SetColMaxLen to resize the column to fit. If the shift key is
'down then 1 is returned in Param2 and likewise the control key state is in Param3
Case %MLGN_THEMECHANGED
wParam=@MLGN.Param1
lParam=@MLGN.Param2
'Theme has change. This notification is simply passing on the WM_THEMECHANGED message
'received by the application. Reset header and background colors if desired.
Case %MLGN_COLDOUBLECLICK
mycol=@MLGN.Param1 ' the is column double clicked
skey=@MLGN.Param2 ' the is shift key is down
ckey=@MLGN.Param3 ' the is control key is down
'A column is double clicked while the EW cursor is not showing. If the shift key is down
'then 1 is returned in Param2 and likewise the control key state is in Param3
Case %MLGN_ROWDOUBLECLICK
mycol=@MLGN.Param1 ' the is row double clicked
skey=@MLGN.Param2 ' the is shift key is down
ckey=@MLGN.Param3 ' the is control key is down
'A row has been double clicked. If the shift key is down then 1 is returned in Param2
'and likewise the control key state is in Param3
Case %MLGN_SETFOCUS
mycntl=@MLGN.Param1 ' The handle of the control losing focus
'Note: in a grid this could be the grid handle or a control within the grid which the
'grid handle could be verified by using the Windows API function GetParent. The
'WM_SETFOCUS message of the grid control has been received and this notification is
'simply telling the user about it. This may or may not be of value.
Case %MLGN_KILLFOCUS
mycntl=@MLGN.Param1 ' handle of the control receiving focus
'Note: in a grid this could be the grid handle or a control within the grid which
'the grid handle could be verified by using the Windows API function GetParent.
'The WM_KILLFOCUS message of the grid control has been received and this notification
'is simply telling the user about it. This may or may not be of value.
Case %MLGN_ROWINSERT
mycntl=@MLGN.Param1 ' Msg %MLG_INSERTAFTER or %MLGINSERTBEFORE
rowsToAdd = @MLGN.Param2
pivotrow = @MLGN.Param3
Case %MLGN_COLINSERT
mycntl=@MLGN.Param1 ' Msg %MLG_INSERTAFTER or %MLGINSERTBEFORE
rowsToAdd = @MLGN.Param2
pivotrow = @MLGN.Param3
Case %MLGN_ROWDELETE
mycntl=@MLGN.Param1 ' Message
startrow = @MLGN.Param2
rowsdeleted = @MLGN.Param3
Case %MLGN_COLDELETE
mycntl=@MLGN.Param1 ' Message
startcol = @MLGN.Param2
colsdeleted = @MLGN.Param3
Case %MLGN_SHEETSELECTCHANGING
myoldsheet=@MLGN.Param2 'which tab is being deselected
mynewsheet=@MLGN.Param1 'which tab is being selected
myoldrow=@MLGN.Param3
myoldcol=@MLGN.Param4
'A sheet tab has been selected. This is sent before the sheet has changed.
Case %MLGN_ROWHEIGHTCHANGED
rowbeingresized=@MLGN.Param2
newrowheight=@MLGN.Param1
Case %MLGN_MULTICELLCHANGE
myselectedcol=@MLGN.Param2
myselectedrow=@MLGN.Param1
myselectedrow2=@MLGN.Param3
myselectedcol2=@MLGN.Param4
Case %MLGN_USERBUTTON
myselectedcol=@MLGN.Param2
myselectedrow=@MLGN.Param1
'Note: This is your chance to bring up a dialog box etc.
Case %MLGN_COMBOBUTTON
myselectedcol=@MLGN.Param2
myselectedrow=@MLGN.Param1
Case %MLGN_SPLITTERCHANGE
whichsplitter=@MLGN.Param1 '1 is vertical 2 is horizontal
splitterposition=@MLGN.Param3
Case %MLGN_SELECTEDCELLLOCKED
mypreviousrow=@MLGN.Param1
mypreviouscol=@MLGN.Param2
myselectedrow=@MLGN.Param3
myselectedcol=@MLGN.Param4
'NOTIFICATIONS BELOW THIS LINE ARE NEW TO VERSION 3.00
Case %MLGN_PRINTAREASET
myselectedtoprow=@MLGN.Param1
myselectedlftcol=@MLGN.Param2
myselectedbtmrow=@MLGN.Param3
myselectedrgtcol=@MLGN.Param4
Case %MLGN_REPEATROWSSET
myselectedtoprow=@MLGN.Param1
myselectedlftcol=@MLGN.Param2
myselectedbtmrow=@MLGN.Param3
myselectedrgtcol=@MLGN.Param4
Case %MLGN_REPEATCOLUMNSSET
myselectedtoprow=@MLGN.Param1
myselectedlftcol=@MLGN.Param2
myselectedbtmrow=@MLGN.Param3
myselectedrgtcol=@MLGN.Param4
Case %MLGN_RCLICKINFOBARMENU
myitem=@MLGN.Param3 ' Menu Item
mycol=@MLGN.Param2 ' Column of Mouse
myrow=@MLGN.Param1 ' Row of Mouse
End Select
End Select
End Select
End Function
http://www.garybeene.com/sw/gbsnippets.htm