Form Designer Bug With GadgetText

Just starting out? Need help? Post your questions and find answers here.
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Form Designer Bug With GadgetText

Post by LESTROSO »

Dear Fred,

i 'm working on my program and i used Form designer to start it.

When i put an image like a wallpaper and i have added some gadget text...., the gadget text are not shown of course when i run and compile my program... I have tryed either png either jpg, but nothing works...

Best Regards,

Lestroso :oops:
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Form Designer Bug With GadgetText

Post by Keya »

are you just using an image gadget? normally you would use a String or Editor gadget for text
If you are using an image gadget make sure you're not drawing the image over your text
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: Form Designer Bug With GadgetText

Post by mhs »

Keya wrote:If you are using an image gadget make sure you're not drawing the image over your text
With other words, there is no z-order, if you put text gadgets over an image gadget, this will not work.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Form Designer Bug With GadgetText

Post by netmaestro »

PureBasic doesn't support overlapping gadgets. This is not a bug.
BERESHEIT
User avatar
TI-994A
Addict
Addict
Posts: 2741
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Form Designer Bug With GadgetText

Post by TI-994A »

LESTROSO wrote:...an image like a wallpaper and i have added some gadget text...., the gadget text are not shown...
You could use a disabled ImageGadget() as a wallpaper, or background image:

Code: Select all

; ================================================
; automatically loads a sample image from DropBox
; requires later versions of PureBasic for the
; ReceiveHTTPFile() function to work with DropBox
; ================================================

Enumeration
  #MainWindow
  #Background
  #bgImage
  #Button  
  #TitleFont
  #Candidate
  #CandidateFont
EndEnumeration

UseJPEGImageDecoder()
InitNetwork()

If FileSize(GetTemporaryDirectory() + "background.jpg") = -1
  ReceiveHTTPFile("https://www.dropbox.com/s/7ay877rq3eq8kwi/stairway.jpg?dl=1",
                  GetTemporaryDirectory() + "background.jpg")
EndIf
LoadImage(#bgImage, GetTemporaryDirectory() + "background.jpg")

LoadFont(#TitleFont, "Times New Roman", 24, #PB_Font_Italic)
LoadFont(#CandidateFont, "Times New Roman", 12, #PB_Font_Italic)

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 1000, 550, "Image Background", wFlags)
StartDrawing(ImageOutput(#bgImage))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawingFont(FontID(#TitleFont))
  DrawText(60, 30, "Stairway to Heaven...", RGB(0, 0, 255))
StopDrawing()
ImageGadget(#Background, 0, 0, 1000, 550, ImageID(#bgImage))
StringGadget(#Candidate, 100, 230, 190, 30, "enter your name here...")
ButtonGadget(#Button, 100, 265, 190, 30, "E N T E R !")
SetGadgetFont(#Candidate, FontID(#CandidateFont))
DisableGadget(#Background, #True)
DisableGadget(#Button, #True)
HideWindow(#MainWindow, #False)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      appQuit = 1
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button
          HideGadget(#Candidate, #True)
          HideGadget(#Button, #True)
          StartDrawing(ImageOutput(#bgImage))
            DrawingMode(#PB_2DDrawing_Transparent)
            DrawingFont(FontID(#TitleFont))
            DrawText(770, 250, "Goodbye...", RGB(255, 200, 255))
          StopDrawing()          
          SetGadgetState(#Background, ImageID(#bgImage))
        Case #Candidate
          Select EventType()
            Case #PB_EventType_Focus
              SetGadgetText(#Candidate, "")
            Case #PB_EventType_Change
              If Trim(GetGadgetText(#Candidate))
                DisableGadget(#Button, #False)
              Else
                DisableGadget(#Button, #True)
              EndIf
          EndSelect
      EndSelect
  EndSelect
Until appQuit = 1
EDITS wrote:18th February 2019: updated download links
Last edited by TI-994A on Mon Feb 18, 2019 7:49 am, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Form Designer Bug With GadgetText

Post by mestnyi »

PureBasic doesn't support overlapping gadgets.
I do not want to support. :)
the gadget text are not shown
Add this code and calls to this procedure after creating all the gadgets.

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Procedure GadgetsClipCallBack( GadgetID, lParam )
    If GadgetID
      If GetWindowLongPtr_( GadgetID, #GWL_STYLE ) & #WS_CLIPSIBLINGS = #False 
        Protected Gadget = GetProp_( GadgetID, "PB_ID" )
        If IsGadget( Gadget ) 
          Select GadgetType( Gadget )
            Case #PB_GadgetType_ComboBox
              Protected Height = GadgetHeight( Gadget )
          EndSelect
        EndIf
        
        SetWindowLongPtr_( GadgetID, #GWL_STYLE, GetWindowLongPtr_( GadgetID, #GWL_STYLE ) | #WS_CLIPSIBLINGS )
        
        If Height
          ResizeGadget( Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, Height )
        EndIf
        
        SetWindowPos_( GadgetID, #GW_HWNDFIRST, 0,0,0,0, #SWP_NOMOVE|#SWP_NOSIZE )
      EndIf
    EndIf
    
    ProcedureReturn GadgetID
  EndProcedure
CompilerEndIf

Procedure ClipGadgets( WindowID )
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    EnumChildWindows_( WindowID, @GadgetsClipCallBack(), 0 )
  CompilerEndIf
EndProcedure
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Re: Form Designer Bug With GadgetText

Post by LESTROSO »

I'm so sorry....

i have understood that purebasic have this limitation....

Thanks for sharing the codes to work around this problem....

Thanks again,Lestroso :D
Post Reply