Re: Phil Russel - EuGrid

new topic     » topic index » view thread      » older message » newer message

Phil Russell wrote:

> Craig Welch wrote:
>> The data in the 'Kanji' column are Unicode codes for each
>> character. This is what I do, in pseudocode:
>>
>> procedure Grid1_onEvent
>>    if msg=EGW_CELLFORMAT then
>>      if column = KANJI then
>>        get the Unicode
>>        write character in Japanese font to hidden RichEdit field
>>        print Richedit field to pixmap
>>        void = copyToBitmapFile(pixmap, file_name)
>>        void = EGW_SetCellProperty ( ..,.. EGW_CELL_TYPE, EGW_PICTURE )
>>        void = EGW_SetCellProperty(..,.., EGW_CELL_TEXT, file_name)
>>      end if
>>    end if
>> end procedure
>>
> Actually I may have an idea why you are getting problem #2. Because the grid
> is an emulated control it basically has to redraw itself if any events
> occur within it, including clicks.  However, I've coded it so that it caches 
> the bitmap from the last time it repainted itself, and if none of the
> underlying grid data has changed then it just uses this rather than building
> a new one from scratch.
> 
> Is it possible that your code above (which will run every time *anything*
> happens
> to the grid) is generating a different file_name for the same row each time?

Yep.

> This would mean that the grid data will be constantly changing and this could
> be enough to give you a flicker.
> 
> If I'm right, you may need to cache the bitmap handle for a given row 
> for as long as the row is visible.

Well based on your advice in the previous post, I'm not creating bitmap
*files* on the fly any more. However, caching generated bitmap handles
does remove the flicker!

Equally as important, as I made the cache, I realised that previously
the number of handles had been growing at a rapid rate. There are just
over 3,000 kanji in the grid, and I found that if I paged all the way
down and up a couple of times, it would crash. I watched the number of
GDI Objects grow, and the crash took place when that number got to a bit
over 7,000.

I've now implemented a simple FIFO cache of 50 handles, and as an old
one falls out of the cache it is destroyed. So that's fine.

However, there are a couple of hundred characters in the grid that
-must- be drawn from bitmap files (fixed, existing files, not
dynamically written files). I found that each time one of those was
drawn, another GDI Object was created, and not released. I've modified
eugrid.ew as follows:

At the end of EGW_DrawBitmap:
-- release the memory
eugrid_mem:W32_release_mem( mset )

-- CW addition:
if sequence(bitmap) then
    deleteObject(hBitmap)
end if



Thanks & Regards,

-- 
Craig

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu