I am going throufh the code of FWH and Mr. Otto's suggestion.
It appears that the intention is to paint the bitmap at center if there is no data and paint left or right when data is present and based on the value of nBmpAlign.
When there is no data, the start column of the bitmap is calculated as
- Code: Select all Expand view RUN
nBmpCol := nCol + ( ( nWidth - aBitmap[ BITMAP_WIDTH ] ) / 2 ) + 2
The calculation works fine if bitmap's width is less than the column width. But if the bitmap's width higher than the column width, nBmpCol is negative. That is what must have happened in these cases.
First quick fix we can apply is :
- Code: Select all Expand view RUN
nBmpCol := nCol + Max( 0, ( ( nWidth - aBitmap[ BITMAP_WIDTH ] ) / 2 ) )+ 2
This fix will not fit the bitmap well in the column, but atleast will not paint to the left of the column.
This raises the queston, how and when can the column width and column height can be lesser than the bitmap width?
I think this can happen for any of the three reasons.
1) User manually specifying column's width or row height less than bitmap's width or height.
2) User specifying the bitmap after oBrw:CreateFromCode.
3) The initial calculation of coulmn width and row height in the methods datawidth() and dataheight() is not perfect.
We know that all browses automatically calculate the column width on the basis of evaluated values of the first row of data. XBrowse is no exception. Column width is calculated by xbrowse on the basis of the width of the bitmap evaluated in the first row of data. If there is a larger bitmap in other rows, the width can not accommidate.
The solutions perhaps would be to
(a) revise datawidth and dataheight methods to take into account the dimensions of the largest of the bitmaps in abitmaps data.
and/or
(b) use transbmp in paintdata method instead of PalBmpDraw, to fit the bitmap to the size available,
These are some thoughts .
[/code]