Can't change the color in a dategadget or make it modifiable

Just starting out? Need help? Post your questions and find answers here.
johnorourke1351
User
User
Posts: 37
Joined: Sun Nov 02, 2014 6:23 pm
Location: Los Angeles

Can't change the color in a dategadget or make it modifiable

Post by johnorourke1351 »

Hi,

I am having some trouble changing the color for a dategadget . The doc says it can be done. Another problem is that when I move a date to the dategadget it then becomes unmodifiable if i just try to modify the text in the box. If I go into the calendar with a down arrow, it will allow me to change it but not if i just edit the text in the box for the date. Why is the date unmodifiable. I have created 2 small programs that are pretty contrived to try to show this. Hope someone can answer this.

Code: Select all

;this is the smalldate.pbf file
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

Global Window_1

Enumeration FormGadget
  #Date_Test
  #String_0
  #String_1
EndEnumeration


Procedure OpenWindow_1(x = 0, y = 0, width = 600, height = 400)
  Window_1 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
  DateGadget(#Date_Test, 120, 160, 100, 25, "")
  StringGadget(#String_0, 120, 90, 100, 25, "")
  SetGadgetColor(#String_0, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_1, 120, 120, 100, 25, "")
  SetGadgetColor(#String_1, #PB_Gadget_BackColor,RGB(255,255,128))
EndProcedure

Below is code for smalldate.pb. If you enter 1 in the String_0 text box it will change the date text in the dategadget. If you enter 2 in String_1 it will enter another date in dategadget and both try to change the color unsuccessfully.

Code: Select all

XIncludeFile "smalldate.pbf" ; Include the first window definition
OpenWindow_1()
Procedure Window_1_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case #String_0
          If GetGadgetText(#String_0) = "1"
            SetGadgetText(#Date_Test,"12/31/2014")
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FFFF66)
          Else
            SetGadgetText(#Date_Test,"12/01/2014")
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FF0000) 
          EndIf
          
        Case #String_1
           If GetGadgetText(#String_1) = "2"
            SetGadgetText(#Date_Test,"12/20/2014")
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $00FFF66)
          Else
            SetGadgetText(#Date_Test,"12/02/2014")
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FF0000) 
          EndIf
        Case #Date_Test
          Debug "Date gadget used"

      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

  Repeat
      Event = WaitWindowEvent()
    
      Select EventWindow()
        Case Window_1
          Window_1_Events(Event) ; This procedure name is always window name followed by '_Events'
      EndSelect
    
    Until Event = #PB_Event_CloseWindow ; Quit on any window close
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Can't change the color in a dategadget or make it modifi

Post by RASHAD »

Hi
- SetColor will change the CalenderGadget color not the DateGadget
as per the PB manual
And of course after disable XP theme

Code: Select all

;this is the smalldate.pbf file
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

Global Window_1

Enumeration FormGadget
  #Date_Test
  #String_0
  #String_1
EndEnumeration


Procedure OpenWindow_1(x = 0, y = 0, width = 600, height = 400)
  Window_1 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
  DateGadget(#Date_Test, 120, 160, 100, 25, "")
  SetThemeAppProperties_(1)
  SetGadgetColor(#Date_Test,#PB_Gadget_FrontColor , #Red)
  StringGadget(#String_0, 120, 90, 100, 25, "")
  SetGadgetColor(#String_0, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_1, 120, 120, 100, 25, "")
  SetGadgetColor(#String_1, #PB_Gadget_BackColor,RGB(255,255,128))
EndProcedure



;Below is code For smalldate.pb. If you enter 1 in the String_0 text box it will change the date text in the dategadget. If you enter 2 in String_1 it will enter another date in dategadget And both try To change the color unsuccessfully.

;Code:
;XIncludeFile "smalldate.pbf" ; Include the first window definition
OpenWindow_1()
Procedure Window_1_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
         
        Case #String_0
          If GetGadgetText(#String_0) = "1"
            Date$ = "12/31/2014"
            SetGadgetState(#Date_Test, ParseDate("%mm/%dd/%yyyy", Date$))
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FFFF66)
          Else
            Date$ = "12/01/2014"
            SetGadgetState(#Date_Test, ParseDate("%mm/%dd/%yyyy", Date$))
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FF0000)
          EndIf
         
        Case #String_1
           If GetGadgetText(#String_1) = "2"
            Date$ = "12/20/2014"
            SetGadgetState(#Date_Test, ParseDate("%mm/%dd/%yyyy", Date$))
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $00FFF66)
          Else
            Date$ = "12/02/2014"
            SetGadgetState(#Date_Test, ParseDate("%mm/%dd/%yyyy", Date$))
            SetGadgetColor(#Date_Test, #PB_Gadget_BackColor, $FF0000)
          EndIf
        Case #Date_Test
          Debug "Date gadget used"

      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

  Repeat
      Event = WaitWindowEvent()
   
      Select EventWindow()
        Case Window_1
          Window_1_Events(Event) ; This procedure name is always window name followed by '_Events'
      EndSelect
   
    Until Event = #PB_Event_CloseWindow ; Quit on any window close
Egypt my love
johnorourke1351
User
User
Posts: 37
Joined: Sun Nov 02, 2014 6:23 pm
Location: Los Angeles

Re: Can't change the color in a dategadget or make it modifi

Post by johnorourke1351 »

Thanks Rashad.

I had looked at the help doc but it says dategadget can be set with setcolor on the setcolor doc but on its own documentation it says that only calendar can be set with set color. So I missed that. But that still doesn't answer the fact that the date cannot be changed after I make a change to it via the other 2 text boxes. Using the calendargadget portion of the control has no effect on the dategadget date. So it doesn't seem to work.

John
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Can't change the color in a dategadget or make it modifi

Post by RASHAD »

Hi John
Everything works with me as it should be
PB 5.31 x86 Win 8.1 x64
Sorry
Egypt my love
johnorourke1351
User
User
Posts: 37
Joined: Sun Nov 02, 2014 6:23 pm
Location: Los Angeles

Re: Can't change the color in a dategadget or make it modifi

Post by johnorourke1351 »

Hi
Are you sure you are duplicating the problem? enter a 1 in the first text box and then go back to the dategadget and try to change the date. It won't do it.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Can't change the color in a dategadget or make it modifi

Post by RASHAD »

I am very sure
Use the code which I posted not yours
Egypt my love
johnorourke1351
User
User
Posts: 37
Joined: Sun Nov 02, 2014 6:23 pm
Location: Los Angeles

Re: Can't change the color in a dategadget or make it modifi

Post by johnorourke1351 »

Ok. I used your code and it does work as you said. Sorry for the misunderstanding. I think I will just use a calendar gadget to change the date if need be and a string gadget to get the final date which I can make the same background colors as the others.

Thanks for your help Rashad!

John
Post Reply