* * *    
Главная » Статьи » Код PB

Просмотров: 1398 | Дата: 28.06.2025 | Коментарии (0)

Мерсающий текст




Code
Procedure makeWindow()
   
 
OpenWindow(0,400,400,400,400,"myWindow")
 
ListIconGadget(1,0,0,400,400,"myicongadget",200)
 
For x = 0 To 20
 
AddGadgetItem(1,-1,"hello " + Str(x))
 
Delay(1)
 
SetGadgetItemColor(1,x,#PB_Gadget_FrontColor,$FFFFFF)  
 
Next
   
 
EndProcedure

 
Procedure fade(dummy)
 
Protected x,color
 
Repeat
   
 
For x = 0 To 20
  color
= GetGadgetItemColor(1,x,#PB_Gadget_FrontColor)
   
 
If color = -1
  color
= 0
 
EndIf
   
 
If color < $FFFFFF
  color
+ $010101
 
If color > $FFFFFF
  color
= $FFFFFF
 
EndIf
 
SetGadgetItemColor(1,x,#PB_Gadget_FrontColor,color)  
 
EndIf

 
Next
 
Delay(1)
 
ForEver
 
EndProcedure

 
Procedure refreshRandom(dummy)
 
Repeat
 
Delay(Random(1000) + 200)
 
SetGadgetItemColor(1,Random(20),#PB_Gadget_FrontColor,color)  
 
ForEver
 
EndProcedure

 makeWindow
()
 
CreateThread(@fade(),0)
 
CreateThread(@refreshRandom(),0)

 
Repeat
 
Until WaitWindowEvent() = #PB_Event_CloseWindow


Code
Enumeration
 
#WIN
 
#Affiche
 
#gadgetone
 
EndEnumeration

 
Structure stFlashError  
  count
.i
  gadget
.i
 
EndStructure

 
Global muFlash.i = CreateMutex()
 
Global NewList gFlash.stFlashError()

 
Procedure FlashError( a.l, b.l, dwUser.l, d.l, E.i )
   
 
Protected uDelay.i
   
 
If TryLockMutex( muFlash )
 
ChangeCurrentElement( gFlash(), dwUser )
  gFlash
()\count - 1
  uDelay
= gFlash()\count * 15
   
 
If uDelay < 125 : uDelay = 125 : EndIf
   
 
If gFlash()\count % 2
 
SetGadgetColor( gFlash()\gadget, #PB_Gadget_BackColor, $E81717 )  
 
Else
 
SetGadgetColor( gFlash()\gadget, #PB_Gadget_BackColor, -1 )
 
EndIf  
   
 
If gFlash()\count > 0  
  timeSetEvent_
( uDelay, 50, @FlashError(), dwUser, #TIME_ONESHOT )  
 
EndIf
   
 
UnlockMutex( muFlash )
 
EndIf  
   
 
EndProcedure

 
If OpenWindow(#WIN, 450, 200, 377, 24, "clignote", #PB_Window_SystemMenu|#PB_Window_TitleBar)
 
StringGadget(#Affiche, 0, 0, 375, 22, "My Text", #PB_String_ReadOnly)
   
 
EndIf

 
LockMutex( muFlash )
 
AddElement( gFlash() )  
  gFlash
()\count = 16
  gFlash
()\gadget = #Affiche  
  d
= @gFlash()
 
UnlockMutex( muFlash )
   
  timeSetEvent_
( 25, 10, @FlashError(), d, #TIME_ONESHOT )

 
Repeat
 
Select WaitWindowEvent()
   
 
Case #PB_Event_CloseWindow
 
Select EventWindow()
 
Case #WIN
 
CloseWindow(#WIN)
 
Break
 
EndSelect
 
EndSelect
 
ForEver










Сайт посвящён языку программирования PureBasic — коммерческий компилятор языка программирования, использующего синтаксис BASIC. Предназначен для создания кроссплатформенных приложений для AmigaOS, Linux, Microsoft Windows, Windows NT и Mac OS X. Разработан компанией Fantaisie Software.