Page 1 of 1

Posted: Wed Apr 24, 2002 2:13 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Hi,

Is it possible, to change the Image of an ImageGadget() without having
to recreate it??

Any Ideas??

Timo




A debugged program is one for which you have not yet found the conditions that make it fail.

Posted: Wed Apr 24, 2002 2:54 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

In PB Windows, you may get what you're looking for experimenting with the following code:

Code: Select all

CreateImage(0, 32, 32)
ImageGadget = ImageGadget(0, 0, 0, 32, 32, UseImage(0))
hImage = LoadImage(1, "newimage.bmp")
SendMessage_(ImageGadget, #STM_SETIMAGE, #IMAGE_BITMAP, hImage)
Can't test it right now, sorry. If you have redraw problems, use:

Code: Select all

RedrawWindow_(WindowID(), 0, 0, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
Hope it helps. Bye,

El_Choni

Posted: Wed Apr 24, 2002 4:37 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Doesn't work for me

Here's the code:

Code: Select all

 
#STM_SETIMAGE = $172
#IMAGE_BITMAP = 0
  
OpenWindow(0,0,0,500,500,#PB_Window_SystemMenu,"Test")
InitGadget(30)
CreateGadgetList(WindowID())
  
CreateImage(0, 256, 256)
hImage = LoadImage(1, "newimage.bmp")
ImageGadget = ImageGadget(0, 10, 10, 256, 256, UseImage(0))
SendMessage_(ImageGadget, #STM_SETIMAGE, #IMAGE_BITMAP, hImage)
RedrawWindow_(WindowID(), 0, 0, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
  
Repeat :  Until WaitWindowEvent()=#PB_EventCloseWindow
End
The new image is of the same size as the old one, that cannot be the problem.


Timo

A debugged program is one for which you have not yet found the conditions that make it fail.

Posted: Wed Apr 24, 2002 5:49 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

This works here:

Code: Select all

#STM_SETIMAGE = $172
#IMAGE_BITMAP = 0
  
If OpenWindow(0,0,0,500,500,#PB_Window_SystemMenu,"Test")
  InitGadget(30)
  CreateGadgetList(WindowID())
    
  CreateImage(0, 380, 481)
  hImage = LoadImage(1, "jatos.bmp")
  ImageGadget = ImageGadget(0, 10, 10, 380, 481, UseImage(0))
  SendMessage_(ImageGadget, #STM_SETIMAGE, #IMAGE_BITMAP, hImage)
    
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_EventRepaint
      RedrawWindow_(WindowID(), 0, 0, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
    EndIf
  Until Event=#PB_EventCloseWindow
EndIf

End
Bye,

El_Choni

Posted: Wed Apr 24, 2002 8:22 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Strange...

This one works for me, too. Even if I delete the RedrawWindow_() call, it still works.
But the other one doesn't, do you see why? Well, I can see no major difference
between the two codes.


Well, anyway, thanks for your Help!

Timo

A debugged program is one for which you have not yet found the conditions that make it fail.

Posted: Wed Apr 24, 2002 10:10 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Both examples run here ¿? Win 98

Bye,

El_Choni

Posted: Sat May 25, 2002 2:12 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
This works here:

Code: Select all

#STM_SETIMAGE = $172
#IMAGE_BITMAP = 0
  
If OpenWindow(0,0,0,500,500,#PB_Window_SystemMenu,"Test")
  InitGadget(30)
  CreateGadgetList(WindowID())
    
  CreateImage(0, 380, 481)
  hImage = LoadImage(1, "jatos.bmp")
  ImageGadget = ImageGadget(0, 10, 10, 380, 481, UseImage(0))
  SendMessage_(ImageGadget, #STM_SETIMAGE, #IMAGE_BITMAP, hImage)
    
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_EventRepaint
      RedrawWindow_(WindowID(), 0, 0, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
    EndIf
  Until Event=#PB_EventCloseWindow
EndIf

End
Bye,

El_Choni
Hello...I've just tried this to solve a problem had and it almost works expcept that if the actual image data is bigger than the specified size, it fliis up the window (ignoring the size constraints).

ANy ideas??? (hopeful look)

Fangles

Posted: Wed Jun 12, 2002 6:15 am
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
In PB Windows, you may get what you're looking for experimenting with the following code:

Code: Select all

CreateImage(0, 32, 32)
ImageGadget = ImageGadget(0, 0, 0, 32, 32, UseImage(0))
hImage = LoadImage(1, "newimage.bmp")
SendMessage_(ImageGadget, #STM_SETIMAGE, #IMAGE_BITMAP, hImage)
Can't test it right now, sorry. If you have redraw problems, use:

Code: Select all

RedrawWindow_(WindowID(), 0, 0, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
Hope it helps. Bye,

El_Choni
Thanks El Choni works great on Windows XP, just what I needed

Fangles