How to add Image Pos. (Cell)-No. to xBrowse Image ?

How to add Image Pos. (Cell)-No. to xBrowse Image ?

Postby ukoenig » Sun Jul 22, 2012 1:33 pm

Hello,

because Images are the same, I need the Cell-No. instead of the Image-name
I found a Solution to show Image-numbers instead of Name,
but only the first Image each Row changes.

// 100 Images each Row
cUmbrella := ALLTRIM(STR((( oBrw2:KeyNo() - 1 ) * 100 ) + oBrw2:SelectedCol

Image

Code: Select all  Expand view

...
...
@ 150, 35 XBROWSE oBrw2 SIZE 850, 540 PIXEL OF oDlg1 ;
AUTOCOLS ARRAY aImg CELL LINES NOBORDER
oBrw2:lHeader := .T.
oBrw2:lFooter := .F.
oBrw2:lRecordSelector := .T.
oBrw2:nHeaderHeight() := 70
FOR nCol := 1 to nColCount
    WITH OBJECT oBrw2:aCols[ nCol ]
        :nWidth := nCellSize + 8
        IF nOption1 <= 4
            :oDataFont := oImgfont1
        ELSE
            :oDataFont := oImgfont2
        ENDIF
        IF nCol = 1
            :cHeader := "Row"
        ELSE
            :lBmpTransparent := .T.
            :nDataBmpAlign := AL_RIGHT
            :cHeader := ALLTRIM(STR(nCol))
            :AddBmpFile( c_path + "\Bitmaps\View.bmp" )
            :nHeadBmpNo := 1
        ENDIF
        :oHeaderFont := oImgfont2
        :bPaintText := { | oCol, hDC, cData, aRect, aColors, lHighLite | ;
                    DrawCell( oCol, hDC, cData, aRect, aColors, lHighLite ) }
    END
NEXT
...
...
...

//----------------------------------------------------------------------------//

STATIC FUNCTION DrawCell ( oCol, hDC, cData, aRect, aColors, lHighLite )
LOCAL oBrw := oCol:oBrw
LOCAL nTop := aRect[ 1 ]
LOCAL nLeft := aRect[ 2 ], cImage
LOCAL nBottom := aRect[ 3 ]
LOCAL nRight := aRect[ 4 ], cUmbrella
LOCAL hBrush1 := CreateSolidBrush( 65535 )
LOCAL hBrush2 := CreateSolidBrush( 56576 )
LOCAL hBmp, hBmpO, nBmpW, nBmpH, nBmpTop, nBmpLeft
LOCAL nOld, nOld1, nOld2, lAlpha, nZeroClr

IF ! Empty( cData := oCol:Value() ) // note: cData is reassigned
    hBmp := FILoadImg( cData )
    IF lZoom = .F.
        nBmpH := nBmpHeight( hBmp )  
        nBmpW := nBmpWidth(  hBmp )  
    ELSE
        nBmpH := nBmpHeight( hBmp )  * 5
        nBmpW := nBmpWidth(  hBmp )  * 5
    ENDIF
    IF nBmpW > nCellSize - 4
        nBmpH  *= ( (nCellSize - 4 ) / nBmpW )
        nBmpW := nCellSize - 8
    ENDIF
    IF nBmpH > nCellSize - 4
        nBmpW  *= ( (nCellSize - 8 ) / nBmpH )
        nBmpH  := nCellSize - 4
    ENDIF
    nBmpTop := nTop  + ( (nCellSize - 4 ) - nBmpH ) / 2
    nBmpLeft := nLeft + ( ( nCellSize - 8 ) - nBmpW ) / 2

    lAlpha := HasAlpha( hBmp )

    IF lAlpha .or. ! oCol:lBmpTransparent
        IF nBmpW != nBmpWidth( hBmp ) .or. nBmpH != nBmpHeight( hBmp )
            hBmpO := hBmp
            hBmp := ResizeImg( hBmpO, nBmpW, nBmpH )
            DeleteObject( hBmpO )
        ENDIF
    ENDIF

    IF lAlpha
        ABPaint( hDC, nBmpLeft, nBmpTop, hBmp, oCol:nAlphaLevel() )
    ELSEIF oCol:lBmpTransparent
        nZeroClr := GetZeroZeroClr( hDC, hBmp )
        nold := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
        TransBmp( hBmp, nBmpWidth( hBmp ), nBmpHeight( hBmp ),;
                nZeroClr, hDC, nBmpLeft, nBmpTop, nBmpW, nBmpH )
        SetBkColor( hDC, nOld )
    ELSE
        DrawBitmap( hDC, hBmp, nBmpTop, nBmpLeft )
    ENDIF
    DeleteObject( hBmp )
ENDIF

// Draw Line
// DrawHorz( hDC, nTop + nCellSize , nLeft - 4, nRight + 4, oBrw2:hRowPen )

IF ! Empty( cData )
        IF cFileNoPath( cData ) <> "Brick1.bmp" // Umbrellas
        cUmbrella := ALLTRIM(STR((( oBrw2:KeyNo() - 1 ) * 100 ) + oBrw2:SelectedCol():nCreationOrder ))
        FillRect( hDC, { nTop + nCellSize + 1, nLeft - 4, nBottom + 4, nRight + 4 }, hBrush1 )
        nOld1  := SetBkColor( hDC,  65535 )
        DrawTextEx( hDC, cUmbrella, { nTop + nCellSize + 1, nLeft + 1, nBottom - 1, nRight - 1 }, ;
                DT_CENTER + DT_VCENTER )
        SetBkColor( hDC, nOld1)
    ELSE
        FillRect( hDC, { nTop + nCellSize + 1, nLeft - 4, nBottom + 4, nRight + 4 }, hBrush2 )
        nOld2 := SetBkColor( hDC, 56576 )
        cImage := ""
        DrawTextEx( hDC, "", { nTop + nCellSize + 1, nLeft + 1, nBottom - 1, nRight - 1 }, ;
                DT_CENTER + DT_VCENTER )
        SetBkColor( hDC, nOld2 )
    ENDIF
ENDIF

DeleteObject( hBrush1)
DeleteObject( hBrush2)

RETURN NIL

 


Best Regards
Uwe :?:
Last edited by ukoenig on Tue Jul 24, 2012 9:41 am, edited 9 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests