weird behavioural of StringGadget

Just starting out? Need help? Post your questions and find answers here.
morosh
Enthusiast
Enthusiast
Posts: 333
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

weird behavioural of StringGadget

Post by morosh »

Hello:
in the following snippet, I can't get the focus on the String gadget #String+14, next to "Resolution" by clicking the mouse inside, I can get it using the TAB key, It works using older versions 5.73 and 6.04.

Code: Select all

EnableExplicit
UseJPEGImageEncoder()
UsePNGImageEncoder()
UsePNGImageDecoder() 

InitSound()

Define InstID.i, Event.i, GadgetID.i, fname.s{1000}, cmd.s, prg.i, choix.b, directory.s
Define result.i, PageCount.i, size.i, OutBytes.i, *Buffer, dumy1.s, dumy2.s, flag.a
Define n1.u, n2.u, len.a, resol.s, minx.d, maxx.d, miny.d, maxy.d, xnull.w, Bkgcolor.l
Global tmp.s

Define *argv, dumy.s
Define.i orig_pdf, output, i
Dim pdfs.i(2)
Define range.i
;1pt = 1/72 inch = 0.0352777 cm    1cm=28.346457  

Enumeration
  #Form
  #Panel
  #Text=#Panel+100
  #String=#Text+100
  #Button=#String+100
  #Editor=#Button+100
  #Option=#Editor+100
  #Spin=#Option+100
  #Image=#Spin+100
  #Check=#Image+100
EndEnumeration

