Hello,
Thanks for the alternative, this is working great. Customdrawcell is triggered by the drawcell method, which allows me to do some drawing.
I also discovered the drawimage call using the matching image list, but decided to draw the images myself. For anyone interested:
Public Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, bitmap As Long) As Long
Public Declare Function GetObjectA Lib "gdi32" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As Long, hbmReturn As Long, ByVal background As Long) As Long
Public Declare Function DeleteDC Lib "GDI32.DLL" (ByVal hdc As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Function DrawImage(hdc As Long, x, y, strFile As String, bgColor As Long)
Dim bmp As Long, hBitmap As Long, hBitmapOld As Long
Dim lResult As Long, pSource As Long
Dim tBMP As bitmap
lResult = GdipCreateBitmapFromFile(StrPtr(strFile), bmp)
If nul(lResult) Then
lResult = GdipCreateHBITMAPFromBitmap(bmp, hBitmap, bgColor)
pSource = CreateCompatibleDC(hdc)
hBitmapOld = SelectObject(pSource, hBitmap)
GetObjectA hBitmap, Len(tBMP), tBMP
Call BitBlt(hdc, x, y, tBMP.bmWidth, tBMP.bmHeight, pSource, 0, 0, 13369376) '= TernaryRasterOperations.SRCCOPY
End If
DeleteDC pSource
DeleteObject hBitmap
DeleteObject hBitmapOld
End Function
this allows me to, when properly controlled using mousemove, down and leave events, create a button that changes its appearance.
Private Sub gdGrid_CustomDrawCell(ByVal lRow As Long, ByVal lCol As Long, ByVal hdc As Long, ByVal lLeft As Long, ByVal lTop As Long, ByVal lRight As Long, ByVal lBottom As Long, ByVal bSelected As Boolean)
Dim rc As rect
Dim val As String
Dim indentCorrection As Integer
val = gdGrid.CellValue(lRow, lCol)
indentCorrection = gdGrid.LevelIndent * (gdGrid.RowLevel(lRow))
With rc
.left = lLeft + indentCorrection + 2
.Top = lTop + 2
.Bottom = lBottom
.right = lRight
End With
DrawText hdc, val, Len(val), rc, DT_LEFT
If bSelected Then
With rc
.left = lLeft - 2
.Top = lTop - 2
.Bottom = lBottom
.right = lRight
End With
If mouseover Then
'iGridGetImageList.DrawImageAlpha "btn_hover", hdc, rc.right - 18, 2, 255 '0 to 255"
DrawImage hdc, rc.right - 22, 1, "C:\temp\button_hover_19.png", gdGrid.CellEffectiveBackColor(lRow, lCol)
ElseIf mousedown Then
'iGridGetImageList.DrawImageAlpha "btn_pressed", hdc, rc.right - 18, 2, 255 '0 to 255"
DrawImage hdc, rc.right - 22, 1, "C:\temp\button_pressed_19.png", gdGrid.CellEffectiveBackColor(lRow, lCol)
Else
'iGridGetImageList.DrawImageAlpha "btn_normal", hdc, rc.right - 18, 2, 255 '0 to 255
DrawImage hdc, rc.right - 22, 1, "C:\temp\button_normal_19.png", gdGrid.CellEffectiveBackColor(lRow, lCol)
End If
End If
End Sub
Edited by user
2017-12-19T15:34:26Z
|
Reason: Not specified