How to refresh a bitmap included in a layout?

3 posts / 0 new
Last post
ktadd
ktadd's picture
Offline
Last seen: 8 months 2 weeks ago
Joined: 2010-12-01 01:20
How to refresh a bitmap included in a layout?

I'm looking for advise on how to update/refresh a Bitmap created from a file that is a part of my GUI layout. Specifically I have a Bitmap in my GUI that is created from a file (Implemented and works). I want to change the contents of the file (using the same filename) the Bitmap uses then have the Bitmap re-created using that file and reder it, replacing the existing Bitmap picture.

After reviewing the AutoDocs I'm guessing what I need to do is create my GUI with the Bitmap contained in it's own layout and save the layout pointer (already done). Then when the user clicks a button gadget I update the file to the new picture. After the file update I'm guessing I need to us the LM_MODIFYCHILD method on the layer, then call RethinkLayout on the layer to refresh it and render it. Does this approach re-create the Bitmap object? Will this work? Is this the best approach or is there a better way to do it?

Example code is always helpful.

Massi
Massi's picture
Offline
Last seen: 3 years 11 months ago
Joined: 2012-03-28 17:16
It seems you have a ReAction

It seems you have a ReAction GUI, if so you basically have to:

1) Remove the bitmap.image object from the active layout (LM_REMOVECHILD)
2) Add a new bitmap.image object to the active layout (LM_ADDIMAGE)
3) WM_RETHINK

Have a look at the source code of my tool BigSister available from OS4 Depot, UpdateGUI() method.

ktadd
ktadd's picture
Offline
Last seen: 8 months 2 weeks ago
Joined: 2010-12-01 01:20
@Massi Thanks for the reply!

@Massi

Thanks for the reply! I took a look at your source code and it implements what I was looking at doing except that you actually us LM_REMOVECHILD where I was looking at using LM_MODIFYCHILD instead of actually removing it. I figured modifying it instead of removing it might be faster, since it doesn't have to remove it from the list and then add it back in again, but I'm not sure if that will actually create a new bitmap object from the new picture file contents or not. I guess I can try it and if that doesn't work just remove and add it like you did.

Thanks again. The source code is helpful.

Log in or register to post comments