Page 1 of 1

[PB6.21] Windows bug? Background image + disabled images over it

Posted: Sat Aug 02, 2025 9:47 am
by marcoagpinto
Heya,

I believe I have found a bug (tested only on Windows 11).

Before you complain that my example is a crap, bear in mind that it is only to show the issue, I haven't been polishing it.

I want to open an about window both in Windows and Ubuntu with a background.

I have to disable the images over it depending on the OS so that the check for clicking anywhere would exit the window (there is no "OK" button, my app requires clicking anywhere in the window).

As you will notice, two of the PNGs won't appear, but the others will.

I believe it is a bug since if you remove the display of the background (first image) it will work okay.

Code: Select all

UsePNGImageDecoder()

LoadImage(1,GetCurrentDirectory()+"about_background.png")
LoadImage(2,GetCurrentDirectory()+"purebasic_2_logo_sharp.png")
LoadImage(3,GetCurrentDirectory()+"purebasic_logo.png")
LoadImage(4,GetCurrentDirectory()+"marcoagpinto_face.png")
LoadImage(5,GetCurrentDirectory()+"pedromarques_face.png")

w=1280
h=600
OpenWindow(1000,0,0,w,h,"About",#PB_Window_WindowCentered|#PB_Window_BorderLess)

; Disable images only on Windows OS
disable_image=#False
If #PB_Compiler_OS=#PB_OS_Windows : disable_image=#True : EndIf

ImageGadget(10,0,0,w,h,ImageID(1))
DisableGadget(10,disable_image)

x=0
y=20
ImageGadget(20,x,y,ImageWidth(2),ImageHeight(2),ImageID(2))
DisableGadget(20,disable_image)

x+ImageWidth(2)+10

ImageGadget(30,x,y,ImageWidth(3),ImageHeight(3),ImageID(3))
DisableGadget(30,disable_image)

x+ImageWidth(3)+10

ImageGadget(40,x,y,ImageWidth(4),ImageHeight(4),ImageID(4))
DisableGadget(40,disable_image)

x+ImageWidth(4)+10

ImageGadget(50,x,y,ImageWidth(5),ImageHeight(5),ImageID(5))
DisableGadget(50,disable_image)


Delay(5000) ; wait 5 seconds
Images used for the example:
https://proofingtoolgui.org/_other/bug_PB_20250802.zip

Re: [PB6.21] Windows bug? Background image + disabled images over it

Posted: Sat Aug 02, 2025 10:14 am
by infratec
You know that PB does not handle Z-Layer :?:
And you need an event loop for a window program!

Alternative:

Code: Select all


UsePNGImageDecoder()

LoadImage(1,GetCurrentDirectory()+"about_background.png")
LoadImage(2,GetCurrentDirectory()+"purebasic_2_logo_sharp.png")
LoadImage(3,GetCurrentDirectory()+"purebasic_logo.png")
LoadImage(4,GetCurrentDirectory()+"marcoagpinto_face.png")
LoadImage(5,GetCurrentDirectory()+"pedromarques_face.png")

;w=1280
w=1000
h=600
OpenWindow(1000,0,0,w,h,"About",#PB_Window_WindowCentered|#PB_Window_BorderLess)

; Disable images only on Windows OS
disable_image=#False
If #PB_Compiler_OS=#PB_OS_Windows : disable_image=#True : EndIf

CanvasGadget(100, 0, 0, w, h)
If StartDrawing(CanvasOutput(100))
  
  DrawAlphaImage(ImageID(1), 0, 0)
  
  x=0
  y=20
  DrawAlphaImage(ImageID(2), x, y)
  
  x+ImageWidth(2)+10
  DrawAlphaImage(ImageID(3), x, y)
  
  x+ImageWidth(3)+10
  DrawAlphaImage(ImageID(4), x, y)
  
  x+ImageWidth(4)+10
  DrawAlphaImage(ImageID(5), x, y)
  
  StopDrawing()
  
EndIf


Startms = ElapsedMilliseconds()
Repeat
  Event = WaitWindowEvent(10)
  If Event = #PB_Event_Gadget
    If EventGadget() = 100
      If EventType() = #PB_EventType_LeftClick
        exit = #True
      EndIf
    EndIf
  Else
    exit = Bool(ElapsedMilliseconds() - Startms >= 5000)
  EndIf
  
Until exit
P.S.: not every person can use your screen resolution :wink:

Re: [PB6.21] Windows bug? Background image + disabled images over it

Posted: Sat Aug 02, 2025 10:21 am
by infratec
And if you want gadgets for later click on your face, use the container solution:

Code: Select all

UsePNGImageDecoder()

LoadImage(1,GetCurrentDirectory()+"about_background.png")
LoadImage(2,GetCurrentDirectory()+"purebasic_2_logo_sharp.png")
LoadImage(3,GetCurrentDirectory()+"purebasic_logo.png")
LoadImage(4,GetCurrentDirectory()+"marcoagpinto_face.png")
LoadImage(5,GetCurrentDirectory()+"pedromarques_face.png")

w=1000
h=600
OpenWindow(1000,0,0,w,h,"About",#PB_Window_WindowCentered|#PB_Window_BorderLess)

; Disable images only on Windows OS
disable_image=#False
If #PB_Compiler_OS=#PB_OS_Windows : disable_image=#True : EndIf

CanvasGadget(10, 0, 0, w, h, #PB_Canvas_Container)
If StartDrawing(CanvasOutput(10))
  DrawImage(ImageID(1), 0, 0)
  StopDrawing()
EndIf

x=0
y=20
ImageGadget(20,x,y,ImageWidth(2),ImageHeight(2),ImageID(2))
DisableGadget(20,disable_image)

x+ImageWidth(2)+10

ImageGadget(30,x,y,ImageWidth(3),ImageHeight(3),ImageID(3))
DisableGadget(30,disable_image)

x+ImageWidth(3)+10

ImageGadget(40,x,y,ImageWidth(4),ImageHeight(4),ImageID(4))
DisableGadget(40,disable_image)

x+ImageWidth(4)+10

ImageGadget(50,x,y,ImageWidth(5),ImageHeight(5),ImageID(5))
DisableGadget(50,disable_image)

CloseGadgetList()

Startms = ElapsedMilliseconds()
Repeat
  Event = WaitWindowEvent(10)
  If Event = #PB_Event_Gadget
    If EventGadget() = 100
      If EventType() = #PB_EventType_LeftClick
        exit = #True
      EndIf
    EndIf
  Else
    exit = Bool(ElapsedMilliseconds() - Startms >= 5000)
  EndIf
  
Until exit

Re: [PB6.21] Windows bug? Background image + disabled images over it

Posted: Sat Aug 02, 2025 10:59 am
by marcoagpinto
Thank you!

It is working!

Image

Re: [PB6.21] Windows bug? Background image + disabled images over it

Posted: Sat Aug 02, 2025 11:35 am
by infratec
And ... don't use GetCurrentDirectory(). It does not always point to the directory of your code.

Use this instead:

Code: Select all

ProgramPath$ = GetPathPart(ProgramFilename())