Date: 02-16-2022
Return to Index
created by gbSnippets
'Load
FileNameZ = "grid.dat"
SendMessage hGrid, %MLG_LoadSheet,0, VarPTR(FileNameZ)
'Save
Case %IDC_Save
FileNameZ = "grid.dat"
SendMessage hGrid, %MLG_SaveSheet,0, VarPTR(FileNameZ)
ARGRID message since cell data and cell formatting is only loaded if present in the saved file. So if a file was only cell selectively saved (with wParam set to 1) then if you are loading onto a presently populated grid, so could have potentially a mix of old and new cell data. This may or may not be what you desired. I kept the Load message pretty low level to give the programmer maximum flexibility.
The wParam parameter of the SendMessage call directs the action.
wParam = -1 asks for row dimensioning data. The returned value is the needed row in the grid
wParam = -2 asks for col dimensioning data. The absolute value of returned value is the needed cols in the grid. If the value is negative then the file has cell formatting data in it but your current sheet does not have a cell format array set up (format override). Recommend procedure is to retrieve this dimensioning data unless you know for sure what the files dimensions are.
wParam = 0 loads everything which is cell data, cell formatting, row headers data, and column header data.
wParam = 1 loads everything but skips cell data.
wParam = 2 loads everything but skips cell formatting.
wParam = 3 loads everything but skip the row and column headers (the headers may include some data needed by cell formatted comoboxes).
wParam = 4 loads only cell data.
When finished, MLG will set the grid to the view rows and cols as saved in the file. The dimensions can be larger than the viewing area.
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
#Include "mlg.inc"
Enum Equates Singular
IDC_Grid = 500
IDC_Save
IDC_Load
End Enum
Global hDlg, hGrid As Dword
Function PBMain() As Long
Dialog Default Font "Tahoma", 10,0
Dialog New Pixels, 0, "MLG Example",300,300,600,350, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Load, "Load", 10,10,100,20
Control Add Button, hDlg, %IDC_Save, "Save", 120,10,100,20
MLG_Init
Control Add "MyLittleGrid", hDlg, %IDC_Grid, "r10/c4", 10,40,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, FileNameZ As StringZ * %Max_Path
Select Case Cb.Msg
Case %WM_InitDialog
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Load
FileNameZ = "grid.dat"
SendMessage hGrid, %MLG_LoadSheet,0, VarPTR(FileNameZ)
Case %IDC_Save
FileNameZ = "grid.dat"
SendMessage hGrid, %MLG_SaveSheet,0, VarPTR(FileNameZ)
Case %WM_Notify
Case %WM_Size
Dialog Get Client hDlg To w,h
Control Set Size hDlg, %IDC_Grid, w-20, h-50
Control ReDraw hDlg, %IDC_Grid
End Select
End Function
http://www.garybeene.com/sw/gbsnippets.htm