2 Notebooks, beide Windows 10 64bit aktuell

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
udg
Beiträge: 566
Registriert: 20.06.2013 23:27

Re: 2 Notebooks, beide Windows 10 64bit aktuell

Beitrag von udg »

Ich hab dir den Code mal angepasst, dass dein Kalender bei jeder Auflösung zu sehen ist (noch extra hinzugefügt, dass man den Kalender auch mit der Maus verschieben kann)...
Getestet von 800*600pix bis 1920*1080pix und gleichzeitig angeschlossenen 3 TFT am PC ---> läuft :)

Code: Alles auswählen

UsePNGImageDecoder()

Global Bild_0 = 0, Bild_1 = 1
Global Dim Nahual.s(20)
Global Date_1 = Date(2012,12,22,0,0,0)
Global Window_0
Global Container_0, Image_0, Image_1, Text_0, Text_1

Declare Timer_Click()

Enumeration FormFont
  #Font_Window_0_0
EndEnumeration

LoadFont(#Font_Window_0_0,"FreeSerif", 9, #PB_Font_Bold)

Nahual.s(1)="Alligator" : Nahual.s(2)="Wind" : Nahual.s(3)="Nacht" : Nahual.s(4)="Eidechse"
Nahual.s(5)="Schlange" : Nahual.s(6)="Tod" : Nahual.s(7)="Hirsch" : Nahual.s(8)="Stern"
Nahual.s(9)="Wasser" : Nahual.s(10)="Hund" : Nahual.s(11)="Affe" : Nahual.s(12)="Straße"
Nahual.s(13)="Stab" : Nahual.s(14)="Jaguar" : Nahual.s(15)="Adler" : Nahual.s(16)="Krieger"
Nahual.s(17)="Erde" : Nahual.s(18)="Obsidian" : Nahual.s(19)="Regensturm" : Nahual.s(20)="Sonne"

Procedure OpenWindow_0()
  
  Window_0 =  OpenWindow(#PB_Any,(GetSystemMetrics_(#SM_CXSCREEN)-200)/1, 0, 104, 194, "",#PB_Window_Normal | #PB_Window_BorderLess)
  SetWindowColor(Window_0, RGB(0,0,255))
  
  Container_0 = ContainerGadget(#PB_Any, 2, 22, 100, 150)
  SetGadgetColor(Container_0, #PB_Gadget_BackColor,RGB(255,255,255))
  Image_1 = ImageGadget(#PB_Any, 0, 0, 100, 100, 0)
  Image_0 = ImageGadget(#PB_Any, 0, 100, 100, 50, 0)
  CloseGadgetList()
  Text_0 = TextGadget(#PB_Any, 2, 2, 100, 18, "", #PB_Text_Center)
  Text_1 = TextGadget(#PB_Any, 2, 174, 100, 18, "", #PB_Text_Center)
  SetGadgetFont(Text_0, FontID(#Font_Window_0_0))
  SetGadgetFont(Text_1, FontID(#Font_Window_0_0))
  SetGadgetColor(Text_0, #PB_Gadget_BackColor, RGB(255,255,255))
  SetGadgetColor(Text_1, #PB_Gadget_BackColor, RGB(255,255,255))
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
        Case 124
          ProcedureReturn #False
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
        
  EndSelect
  ProcedureReturn #True
EndProcedure
Procedure Timer_Click()
  Date_2 = Date()
  Tage.i = (Date_2-Date_1) / (3600*24)
  Tage.i + 1872000
  Baktun.i = Tage.i / 144000
  Rest.i = Tage.i % 144000
  Katun.i =  Rest.i / 7200
  Rest.i = Rest.i % 7200
  Tun.i = Rest.i / 360
  Rest.i = Rest.i % 360
  Uinal.i = Rest.i / 20
  Kin.i = Rest.i % 20
  Tzolkin.i = (Tage.i - 100) % 260
  Siegel.i = Tzolkin.i % 20 + 1
  Ton.i = Tzolkin.i % 13 + 1
  SetGadgetText(Text_0,Str(Baktun.i)+"."+Str(Katun.i)+"."+Str(Tun.i)+"."+Str(Uinal.i)+"."+Str(Kin.i)+" - "+Str(Tzolkin.i))
  SetGadgetText(Text_1,Str(Ton.i)+" "+Nahual.s(Siegel.i))
  
  Select Ton.i
    Case 1
      CatchImage(Bild_0, ?Ton_01)
    Case 2
      CatchImage(Bild_0, ?Ton_02)
    Case 3
      CatchImage(Bild_0, ?Ton_03)
    Case 4
      CatchImage(Bild_0, ?Ton_04)
    Case 5
      CatchImage(Bild_0, ?Ton_05)
    Case 6
      CatchImage(Bild_0, ?Ton_06)
    Case 7
      CatchImage(Bild_0, ?Ton_07)
    Case 8
      CatchImage(Bild_0, ?Ton_08)
    Case 9
      CatchImage(Bild_0, ?Ton_09)
    Case 10
      CatchImage(Bild_0, ?Ton_10)
    Case 11
      CatchImage(Bild_0, ?Ton_11)
    Case 12
      CatchImage(Bild_0, ?Ton_12)
    Case 13
      CatchImage(Bild_0, ?Ton_13)
  EndSelect
  Select Siegel.i
    Case 1
      CatchImage(Bild_1, ?Siegel_01)
    Case 2
      CatchImage(Bild_1, ?Siegel_02)
    Case 3
      CatchImage(Bild_1, ?Siegel_03)
    Case 4
      CatchImage(Bild_1, ?Siegel_04)
    Case 5
      CatchImage(Bild_1, ?Siegel_05)
    Case 6
      CatchImage(Bild_1, ?Siegel_06)
    Case 7
      CatchImage(Bild_1, ?Siegel_07)
    Case 8
      CatchImage(Bild_1, ?Siegel_08)
    Case 9
      CatchImage(Bild_1, ?Siegel_09)
    Case 10
      CatchImage(Bild_1, ?Siegel_10)
    Case 11
      CatchImage(Bild_1, ?Siegel_11)
    Case 12
      CatchImage(Bild_1, ?Siegel_12)
    Case 13
      CatchImage(Bild_1, ?Siegel_13)
    Case 14
      CatchImage(Bild_1, ?Siegel_14)
    Case 15
      CatchImage(Bild_1, ?Siegel_15)
    Case 16
      CatchImage(Bild_1, ?Siegel_16)
    Case 17
      CatchImage(Bild_1, ?Siegel_17)
    Case 18
      CatchImage(Bild_1, ?Siegel_18)
    Case 19
      CatchImage(Bild_1, ?Siegel_19)
    Case 20
      CatchImage(Bild_1, ?Siegel_20)
  EndSelect
  
  SetGadgetState(Image_0, ImageID(Bild_0))
  SetGadgetState(Image_1, ImageID(Bild_1))
EndProcedure

OpenWindow_0()
CreateImage(Bild_0, 100, 100, 24, RGB(255,255,255))
CreateImage(Bild_1, 10, 50, 24, RGB(255,255,255))

AddWindowTimer(Window_0, 123, 10000)
AddKeyboardShortcut(Window_0, #PB_Shortcut_Escape, 124)
Timer_Click()

Repeat
  event = WaitWindowEvent()
  prglauf = Window_0_Events(event)
  If event = #PB_Event_Timer And EventTimer() = 123
    Timer_Click()
  EndIf
;//////////////////////////////////////////////  
;- EIN EXTRA NOCH DAZU: DRAG KALENDER MIT MAUS
;//////////////////////////////////////////////
  Select Event
      Case #WM_LBUTTONDOWN    
        If WindowMouseX(Window_0) >= 0 And WindowMouseX(Window_0) <= 104 And WindowMouseY(Window_0) >= 0 And WindowMouseY(Window_0) <= 30
           SendMessage_(WindowID(Window_0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)    
         EndIf
  EndSelect      
  
Until prglauf = #False
End

;{ DATASECTION
DataSection
  Ton_01:
  IncludeBinary "Zahl/T01.png"
  Ton_02:
  IncludeBinary "Zahl/T02.png"
  Ton_03:
  IncludeBinary "Zahl/T03.png"
  Ton_04:
  IncludeBinary "Zahl/T04.png"
  Ton_05:
  IncludeBinary "Zahl/T05.png"
  Ton_06:
  IncludeBinary "Zahl/T06.png"
  Ton_07:
  IncludeBinary "Zahl/T07.png"
  Ton_08:
  IncludeBinary "Zahl/T08.png"
  Ton_09:
  IncludeBinary "Zahl/T09.png"
  Ton_10:
  IncludeBinary "Zahl/T10.png"
  Ton_11:
  IncludeBinary "Zahl/T11.png"
  Ton_12:
  IncludeBinary "Zahl/T12.png"
  Ton_13:
  IncludeBinary "Zahl/T13.png"
  Siegel_01:
  IncludeBinary "Symbol/S01.png"
  Siegel_02:
  IncludeBinary "Symbol/S02.png"
  Siegel_03:
  IncludeBinary "Symbol/S03.png"
  Siegel_04:
  IncludeBinary "Symbol/S04.png"
  Siegel_05:
  IncludeBinary "Symbol/S05.png"
  Siegel_06:
  IncludeBinary "Symbol/S06.png"
  Siegel_07:
  IncludeBinary "Symbol/S07.png"
  Siegel_08:
  IncludeBinary "Symbol/S08.png"
  Siegel_09:
  IncludeBinary "Symbol/S09.png"
  Siegel_10:
  IncludeBinary "Symbol/S10.png"
  Siegel_11:
  IncludeBinary "Symbol/S11.png"
  Siegel_12:
  IncludeBinary "Symbol/S12.png"
  Siegel_13:
  IncludeBinary "Symbol/S13.png"
  Siegel_14:
  IncludeBinary "Symbol/S14.png"
  Siegel_15:
  IncludeBinary "Symbol/S15.png"
  Siegel_16:
  IncludeBinary "Symbol/S16.png"
  Siegel_17:
  IncludeBinary "Symbol/S17.png"
  Siegel_18:
  IncludeBinary "Symbol/S18.png"
  Siegel_19:
  IncludeBinary "Symbol/S19.png"
  Siegel_20:
  IncludeBinary "Symbol/S20.png"
EndDataSection
;}

Code: Alles auswählen

Window_0 =  OpenWindow(#PB_Any,(GetSystemMetrics_(#SM_CXSCREEN)-200)/1, 0, 104, 194, "",#PB_Window_Normal | #PB_Window_BorderLess)
-200 kannst du anpassen. Ist der Abstand zum Rechten Bildschirmrand.
die Null nach: -200)/1, kannst du auch positiv erhöhen (zb. 30). Dies schiebt dir den Kalender vom oberen Bildschirmrand 30pix nach unten.
PB v5.43 LTS + v6.02 LTS | Windows 7 x86 + 11 x64 - Gforce RTX 4090 - AMD Ryzen 9 5900X 12-Core Processor 4.2 GHz - 64,0 GB RAM,
ASUSTEK TUF Gaming X570 Plus
ASUS ROG Thor-1200P Platinum (1200W, Aura Sync, OLED Display, 0dB-Cooling)
1x 1 TByte Samsung MZ-V7S500BW 970 EVO Plus 1 TB NVMe M.2 Internal SSD
1x 2 TByte Samsung MZ-V7S2T0BW 970 EVO Plus 2 TB NVMe M.2 Internal SSD
von BiSONTE!. Kauft Hardware gern bei ihm.
Monitor:
LG 38GL950G-B 95 (38 Zoll) Ultragear Curved 21: 9 UltraWide QHD IPS
Antworten