04-19-2018, 08:44 PM
Hi Gintaras,
For certain tasks, I am using MSFlexGrid instead of QM's native QM_Grid and DlgGrid functionality because it allows for multi-line wrapped text in rows of variable height and the ability to apply Text/background color to cell (see attached image and example code below).
One thing I can't figure out how to do is apply images to a cell even though there are functions for it. I think it is limitation of my understanding of interface.
There are four potentially relevant functions:
MSFlexGridLib.MSFlexGrid xGrid.CellPicture
? CellPicture() ;;Property
Returns/sets an image to be displayed in the current cell or in a range of cells.
MSFlexGridLib.MSxGrid.CellPictureAlignment
word CellPictureAlignment() ;;Property
Returns/sets the alignment of pictures in a cell or range of selected cells. Not available at design time.
MSFlexGridLib.MSxGrid.Picture
? Picture() ;;Property, read-only
Returns a picture of the FlexGrid control, suitable for printing, saving to disk, copying to the clipboard, or assigning to a different control.
MSFlexGridLib.MSxGrid.PictureType
int PictureType() ;;Property
Returns/sets the type of picture that should be generated by the Picture property. ;;Possible values: flexPictureColor flexPictureMonochrome
I tried doing something like:
xGrid.CellPicture = "$qm$\text.bmp"
xGrid.CellPicture = LoadPictureFile("$qm$\text.bmp" 0)
xGrid.CellPicture = LoadPictureFile("$qm$\text.bmp" 1)
but they all fail saying:
"Error in MsFlexGridDlg: expected Picture"
so then I tried:
Picture pic._getfile("$my pictures$\test.jpg")
xGrid.CellPicture = pic
but it returned
Error (RT) in MsFlexGridDlg: 0x80004002, No such interface supported. ?
for Picture pic.
I found this on stackoverflow for VB6 but doesn't really help:
Any advice?
Thanks,
Stuart
Function MsFlexGridDlg
For certain tasks, I am using MSFlexGrid instead of QM's native QM_Grid and DlgGrid functionality because it allows for multi-line wrapped text in rows of variable height and the ability to apply Text/background color to cell (see attached image and example code below).
One thing I can't figure out how to do is apply images to a cell even though there are functions for it. I think it is limitation of my understanding of interface.
There are four potentially relevant functions:
MSFlexGridLib.MSFlexGrid xGrid.CellPicture
? CellPicture() ;;Property
Returns/sets an image to be displayed in the current cell or in a range of cells.
MSFlexGridLib.MSxGrid.CellPictureAlignment
word CellPictureAlignment() ;;Property
Returns/sets the alignment of pictures in a cell or range of selected cells. Not available at design time.
MSFlexGridLib.MSxGrid.Picture
? Picture() ;;Property, read-only
Returns a picture of the FlexGrid control, suitable for printing, saving to disk, copying to the clipboard, or assigning to a different control.
MSFlexGridLib.MSxGrid.PictureType
int PictureType() ;;Property
Returns/sets the type of picture that should be generated by the Picture property. ;;Possible values: flexPictureColor flexPictureMonochrome
I tried doing something like:
xGrid.CellPicture = "$qm$\text.bmp"
xGrid.CellPicture = LoadPictureFile("$qm$\text.bmp" 0)
xGrid.CellPicture = LoadPictureFile("$qm$\text.bmp" 1)
but they all fail saying:
"Error in MsFlexGridDlg: expected Picture"
so then I tried:
Picture pic._getfile("$my pictures$\test.jpg")
xGrid.CellPicture = pic
but it returned
Error (RT) in MsFlexGridDlg: 0x80004002, No such interface supported. ?
for Picture pic.
I found this on stackoverflow for VB6 but doesn't really help:
With MSFlexGrid1
.Row = 1
.Col = 1
.RowSel = 1
.ColSel = 1
.CellAlignment = flexAlignCenterCenter
Set .CellPicture = LoadPicture("C:\My Pictures\Me.bmp")
' Alternatively:
' Set .CellPicture = LoadResPicture(MY_PROFILE_PIC_ID)
End With
Any advice?
Thanks,
Stuart
Function MsFlexGridDlg
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 461 271 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 368 192 "MSFlexGridLib.MSFlexGrid {6262D3A0-531B-11CF-91F6-C2863C385E30} data:E585A5D0AA4293D1A27487688334A52541D9E9297C0AC17CC416169478846C108A9AD1DEB75F40C804"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""
if(!ShowDialog("MsFlexGridDlg" &MsFlexGridDlg)) ret
;;copy MSFLXGRD.X.manifest and MSFLXGRD.OCX to $qm$ folder
typelib MSFlexGridLib "$qm$\MSFLXGRD.OCX"
ret
;messages
sel message
,case WM_INITDIALOG
,MSFlexGridLib.MSFlexGrid xGrid
,xGrid._getcontrol(id(3 hDlg))
,xGrid._setevents("xGrid2_DMSFlexGridEvents")
,xGrid.CellTextStyle = 0
,xGrid.FontBold = 1
,xGrid.cols = 4
,xGrid.rows = 5
,xGrid.ScrollBars = 0
,xGrid.WordWrap = 1
,xGrid.RowHeight(2) = 600
,
,str FlexGridCSVColl=
,;0,1,"A",8,0,2000
,;0,2,"B",8,0,2000
,;0,3,"C",8,0,2000
,;1,0,"1",8,0,2000
,;2,0,"2",8,0,2000
,;3,0,"3",8,0,2000
,;1,1,"abc",8,0,2000
,;2,3,abc def ghi jkl mnop qrs tuv wxyz,8,0,2000
,
,xGrid.BackColorBkg = ColorFromRGB(0 0 255)
,xGrid.BackColor = ColorFromRGB(0 255 0)
,xGrid.BackColorFixed = ColorFromRGB(255 0 0)
,xGrid.ForeColorFixed = ColorFromRGB(255 255 0)
,
,;xGrid.RowSel = 2
,;xGrid.BackColorSel = ColorFromRGB(255 255 0)
,int i j
,ICsv FlexGridCSV=CreateCsv(1); FlexGridCSV.FromString(FlexGridCSVColl)
,for i 0 FlexGridCSV.RowCount
,,xGrid.Row = val(FlexGridCSV.Cell(i 0))
,,xGrid.Col = val(FlexGridCSV.Cell(i 1))
,,out F"Row {val(FlexGridCSV.Cell(i 0))} Col {FlexGridCSV.Cell(i 1)}"
,,xGrid.TextMatrix(xGrid.Row xGrid.Col) = FlexGridCSV.Cell(i 2)
,,xGrid.CellFontSize = val(FlexGridCSV.Cell(i 3))
,,xGrid.CellAlignment = val(FlexGridCSV.Cell(i 4))
,,xGrid.ColWidth(xGrid.Col) = val(FlexGridCSV.Cell(i 5))
,,xGrid.CellTextStyle = 0
,,xGrid.CellFontBold = 1
,,if(xGrid.Row > 0 and xGrid.Row%2)
,,,for j 1 xGrid.Cols
,,,,xGrid.Col = j
,,,,xGrid.CellBackColor = ColorFromRGB(255 255 0)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1