Page 1 of 1

Posted: Tue Sep 10, 2002 9:32 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

Don't know if this is a bug or not... so please test this for me.
You'll need 2 x BMP images called 0.bmp and 1.bmp for the test.
Run the code, make sure the window has the focus, then press any
key a few times. No images are shown. Then uncomment the commented
line and it works... why? Shouldn't the toggling action work without
having to load an "initial" image first?

Code: Select all

If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  ;pic=LoadImage(1,"0.bmp")
  ig=ImageGadget(1,0,0,0,0,pic)
  Repeat
    ev=WaitWindowEvent()
    If ev=#WM_KEYDOWN
      a=1-a : pic=LoadImage(1,Str(a)+".bmp")
      SendMessage_(ig,#STM_SETIMAGE,#IMAGE_BITMAP,pic)
    EndIf
  Until ev=#PB_EventCloseWindow
EndIf

PB - Registered PureBasic Coder

Posted: Wed Sep 11, 2002 7:19 am
by BackupUser
Restored from previous forum. Originally posted by fweil.

Hello PB,

This is exactly as you say for me.

But following code update works fine, except it does not display any image at start :

If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
CreateGadgetList(WindowID())
Repeat
ev=WaitWindowEvent()
If ev=#WM_KEYDOWN
a=1-a
pic=LoadImage(1,Str(a)+".bmp")
ig=ImageGadget(1,0,0,0,0,pic)
EndIf
Until ev=#PB_EventCloseWindow
EndIf



Francois Weil
14, rue Douer
F64100 Bayonne

Posted: Wed Sep 11, 2002 8:02 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> [the] following code update works fine, except it does not display
> any image at start :

Thanks Francois, but I was just wondering if there was a reason why
the toggle in my example wasn't putting the image into the ImageGadget
that already existed, via the SendMessage API... Fred?


PB - Registered PureBasic Coder

Posted: Wed Sep 11, 2002 8:30 am
by BackupUser
Restored from previous forum. Originally posted by Pupil.
Originally posted by PB
Thanks Francois, but I was just wondering if there was a reason why
the toggle in my example wasn't putting the image into the ImageGadget
that already existed, via the SendMessage API... Fred?
It seems like the gadget isn't created when provided with a null pointer and this makes the sendmessage_() command fail. Check it out by changing the sendmessage line to this:

Code: Select all

If SendMessage_(ig,#STM_SETIMAGE,#IMAGE_BITMAP,pic) = 0
  Debug "Message failed!"
EndIf

Posted: Wed Sep 11, 2002 8:38 am
by BackupUser
Restored from previous forum. Originally posted by fweil.

You are right Pupil. I checked the GetLastError_() function which does not send an error code back, but the SendMessage has a Null return value.

Fred will certainly have an idea about this.

...

Francois Weil
14, rue Douer
F64100 Bayonne