PureBasic

Forums PureBasic
Nous sommes le Mer 02/Déc/2020 3:22

Heures au format UTC + 1 heure




Poster un nouveau sujet Répondre au sujet  [ 3 messages ] 
Auteur Message
 Sujet du message: Alarme pour rendez-vous
MessagePosté: Sam 27/Juil/2019 16:08 
Hors ligne
Avatar de l’utilisateur

Inscription: Ven 25/Avr/2008 11:14
Messages: 1412
bjr à tous
j'ai revisité mon code alarme pour window7
ci-joint le code de création de l' icône pour ajout dans l'option compilateur

Cordialement
Code:
;**********************************
; kernadec juillet 2019 PB 5.70
; alarme pour rendez vous
;**********************************
;
Enumeration
  #window
  #image
  #GadgetText1
  #spin
  #spin2
  #heures 
  #String
  #minutes
  #CheckBox
  #GadgetText2
EndEnumeration

FontID1=LoadFont(1, "arial", 12, #PB_Font_Bold)
FontID2=LoadFont(2, "arial", 16, #PB_Font_Bold)

buffer$=Space(128)
file$="c:\windows\media\town.mid"
mciSendString_("OPEN "+file$+" TYPE SEQUENCER ALIAS midi",buffer$,128,0)

hr=Hour(Date()):hr$=Str(Hour(Date()))
state=Minute(Date()):state$=Str(Minute(Date()))

If hr = 00 :hr$ ="00":EndIf
If state = 0 :state$ ="00":EndIf
If hr < 10 :hr$ ="0"+Str(hr):EndIf
If hr > 9 :hr$ =Str(hr):EndIf
If state < 10 :state$ ="0"+Str(state):EndIf
If state > 9 :state$ =Str(state):EndIf

OpenWindow(#window,0,0,190,25,"",#PB_Window_ScreenCentered| #PB_Window_MinimizeGadget |#PB_Window_SystemMenu)
SendMessage_(WindowID(#window),#WM_SETICON,#False,CatchImage(#image,?clock_ico_Start)) ;icon titre

StringGadget(#GadgetText1, 10, -1,48 ,23,"")
DisableGadget(#GadgetText1,1)
SpinGadget(#spin, 76, 0, 10, 24, -1, 60)
SpinGadget(#spin2, 8, 0, 10, 24, -1, 60)
SetGadgetState(#spin,Minute(Date()))
StringGadget(#heures, 20, 2, 19, 20, hr$, #PB_String_Numeric | #PB_String_BorderLess)
SetGadgetFont(#heures, FontID1)
SendMessage_(GadgetID(#heures), #EM_LIMITTEXT, 2, 0)
StringGadget(#String, 40, 2, 5, 20, ":", #PB_String_BorderLess)
SetGadgetFont(#String, FontID1)
SendMessage_(GadgetID(#String), #EM_LIMITTEXT, 1, 0)
StringGadget(#minutes, 48, 2, 20, 20, state$, #PB_String_Numeric | #PB_String_BorderLess)
SetGadgetFont(#minutes, FontID1)
SendMessage_(GadgetID(#minutes), #EM_LIMITTEXT, 2, 0)
CheckBoxGadget(#CheckBox,92,4,15,15,"")
StringGadget(#GadgetText2, 106,0,80,22,"", #PB_String_BorderLess)
SetGadgetFont(#GadgetText2, FontID2)
SetTimer_(WindowID(#window),40,1000,0)
StartTime = ElapsedMilliseconds()
;------------------------------------------------------------------------------
StartDrawing(WindowOutput(0))
SetGadgetColor(#GadgetText2,#PB_Gadget_BackColor,Point(1,1))
SetGadgetText(#GadgetText2,"Alarme")
Repeat
  If EventGadget()=#String:SetActiveGadget(#minutes):EndIf
  EventID = WaitWindowEvent()
  If (ElapsedMilliseconds()-StartTime)> 59000
    mouse_event_(#MOUSEEVENTF_MOVE, 0, 0, 0, 0)       
    StartTime = ElapsedMilliseconds()
  EndIf
  Select EventID
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #heures
          If EventType()=#PB_EventType_Change
            state=Val(GetGadgetText(#heures)):SetGadgetState(#spin2,state)
          EndIf
        Case #spin2
          hr=Val(GetGadgetText(#heures))
          state=GetGadgetState(#spin2)
          If state < 0 :hr=hr-1:SetGadgetState(#spin2,0):state=0:EndIf
          If state = 1 :hr=hr+1:SetGadgetState(#spin2,0):state=0:EndIf
          If hr < 0 :hr=23:EndIf
          If hr > 23:hr=0:EndIf
          SetGadgetText(#heures ,Str(hr))
          If hr < 10:SetGadgetText(#heures ,"0"+Str(hr)):EndIf
        Case #minutes                                     
          If EventType()=#PB_EventType_Change
            state=Val(GetGadgetText(#minutes)):SetGadgetState(#spin,state)
          EndIf
        Case #spin
          hr=Val(GetGadgetText(#heures))
          state=GetGadgetState(#spin)
          If state =-1 :state=59:SetGadgetState(#spin,59):hr=hr-1:EndIf
          If state >60 :SetGadgetState(#spin,59):hr=hr-1:EndIf
          If state =>60 And state <70 :hr=hr+1:SetGadgetState(#spin,0):state=0:EndIf
          If state <10 :SetGadgetText(#minutes,"0"+Str(GetGadgetState(#spin))):EndIf
          If state >9 :SetGadgetText(#minutes,Str(GetGadgetState(#spin))):EndIf
          If hr<0 :hr=23:EndIf
          If hr>23:hr=0:EndIf
          SetGadgetText(#heures ,Str(hr))
          If hr<10:SetGadgetText(#heures ,"0"+Str(hr)):EndIf
      EndSelect
  EndSelect
  If GetGadgetState(#CheckBox)=1
    If (Val(GetGadgetText(#heures))=Hour(Date()) And GetGadgetState(#spin)=Minute(Date()))
      StickyWindow(#window, 1)
      SetWindowState(#window,#PB_Window_Normal)
      SetGadgetFont(#GadgetText2, FontID2)
      SetGadgetColor(#GadgetText2,#PB_Gadget_FrontColor,RGB(255,0,0))
      SetGadgetText(#GadgetText2," "+GetGadgetText(#heures)+":"+GetGadgetText(#minutes))
      ;PlaySound(0,1)
      Repeat
        Event=WindowEvent()
        FlashWindow_(WindowID(#window),1)
        Delay(30)
        FlashWindow_(WindowID(#window),0)
        mciSendString_("PLAY MIDI",0,0,0)
        SetWindowTitle(#window,Str(Hour(Date()))+":"+Str(Minute(Date()))+":"+Str(Second(Date())))
        Select Event
          Case #SC_RESTORE   
            SetWindowState(#window,#PB_Window_Normal)
          Case #PB_Event_CloseWindow
            EventID=#PB_Event_CloseWindow
        EndSelect
        If GetGadgetState(#CheckBox)=0
          SetGadgetColor(#GadgetText2,#PB_Gadget_BackColor,Point(1,1))
          SetGadgetColor(#GadgetText2,#PB_Gadget_FrontColor,#Black)
          mciSendString_("STOP MIDI",0,0,0)
        SetGadgetText(#GadgetText2,"Alarme"):Break:EndIf
      Until Event=#PB_Event_CloseWindow
    EndIf
  EndIf
  ;              display the time in the title bar
  SetWindowTitle(#window,Str(Hour(Date()))+":"+Str(Minute(Date()))+":"+Str(Second(Date())))
Until EventID=#PB_Event_CloseWindow
mciSendString_("CLOSE MIDI",0,0,0)
StopDrawing() 
;  IncludeBinary "clock.ico" [?clock_ico_Start , ?clock_ico_End]
;{ Size = 766 bytes
DataSection
  ; PureBin2Data header
  Data.l 766
  Data.b 0
  ; Data
  clock_ico_Start:
  Data.l $00010000,$20200001,$00000010,$02E80000,$00160000,$00280000,$00200000,$00400000,$00010000,$00000004,$02800000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00800000,$00FF0000,$FFFF0000,$00000000,$800000FF,$FF000080,$808000FF,$C0C00080
  Data.l $FFFF00C0,$000000FF,$00000000,$00000000,$00000000,$00000000,$00000000,$00000000,$00004004,$00000000,$00400400,$00000000
  Data.l $04004407,$40444444,$00704400,$00000000,$44400400,$44444444,$00004004,$00000000,$40440000,$04000000,$00000044,$00000000
  Data.l $08447400,$90982288,$00004704,$00000000,$89084407,$89892289,$00704480,$00000000,$28814074,$92999898,$00470429,$00000000
  Data.l $29820844,$92999989,$00449029,$07000000,$98988840,$99999999,$70049999,$04000000,$89891240,$99999999,$40042299,$74000000
  Data.l $99982208,$99899999,$47902299,$44000000,$99898908,$99899099,$44909999,$44000000,$99989808,$88889099,$44909988,$44000000
  Data.l $99892901,$00000490,$44209209,$44000000,$99982801,$99899099,$44209299,$44000000,$99898908,$99899099,$44909999,$44000000
  Data.l $99989808,$99899099,$44909999,$74000000,$89298208,$99899099,$47902299,$04000000,$99288140,$99899099,$40042199,$07000000
  Data.l $89898844,$99899099,$70449899,$00000000,$28824844,$92999099,$00448429,$00000000,$29814474,$92998989,$00474418,$00000000
  Data.l $88084407,$88881188,$00704480,$00000000,$08447400,$80881188,$00004744,$00000000,$40440770,$04000000,$00077044,$07000000
  Data.l $44040050,$44444444,$70050740,$00000000,$04708085,$00444444,$00550507,$00000000,$70606658,$07000000,$00555508,$07000000
  Data.l $50688689,$06000000,$70588866,$00000000,$85669606,$66100002,$00809668,$00000000,$50680907,$06102103,$00706099,$00000000
  Data.l $00000700,$00000000,$00007000,$FFF80000,$60F87FFC,$00FC7F18,$00FEFF00,$00FCFF01,$00F8FF00,$00F07F00,$00F03F00,$00E03F00
  Data.l $00E01F00,$00C01F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00E00F00,$00E01F00,$00F01F00
  Data.l $00F03F00,$00F83F00,$00FC7F00,$00F6FF00,$80E1BF01,$60E01F06,$1CE01F18,$0CE01FE0,$00F01FC0,$08F83F00,$1FFE7F40
  Data.b $E1,$FF
  clock_ico_End:
EndDataSection ;}
End


code de l’Icône
Code:
CatchImage(0,?clock_ico_Start)

Procedure ExpandBinaryfile(Filename.s) 
  If CreateFile(1, Filename) ;Create File 
                             ;Use File 1 
    L1= ?clock_ico_End-?clock_ico_Start    ;get the size of it 
    WriteData(1,?clock_ico_Start,L1)       ;write it down to the file 
    CloseFile(1)                           ; Close Filepointer 
  EndIf 
  ProcedureReturn 
EndProcedure 

ExpandBinaryfile("c:\PureBasic\clock.ico") 

; IncludeBinary "clock.ico" [?clock_ico_Start , ?clock_ico_End]
;{ Size = 766 bytes
DataSection
  ; PureBin2Data header
  Data.l 766
  Data.b 0
  ; Data
  clock_ico_Start:
  Data.l $00010000,$20200001,$00000010,$02E80000,$00160000,$00280000,$00200000,$00400000,$00010000,$00000004,$02800000,$00000000
  Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$80000080,$80000000,$00800080,$00800000,$80800080,$C0C00000,$808000C0
  Data.l $00000080,$FF0000FF,$FF000000,$00FF00FF,$00FF0000,$FFFF00FF,$FFFF0000,$000000FF,$00000000,$00000000,$00000000,$00000000
  Data.l $0000B708,$00000000,$00803700,$00000000,$03700B00,$30333333,$00007003,$00000000,$30070000,$03000000,$00000070,$00000000
  Data.l $07308000,$F0F7CC77,$00000803,$00000000,$7F070308,$7F7FCC7F,$00803070,$00000000,$C7743080,$FCFFF7F7,$000803CF,$00000000
  Data.l $CF7C0707,$FCFFFF7F,$0030F0CF,$08000000,$F7F777B0,$FFFFFFFF,$8003FFFF,$00000000,$7F7F4C70,$FFFFFFFF,$0003CCFF,$8B000000
  Data.l $FFF7CC07,$FF7FFFFF,$38F0CCFF,$07000000,$FF7F7F07,$FF7FF0FF,$30F0FFFF,$0B000000,$FFF7F707,$7777F0FF,$30F0FF77,$07000000
  Data.l $FF7FCF04,$000009F0,$30C0FC0F,$0B000000,$FFF7C704,$FF7FF0FF,$30C0FCFF,$07000000,$FF7F7F07,$FF7FF0FF,$30F0FFFF,$0B000000
  Data.l $FFF7F707,$FF7FF0FF,$30F0FFFF,$87000000,$7FCF7C07,$FF7FF0FF,$38F0CCFF,$00000000,$FFC774B0,$FF7FF0FF,$0003C4FF,$08000000
  Data.l $7F7F7770,$FF7FF0FF,$8003F7FF,$00000000,$C77C070B,$FCFFF0FF,$003070CF,$00000000,$CF74B080,$FCFF7F7F,$00080347,$00000000
  Data.l $77070B08,$77774477,$00803070,$00000000,$07B08000,$70774477,$00000803,$00000000,$700B0880,$03000000,$00088030,$08000000
  Data.l $0B000030,$30B7B7BB,$80030800,$00000000,$00807073,$00000000,$00330308,$00000000,$80B0BB37,$08000000,$00333307,$08000000
  Data.l $30B77B7F,$0B000000,$803777BB,$00000000,$73BBFB0B,$BB40000C,$0070FBB7,$00000000,$30B70F08,$0B40C40E,$0080B0FF,$00000000
  Data.l $00000800,$00000000,$00008000,$FFF80000,$60F87FFC,$00FC7F18,$00FEFF00,$00FCFF01,$00F8FF00,$00F07F00,$00F03F00,$00E03F00
  Data.l $00E01F00,$00C01F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00C00F00,$00E00F00,$00E01F00,$00F01F00
  Data.l $00F03F00,$00F83F00,$00FC7F00,$00F6FF00,$80E1BF01,$60E01F06,$1CE01F18,$0CE01FE0,$00F01FC0,$08F83F00,$1FFE7F40
  Data.b $E1,$FF
  clock_ico_End:
EndDataSection ;}


Haut
 Profil  
Répondre en citant le message  
 Sujet du message: Re: Alarme pour rendez-vous
MessagePosté: Dim 28/Juil/2019 20:27 
Hors ligne

Inscription: Mer 13/Sep/2017 14:35
Messages: 69
Localisation: Picardie (Somme)
Citation:
Merci pour le partage kernadec :wink: Bien vu pour > musique, vibration de la fenêtre et clignotements colorés ... :roll: W10 PB 5.70 LTS


Haut
 Profil  
Répondre en citant le message  
 Sujet du message: Re: Alarme pour rendez-vous
MessagePosté: Dim 28/Juil/2019 22:20 
Hors ligne
Avatar de l’utilisateur

Inscription: Ven 25/Avr/2008 11:14
Messages: 1412
bsr Mouillard
je suis heureux que cela te soit utile
je n'ai pas utilisé de date car je l'utilise juste pour mes rendez vous du jour..
car quand on code la concentration comprime le temps à notre insu :mrgreen:

Cordialement


Haut
 Profil  
Répondre en citant le message  
Afficher les messages postés depuis:  Trier par  
Poster un nouveau sujet Répondre au sujet  [ 3 messages ] 

Heures au format UTC + 1 heure


Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 2 invités


Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages

Rechercher:
Aller à:  
cron

 


Powered by phpBB © 2008 phpBB Group | Traduction par: phpBB-fr.com
subSilver+ theme by Canver Software, sponsor Sanal Modifiye