Voici au final la solution que je vais utiliser.
Merci Zorro et Ar-s pour les idées.
C'est loin d'être parfait ... mais au moins ça fonctionne
Code : Tout sélectionner
Procedure DateGadgetEx(Gadget.i,X.l,Y.l,Width.l,Height.l)
Protected D.i,GdtTmp.i
GdtTmp=Gadget
FrameGadget(GdtTmp,X,Y,Width,Height,"",#PB_Frame_Double)
SetGadgetColor(GdtTmp, #PB_Gadget_BackColor , RGB(255,255,255))
X=X+2:Y=Y+2:Height-4
GdtTmp=GdtTmp+1:DateGadget(GdtTmp,X,Y,15,Height," "):D.i=GetGadgetState(GdtTmp)
;Year
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,25,Height,FormatDate("%yyyy",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Year YYYY"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,4)
;/
GdtTmp=GdtTmp+1:TextGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,8,Height,"/"):SetGadgetColor(GdtTmp, #PB_Gadget_BackColor , RGB(255,255,255))
;Month
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,15,Height,FormatDate("%mm",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Month MM (1 to 12)"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,2)
;/
GdtTmp=GdtTmp+1:TextGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,8,Height,"/"):SetGadgetColor(GdtTmp, #PB_Gadget_BackColor , RGB(255,255,255))
;Day
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,15,Height,FormatDate("%dd",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Day DD (01 to 31)"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,2)
;Hour
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1)+15,Y,15,Height,FormatDate("%hh",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Hour HH (00 to 23)"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,2)
;:
GdtTmp=GdtTmp+1:TextGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,8,Height,":"):SetGadgetColor(GdtTmp, #PB_Gadget_BackColor , RGB(255,255,255))
;Minute
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,15,Height,FormatDate("%ii",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Minute II (00 to 59)"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,2)
;:
GdtTmp=GdtTmp+1:TextGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,8,Height,":"):SetGadgetColor(GdtTmp, #PB_Gadget_BackColor , RGB(255,255,255))
;Seconds
GdtTmp=GdtTmp+1:StringGadget(GdtTmp,GadgetX(GdtTmp-1)+GadgetWidth(GdtTmp-1),Y,15,Height,FormatDate("%ss",D),#PB_String_Numeric|#PB_String_BorderLess):GadgetToolTip(GdtTmp,"Second SS (00 to 59)"): SetGadgetAttribute(GdtTmp,#PB_String_MaximumLength,2)
ResizeGadget(Gadget,#PB_Ignore,#PB_Ignore,GadgetX(GdtTmp)+GadgetWidth(GdtTmp)-GadgetX(Gadget)+2,#PB_Ignore)
; Gmt
GdtTmp=GdtTmp+1:ComboBoxGadget(GdtTmp,GadgetX(Gadget)+GadgetWidth(Gadget)+15,GadgetY(Gadget),150,GadgetHeight(Gadget))
EndProcedure
Procedure DateGadgetExEvent(Event.i,Gadget.i)
Protected D.i, DTxt.s
If Event=#PB_Event_Gadget
If EventGadget()>=Gadget And #PB_EventType_Change
Select EventGadget()
Case Gadget+1
D=GetGadgetState(Gadget+1)
SetGadgetText(Gadget+2,FormatDate("%yyyy",D)) ; Year
SetGadgetText(Gadget+4,FormatDate("%mm",D)) ; Month
SetGadgetText(Gadget+6,FormatDate("%dd",D)) ; Day
SetGadgetText(Gadget+7,FormatDate("%hh",D)) ; Hour
SetGadgetText(Gadget+9,FormatDate("%ii",D)) ; Minute
SetGadgetText(Gadget+11,FormatDate("%ss",D)) ; Second
Case Gadget+2,Gadget+4,Gadget+6,Gadget+7,Gadget+9,Gadget+11;Year
DTxt=GetGadgetText(Gadget+2)+":"+GetGadgetText(Gadget+4)+":"+GetGadgetText(Gadget+6)+" "+GetGadgetText(Gadget+7)+":"+GetGadgetText(Gadget+9)+":"+GetGadgetText(Gadget+11)
D=ParseDate("%yyyy:%mm:%dd %hh:%ii:%ss",DTxt)
SetGadgetState(Gadget+1,D)
EndSelect
EndIf
EndIf
EndProcedure
Procedure AddTimeZone(Gadget.i,selected.l,Full.b=#True)
Protected Zone.s,p.l
If IsGadget(Gadget)
If GadgetType(Gadget)<>#PB_GadgetType_ComboBox
Gadget=Gadget+12
EndIf
If IsGadget(Gadget) And GadgetType(Gadget)=#PB_GadgetType_ComboBox
Restore TimeZone
Repeat
Read.s Zone
If Zone<>"END"
If Full=#False
p.l=FindString(Zone," ",0)
Zone=Left(Zone,p)
EndIf
Debug Zone
AddGadgetItem(Gadget,-1,Zone)
EndIf
Until Zone="END"
EndIf
EndIf
EndProcedure
DataSection
TimeZone:
Data.s "GMT+0:00 Greenwich Mean Time"
Data.s "GMT+1:00 European Central Time"
Data.s "GMT+2:00 Eastern European Time"
Data.s "GMT+2:00 (Arabic) Egypt Standard Time"
Data.s "GMT+3:00 Eastern African Time "
Data.s "GMT+3:30 Middle East Time"
Data.s "GMT+4:00 Near East Time"
Data.s "GMT+5:00 Pakistan Lahore Time"
Data.s "GMT+5:30 India Standard Time"
Data.s "GMT+6:00 Bangladesh Standard Time"
Data.s "GMT+7:00 Vietnam Standard Time"
Data.s "GMT+8:00 China Taiwan Time "
Data.s "GMT+9:00 Japan Standard Time "
Data.s "GMT+9:30 Australia Central Time"
Data.s "GMT+10:00 Australia Eastern Time"
Data.s "GMT+11:00 Solomon Standard Time"
Data.s "GMT+12:00 New Zealand Standard Time"
Data.s "GMT-11:00 Midway Islands Time"
Data.s "GMT-10:00 Hawaii Standard Time"
Data.s "GMT-9:00 Alaska Standard Time"
Data.s "GMT-8:00 Pacific Standard Time"
Data.s "GMT-7:00 Phoenix Standard Time"
Data.s "GMT-7:00 Mountain Standard Time"
Data.s "GMT-6:00 Central Standard Time"
Data.s "GMT-5:00 Eastern Standard Time"
Data.s "GMT-5:00 Indiana Eastern Standard Time"
Data.s "GMT-4:00 Puerto Rico And US Virgin Islands Time"
Data.s "GMT-3:30 Canada Newfoundland Time"
Data.s "GMT-3:00 Argentina Standard Time"
Data.s "GMT-3:00 Brazil Eastern Time"
Data.s "GMT-1:00 Central African Time"
Data.s "END"
EndDataSection
CompilerIf #PB_Compiler_IsMainFile
Enumeration
#Win
#gadget_date
#gadget_autre = #gadget_date+13
EndEnumeration
If OpenWindow(#win, 0, 0, 500, 250,"DateGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
DateGadgetEx(#gadget_date,5,5,250,20)
AddTimeZone(#gadget_date,0,#True)
Repeat
Event=WaitWindowEvent()
DateGadgetExEvent(Event,#gadget_date)
Select Event
Case #PB_Event_Gadget
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
CompilerEndIf