CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2001
    Posts
    29

    flexgrid - image

    I like the feature of the grid control that shows a triangle in the first column of the grid when you move the cursor up and down. Is there a way to do that with the hierarchical flexgrid control?
    I thougt of puting a triangle image in the first row every time you move up and down - but i dont know how to implement that.

    Thanks!


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: flexgrid - image

    Put Icon in msfg

    This code will take the file and the icon and enter to the msfg

    OleCreatePictureIndirect is used to create a picture object to display in the flexgrid. But
    when I set the CellPicture property to
    the picture object, the grid scales the 16x16 icon to 32x32 when displaying it. According to a Google
    search, Microsoft acknowledges
    this a bug with the flexgrid. They suggest a workaround by enlarging the 16x16 icon to a 32x32 icon.
    How would I enlarge the icon to a
    32x32 icon without scaling the image nor loosing the transparency information?




    Private Sub Command1_Click()

    Dim hImgSmall As Long
    Dim strFile As String
    Dim shinfo As SHFILEINFO
    Dim i As Integer

    strFile = "C:\myfile.txt"
    ' Get the small icon data from the file
    hImgSmall = SHGetFileInfo(strFile, 0&, shinfo, Len(shinfo), _
    SHGFI_SMALLICON Or BASIC_SHGFI_FLAGS Or SHGFI_ICON)

    ' Populate the grid with the small icon
    For i = 1 To MSFlexGrid1.Rows - 1
    MSFlexGrid1.Col = 2
    MSFlexGrid1.Row = i
    MSFlexGrid1.CellPictureAlignment = flexAlignCenterCenter
    ' Returns the 16x16 icon with all transparency information in tact
    Picture1.Picture = IconToPicture(shinfo.hIcon)
    Set MSFlexGrid1.CellPicture = Picture1.Picture
    Next i

    End Sub

    Public Function IconToPicture(ByVal hIcon As Long) As IPicture
    If hIcon = 0 Then Exit Function
    Dim oNewPic As Picture
    Dim tPicConv As PictDesc
    Dim IGuid As Guid

    With tPicConv
    .cbSizeofStruct = Len(tPicConv)
    .picType = vbPicTypeIcon
    .hImage = hIcon
    End With

    ' Fill in magic IPicture GUID {7BF80980-BF32-101A-8BBB-00AA00300CAB}
    With IGuid
    .Data1 = &H7BF80980
    .Data2 = &HBF32
    .Data3 = &H101A
    .Data4(0) = &H8B
    .Data4(1) = &HBB
    .Data4(2) = &H0
    .Data4(3) = &HAA
    .Data4(4) = &H0
    .Data4(5) = &H30
    .Data4(6) = &HC
    .Data4(7) = &HAB
    End With

    OleCreatePictureIndirect tPicConv, IGuid, True, oNewPic
    Set IconToPicture = oNewPic
    End Function



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: flexgrid - image

    Picture in msfg

    Sub AddPicToCell(flex As MSFlexGrid, row As Long, col As Long, pic As stdole.StdPicture)
    flex.row = row
    flex.col = col
    Set flex.CellPicture = pic
    End Sub

    Private Sub Command1_Click()
    AddPicToCell MSFlexGrid1, 0, 0, Picture1.Picture
    End Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: flexgrid - image

    Another example of putting picture to msfg

    ' pictures that we want to enter to the MSFG are on the form (imgItems)
    Private Sub Form_Load()
    '------------------------
    Const NUM_ROWS = 10
    Dim i As Integer

    flxItems.Rows = NUM_ROWS
    flxItems.Cols = 2
    flxItems.FixedRows = 0
    flxItems.FixedCols = 0
    flxItems.GridLines = flexGridNone
    flxItems.SelectionMode = flexSelectionByRow
    flxItems.RowHeightMin = imgItems(0).Height + _
    ScaleY(2, vbPixels, vbTwips)
    flxItems.ColWidth(0) = flxItems.RowHeightMin
    flxItems.Width = flxItems.ColWidth(0) + flxItems.ColWidth(1) + 400
    flxItems.Clear
    For i = 1 To NUM_ROWS
    flxItems.Row = i - 1
    flxItems.Col = 0
    Set flxItems.CellPicture = imgItems(CInt(Rnd * 5)).Picture
    flxItems.TextMatrix(i - 1, 1) = "Item " & Format$(i - 1)
    Next i
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Mar 2001
    Posts
    29

    Re: flexgrid - image

    Do you know how I can clear out the images in all the other cells?


  6. #6
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: flexgrid - image

    Try
    msfg.TextMatrix(Row,Col) = ""

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  7. #7
    Join Date
    May 2001
    Posts
    36

    Re: flexgrid - image

    Look at EasyGrid control.
    It has everything already.
    http://www.share2.com/easygrid/


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured