Page 1 of 1

Square round the StringGadget

Posted: Tue Feb 05, 2019 5:33 pm
by Little_man
After starting the program, pressing on the "Remove" button.

How to remove the square round the StringGadget (#Main_S1) ?.

Code: Select all


;Purebasic: 5.11
;OS:        Windows 10, x64

EnableExplicit

Enumeration
  #Main
  #Main_S1:#Main_S2
  #Main_B1:#Main_B2:#Main_B3
EndEnumeration

Global.i Event

Global.i Backcolor = 16711680
Global.i Fontcolor = 16777215

Global FontID0 = LoadFont(0, "Verdana", 8, #PB_Font_Bold | #PB_Font_Italic)

Procedure Main()
  OpenWindow(#Main, 0, 0, 340, 200, "Test", #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  StringGadget(#Main_S1,  20, 40, 100, 20, "12:00", #PB_Text_Center): SetGadgetFont(#Main_S1, FontID0)
  StringGadget(#Main_S2, 120, 40, 100, 20, "14:00", #PB_Text_Center): SetGadgetFont(#Main_S2, FontID0)
  SetGadgetColor(#Main_S1, #PB_Gadget_BackColor, Backcolor): SetGadgetColor(#Main_S1, #PB_Gadget_FrontColor, Fontcolor)
  SetGadgetColor(#Main_S2, #PB_Gadget_BackColor, Backcolor): SetGadgetColor(#Main_S2, #PB_Gadget_FrontColor, Fontcolor)
  ButtonGadget(#Main_B1, 225, 39, 100, 22, "Remove")
  ButtonGadget(#Main_B2, 225, 64, 100, 22, "Change")
  ButtonGadget(#Main_B3, 70, 170, 200, 25, "End Program")
  
  SetActiveGadget(#Main_S1)
EndProcedure

Main()

Repeat
  Event = WaitWindowEvent()
  Select EventGadget()
    ;-#Main_E.
    Case #Main_B1
      SetGadgetText(#Main_S1, #NULL$): DisableGadget(#Main_S1, 1)
      SetGadgetText(#Main_S2, #NULL$): DisableGadget(#Main_S2, 1)
      
    Case #Main_B2
      DisableGadget(#Main_S1, 0)
      DisableGadget(#Main_S2, 0)
      
    Case #Main_B3
      End
  EndSelect
Until Event = #PB_Event_CloseWindow
End
Regards,
Little_man

Re: Square round the StringGadget

Posted: Tue Feb 05, 2019 7:57 pm
by Christophe_fr
can be like that

Code: Select all

;Purebasic: 5.11
;OS:        Windows 10, x64

EnableExplicit

Enumeration
  #Main
  #Main_S1:#Main_S2
  #Main_B1:#Main_B2:#Main_B3
EndEnumeration

Global.i Event

Global.i Backcolor = 16711680
Global.i Fontcolor = 16777215

Global FontID0 = LoadFont(0, "Verdana", 8, #PB_Font_Bold | #PB_Font_Italic)

Procedure Main()
  OpenWindow(#Main, 0, 0, 340, 200, "Test", #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  StringGadget(#Main_S1,  20, 40, 100, 20, "12:00", #PB_Text_Center): SetGadgetFont(#Main_S1, FontID0)
  StringGadget(#Main_S2, 120, 40, 100, 20, "14:00", #PB_Text_Center): SetGadgetFont(#Main_S2, FontID0)
  SetGadgetColor(#Main_S1, #PB_Gadget_BackColor, Backcolor): SetGadgetColor(#Main_S1, #PB_Gadget_FrontColor, Fontcolor)
  SetGadgetColor(#Main_S2, #PB_Gadget_BackColor, Backcolor): SetGadgetColor(#Main_S2, #PB_Gadget_FrontColor, Fontcolor)
  ButtonGadget(#Main_B1, 225, 39, 100, 22, "Remove")
  ButtonGadget(#Main_B2, 225, 64, 100, 22, "Change")
  ButtonGadget(#Main_B3, 70, 170, 200, 25, "End Program")
 
  SetActiveGadget(#Main_S1)
EndProcedure

Main()

Repeat
  Event = WaitWindowEvent()
  Select EventGadget()
    ;-#Main_E.
    Case #Main_B1
      SetGadgetText(#Main_S1, #Null$): DisableGadget(#Main_S1, 1)
      SetGadgetText(#Main_S2, #Null$): DisableGadget(#Main_S2, 1)
     FreeGadget(#Main_S1)
   Case #Main_B2
     If IsGadget(#Main_S1)=0
       StringGadget(#Main_S1,  20, 40, 100, 20, "12:00", #PB_Text_Center)
       SetGadgetFont(#Main_S1, FontID0):SetGadgetColor(#Main_S1, #PB_Gadget_BackColor, Backcolor)
       SetGadgetColor(#Main_S1, #PB_Gadget_FrontColor, Fontcolor)
       SetActiveGadget(#Main_S1)
     EndIf
      DisableGadget(#Main_S1, 0)
      DisableGadget(#Main_S2, 0)
     
    Case #Main_B3
      End
  EndSelect
Until Event = #PB_Event_CloseWindow
End

sorry for my English translated from french by google

Re: Square round the StringGadget

Posted: Tue Feb 05, 2019 11:32 pm
by Little_man
Thanks: Christophe_fr

My choice is what I specified on "Tue Feb 05, 2019 7:57 pm".

Little_Man