SetGadgetFont(#PB_Default, LoadFont(0, "Arial", 9))
CreateImage(0,100,100)

OpenWindow(0,100, 100, 800, 400, "TOOLS1",  #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
PanelGadget(#Panel, 10, 10, 600, 350)

AddGadgetItem(#Panel, -1, "Pdf2Image")
TextGadget(#Text+10,10,10,70,15,"File name:")
StringGadget(#String+12,80,10,200,20,"")
TextGadget(#Text+11,10,40,100,20,"Pages:    From")
StringGadget(#String+10,115,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+12,170,40,15,20,"To")
StringGadget(#String+11,200,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+14,300,40,150,20,"Resolution:")
StringGadget(#String+14,375,40,60,20,"400")
CheckBoxGadget(#Check+1, 300,70,50,20,"File")
TextGadget(#Text+13,10,70,37,20,"Page:")
StringGadget(#String+13,50,70,50,23,"1")
ButtonGadget(#Button+10,285,10,30,20,"...")
ButtonGadget(#Button+11,320,10,60,20,"Convert")
EditorGadget(#Editor+2, 10,100,500,100,#PB_Editor_ReadOnly)

CloseGadgetList()

Repeat 
  Event = WaitWindowEvent()
  GadgetID = EventGadget() ; Is it a gadget event?
Until Event = #PB_Event_CloseWindow
End

Any idea?

Other question: I prefer that the color of the panel gadget stay gray not white. If in compiler options, "enable DPI aware" is checked, panel is white, otherwise it's gray if unchecked. is there a trick to keep it gray with "enable DPI aware" checked?

using PB6.30b2 - W10.
PureBasic: Surprisingly simple, diabolically powerful
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: weird behavioural of StringGadget

Post by Axolotl »

Perhaps because your text gadget is too large.

Code: Select all

TextGadget(#Text+14,300,40,150,20,"Resolution:")  ; <== x = 300 and width = 150 leads to 450 
StringGadget(#String+14,375,40,60,20,"400")       ; <== x = 375 overlapping by textgadget 


BTW: what kind of advantage has this #Constant+100 coding style ?
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
morosh
Enthusiast
Enthusiast
Posts: 333
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: weird behavioural of StringGadget

Post by morosh »

Thank you Axoloti

Yes, this is the problem, (but it didn't come to my mind as it runs well with v6.04).
About the "#Constant+100" coding style, I'm not sure if it's a clever idea, but I use it to minimize the search for adding a new gadget, so if I need to add a new string gadget, I search for "#String+" and I note the biggest number and I increment it by 1. #Text=#Panel+100 means I reserved the place for 100 panels gadgets etc...

Still the question for the color of the Panel Gadget.

Best Regards
PureBasic: Surprisingly simple, diabolically powerful
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: weird behavioural of StringGadget

Post by RASHAD »

Hi

Code: Select all

EnableExplicit
UseJPEGImageEncoder()
UsePNGImageEncoder()
UsePNGImageDecoder() 

InitSound()

Define InstID.i, Event.i, GadgetID.i, fname.s{1000}, cmd.s, prg.i, choix.b, directory.s
Define result.i, PageCount.i, size.i, OutBytes.i, *Buffer, dumy1.s, dumy2.s, flag.a
Define n1.u, n2.u, len.a, resol.s, minx.d, maxx.d, miny.d, maxy.d, xnull.w, Bkgcolor.l
Global tmp.s

Define *argv, dumy.s
Define.i orig_pdf, output, i
Dim pdfs.i(2)
Define range.i
;1pt = 1/72 inch = 0.0352777 cm    1cm=28.346457  

Enumeration
  #Form
  #Panel
  #Text=#Panel+100
  #String=#Text+100
  #Button=#String+100
  #Editor=#Button+100
  #Option=#Editor+100
  #Spin=#Option+100
  #Image=#Spin+100
  #Check=#Image+100
EndEnumeration

Define brush,cont
brush = CreateSolidBrush_($F0F0F0)

SetGadgetFont(#PB_Default, LoadFont(0, "Arial", 9))
CreateImage(0,100,100)

OpenWindow(0,100, 100, 800, 400, "TOOLS1",  #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
PanelGadget(#Panel, 10, 10, 600, 350)
cont = ContainerGadget(#PB_Any, 0, 20, 600, 350)
CloseGadgetList()
DisableGadget(cont,1)
SetClassLongPtr_(GadgetID(cont), #GCL_HBRBACKGROUND, brush)

AddGadgetItem(#Panel, -1, "Pdf2Image")
TextGadget(#Text+10,10,10,70,15,"File name:")
SetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+12,80,10,200,20,"")
TextGadget(#Text+11,10,40,100,20,"Pages:    From")
SetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+10,115,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+12,170,40,15,20,"To")
SetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+11,200,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+14,300,40,150,20,"Resolution:")
SetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+14,375,40,60,20,"400")
CheckBoxGadget(#Check+1, 300,70,50,20,"File")
TextGadget(#Text+13,10,70,37,20,"Page:")
SetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+13,50,70,50,23,"1")
ButtonGadget(#Button+10,285,10,30,20,"...")
ButtonGadget(#Button+11,320,10,60,20,"Convert")
EditorGadget(#Editor+2, 10,100,500,100,#PB_Editor_ReadOnly)

CloseGadgetList()

Repeat 
  Event = WaitWindowEvent()
  GadgetID = EventGadget() ; Is it a gadget event?
Until Event = #PB_Event_CloseWindow
End
Edit : Modified
Last edited by RASHAD on Wed Oct 22, 2025 1:01 pm, edited 1 time in total.
Egypt my love
morosh
Enthusiast
Enthusiast
Posts: 333
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: weird behavioural of StringGadget

Post by morosh »

Thank you Rashad!!
but the panel still white :(
PureBasic: Surprisingly simple, diabolically powerful
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: weird behavioural of StringGadget

Post by RASHAD »

Previous post updated
Choose any Color you like
Now you can see how your design is good or not
OR

Code: Select all

EnableExplicit
UseJPEGImageEncoder()
UsePNGImageEncoder()
UsePNGImageDecoder() 

InitSound()

Define InstID.i, Event.i, GadgetID.i, fname.s{1000}, cmd.s, prg.i, choix.b, directory.s
Define result.i, PageCount.i, size.i, OutBytes.i, *Buffer, dumy1.s, dumy2.s, flag.a
Define n1.u, n2.u, len.a, resol.s, minx.d, maxx.d, miny.d, maxy.d, xnull.w, Bkgcolor.l
Global tmp.s

Define *argv, dumy.s
Define.i orig_pdf, output, i
Dim pdfs.i(2)
Define range.i
;1pt = 1/72 inch = 0.0352777 cm    1cm=28.346457  

Enumeration
  #Form
  #Panel
  #Text=#Panel+100
  #String=#Text+100
  #Button=#String+100
  #Editor=#Button+100
  #Option=#Editor+100
  #Spin=#Option+100
  #Image=#Spin+100
  #Check=#Image+100
EndEnumeration

Define brush,cont
brush = CreateSolidBrush_($0)

SetGadgetFont(#PB_Default, LoadFont(0, "Arial", 9))
CreateImage(0,100,100)

OpenWindow(0,100, 100, 800, 400, "TOOLS1",  #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
PanelGadget(#Panel, 10, 10, 600, 350)
cont = ContainerGadget(#PB_Any, 0, 20, 600, 350)
CloseGadgetList()
DisableGadget(cont,1)
SetClassLongPtr_(GadgetID(cont), #GCL_HBRBACKGROUND, brush)

AddGadgetItem(#Panel, -1, "Pdf2Image")
TextGadget(#Text+10,10,10,70,20,"File name:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+12,80,10,200,20,"")
TextGadget(#Text+11,10,40,100,20,"Pages:    From",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+10,115,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+12,170,40,24,20,"To :",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+11,200,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+14,300,40,70,20,"Resolution:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+14,375,40,60,20,"400")
CheckBoxGadget(#Check+1, 300,70,50,20,"File")
TextGadget(#Text+13,10,70,35,23,"Page:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+13,50,70,50,23,"1")
ButtonGadget(#Button+10,285,10,30,20,"...")
ButtonGadget(#Button+11,320,10,60,20,"Convert")
EditorGadget(#Editor+2, 10,100,500,100,#PB_Editor_ReadOnly)

CloseGadgetList()

Repeat 
  Event = WaitWindowEvent()
  GadgetID = EventGadget() ; Is it a gadget event?
Until Event = #PB_Event_CloseWindow
End

Egypt my love
morosh
Enthusiast
Enthusiast
Posts: 333
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: weird behavioural of StringGadget

Post by morosh »

Thank you Rashad! Awesome as always

In addition I've added a callback function to make text gadgets and others transparent.
now it looks like this (in case that interest someone):

Code: Select all

EnableExplicit
UseJPEGImageEncoder()
UsePNGImageEncoder()
UsePNGImageDecoder() 

InitSound()

Enumeration
  #Form
  #Panel
  #Text=#Panel+100
  #Option=#Text+100
  #Check=#Option+100
  #String=#Check+100
  #Button=#String+100
  #Editor=#Button+100
  #Spin=#Editor+100
  #Image=#Spin+100

EndEnumeration

Define InstID.i, Event.i, GadgetID.i, fname.s{1000}, cmd.s, prg.i, choix.b, directory.s
Define result.i, PageCount.i, size.i, OutBytes.i, *Buffer, dumy1.s, dumy2.s, flag.a
Define n1.u, n2.u, len.a, resol.s, minx.d, maxx.d, miny.d, maxy.d, xnull.w, Bkgcolor.l
Global tmp.s

Define *argv, dumy.s
Define.i orig_pdf, output, i
Dim pdfs.i(2)
Define range.i
;1pt = 1/72 inch = 0.0352777 cm    1cm=28.346457  

Procedure WindowCallback1(hWnd,uMsg,wParam,lParam)
Define kk.u
  Select uMsg
    Case #WM_CTLCOLORSTATIC
      For kk=#Panel To #String
        If IsGadget(kk)
          If lparam = GadgetID(kk) 
            ;If kk=#Spin1 : ProcedureReturn #PB_ProcessPureBasicEvents : EndIf
            SetBkMode_(wParam,#TRANSPARENT)         
            ProcedureReturn GetStockObject_(#NULL_BRUSH)
          EndIf
        EndIf
      Next
  EndSelect
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Define brush,cont
brush = CreateSolidBrush_($E6ECEC)

SetGadgetFont(#PB_Default, LoadFont(0, "Arial", 9))
CreateImage(0,100,100)

OpenWindow(0,100, 100, 800, 400, "TOOLS1",  #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
PanelGadget(#Panel, 10, 10, 600, 350)
cont = ContainerGadget(#PB_Any, 0, 20, 600, 350)
CloseGadgetList()
DisableGadget(cont,1)
SetClassLongPtr_(GadgetID(cont), #GCL_HBRBACKGROUND, brush)

AddGadgetItem(#Panel, -1, "Pdf2Image")
TextGadget(#Text+10,10,10,70,20,"File name:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+10),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+12,80,10,200,20,"")
TextGadget(#Text+11,10,40,100,20,"Pages:    From",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+11),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+10,115,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+12,170,40,24,20,"To :",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+12),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+11,200,40,40,20,"",#PB_String_ReadOnly)
TextGadget(#Text+14,300,40,70,20,"Resolution:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+14),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+14,375,40,60,20,"400")
CheckBoxGadget(#Check+1, 300,70,50,20,"File")
TextGadget(#Text+13,10,70,35,23,"Page:",#SS_CENTERIMAGE)
SetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE	,GetWindowLongPtr_(GadgetID(#Text+13),#GWL_STYLE)&~ #SS_NOTIFY)
StringGadget(#String+13,50,70,50,23,"1")
ButtonGadget(#Button+10,285,10,30,20,"...")
ButtonGadget(#Button+11,320,10,60,20,"Convert")
EditorGadget(#Editor+2, 10,100,500,100,#PB_Editor_ReadOnly)

CloseGadgetList()

SetWindowCallback(@WindowCallback1())

Repeat 
  Event = WaitWindowEvent()
  GadgetID = EventGadget() ; Is it a gadget event?
Until Event = #PB_Event_CloseWindow
End

PureBasic: Surprisingly simple, diabolically powerful
Post Reply