Page 1 of 1

Posted: Mon Mar 16, 2009 5:09 pm
by einander
I remember a snippet by Sparkie (buried on the forums, the snippet, not Sparkie) to put a gadget on caption.
I Can't find it, but here is a faked Animated Icon based on Sparkie's idea.

Code: Select all

Global _AnimICO,_Img,_ImGad
   
Macro NoFlickWin(Win)  ;- NoFlickWin(win) - this one is from Sparkie *************
  SetWindowLongPtr_(WindowID(Win), -20, GetWindowLongPtr_(WindowID(Win), -20) | $2000000)
EndMacro     

Procedure WinCallback(hwnd, msg, wParam, lParam)
  Protected Result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_MOVE,#WM_SIZE,#WM_SIZING,#WM_PAINT
      ResizeWindow(_AnimICO, WindowX(0)+4, WindowY(0) + 6, 20,20)
  EndSelect
  ProcedureReturn Result
EndProcedure

Procedure AnimIco()
  StartDrawing(ImageOutput(_Img))
    Box(Random(20),Random(20),4,4,Random(#White))
  StopDrawing()
  SetGadgetState(_ImGad,ImageID(_Img))
EndProcedure 
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<

hwnd=OpenWindow(0, 0, 0, 300, 100, "  Animated Caption Icon", #WS_OVERLAPPEDWINDOW|1)
StickyWindow(0,1)
_AnimICO=OpenWindow(-1, 30,0,20,20, "", #PB_Window_BorderLess, hwnd)

_Img=CreateImage(-1,20,20)
_ImGad=ImageGadget(-1, 0, 0, 20,20,ImageID(_Img))

SetActiveWindow(0)
SetWindowCallback(@WinCallback())
NoFlickWin(0)
NoFlickWin(_AnimICO)

UseGadgetList(hwnd)
ti=timeGetTime_()
Freq=60 
Repeat
  Ev=WaitWindowEvent(1)
  If timeGetTime_()-ti>Freq
    AnimIco()
    ti=timeGetTime_()
  EndIf
Until Ev= #WM_CLOSE
End
Cheers

Posted: Mon Mar 16, 2009 5:25 pm
by Tomi
Very thanks Dear einander
one by one recive diffrent methods 8)

Posted: Mon Mar 16, 2009 6:21 pm
by Tomi