Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add Picture to MSFlexGrid Cell in QM
#1
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:

Code:
Copy      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
Code:
Copy      Help
\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


Attached Files Image(s)
   
#2
Function MsFlexGridDlg
Code:
Copy      Help
,IPicture p=+LoadPictureFile("$qm$\il_qm.bmp" 1)
,xGrid.CellPicture=+p
,
,;or
,;IDispatch o=xGrid
,;o.CellPicture=p
#3
works perfectly, thanks!!!!,
S
#4
Two quick questions:
I would prefer to use qmgrid - is it hard to add the functionality I showed above in msflexgrid (multiline text, adjustable rowheight, background color, etc). Not urgent because I have alternative inmsflexgrid. I guess there is no end to this type of functionality one could build but just wondering for wishlist.

On a related topic, I was reading more in QM help about COM function interfaces and IDispatch - most of it above my head but I was intrigued about the ability to execute VbsExec functions. I have learned so much from the QM script examples on the forum and in the archive. I know realize there are countless examples of cool things on sites like http://www.planet-source-code.com
For example when you search on flexgrid, you get code examples like:

Combining DBGrid & Combo
http://www.planet-source-code.com/vb/scr...5&lngWId=1

(I know this is something already in qmgrid (!) but it's just an example.

I imagine that with a little bit of help (future questions), I could integrate much useful functionality into my QM-built apps with use of VbsExec. I guess I should just go ahead at some point and become more fully capable in VisualStudio with direct VB but I am so comfortable in QM IDE and have developed such a large codebase and appreciate you and the forum members.
Thanks again for all you do.
Stuart
#5
VbsExec is sometimes useful for something simple, but it is not for dialogs.
QM grid control will not be developed more.
#6
ok. I understand. Again, much appreciated.
S


Forum Jump:


Users browsing this thread: 1 Guest(s)