Transparency regression in 5.73 B4

Just starting out? Need help? Post your questions and find answers here.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Transparency regression in 5.73 B4

Post by Saki »

Well, I don't know for sure, but I've never stacked gadgets, Windows is very bitchy about that.

The normal way is to write the text into the image, or put a text layer behind the image.
地球上の平和
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: Transparency regression in 5.73 B4

Post by BarryG »

This is about the latest beta not working the same as the latest final. It's not about what I'm doing, but about the fact that a command (SetWindowColor) isn't working the same anymore.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Transparency regression in 5.73 B4

Post by Saki »

Well, maybe someone else can say something about it.
It's all about the rules of the game.
The parking offender can't say that he hasn't received a ticket ever, why now ?

I would say that the ImageGadget() has no place on the ButtonGadget !

ImageGadget - Demo output, four layers, colored window - Tested 5.73b4 Windows
Image
地球上の平和
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Transparency regression in 5.73 B4

Post by Blue »

BarryG wrote:I finally got a working snippet to show the problem. Woohoo!
Try this code with 5.72 Final, and with 5.73 Beta 4, using Little John's icon in his first reply:
It seems to me that you're jumping to the wrong conclusion here !

The problem appears to be linked to the #PB_Button_MultiLine flag. With that flag removed, everything works fine.

(tested with Beta 4 on Windows 10 x64)
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Transparency regression in 5.73 B4

Post by breeze4me »

There seems to be an internal change in drawing. It may be the result of a bug fix rather than a regression.

Anyway, the code below is a workaround.
Tested in PB 5.72/5.73 b4 x64/86.

Code: Select all

;w=OpenWindow(0, 100, 100, 145, 105, "ICO test", #PB_Window_Invisible|#PB_Window_BorderLess)
w=OpenWindow(0, 100, 100, 145, 105, "ICO test", #PB_Window_Invisible|#PB_Window_BorderLess|#PB_Window_Tool)

im=LoadImage(#PB_Any, "d:\test.ico")

ig=ImageGadget(#PB_Any, 16, 16, 16, 16, 0)
SetGadgetState(ig, ImageID(im))

bg=ButtonGadget(#PB_Any, 10, 10, 78, 78, "", #PB_Button_MultiLine|#WS_CLIPSIBLINGS)

hWnd=WindowID(0)
;SetWindowLongPtr_(hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(hWnd,#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW)
SetWindowLongPtr_(hWnd,#GWL_STYLE,GetWindowLongPtr_(hWnd,#GWL_STYLE) & ~#WS_CAPTION)

SetWindowColor(0, GetSysColor_(#COLOR_3DLIGHT)) ; *** This breaks 5.73 Beta 4 ***

ShowWindow_(hWnd,#SW_SHOW)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: Transparency regression in 5.73 B4

Post by BarryG »

Blue wrote:It seems to me that you're jumping to the wrong conclusion here !
The problem appears to be linked to the #PB_Button_MultiLine flag. With that flag removed, everything works fine.
It doesn't work here on 32-bit PureBasic 5.73 Beta 4 with #PB_Button_MultiLine removed. Still results in a black background. I need #PB_Button_MultiLine anyway due to long text on the button.
breeze4me wrote:Anyway, the code below is a workaround.
Doesn't work here - the background is still messed up:

Image
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Transparency regression in 5.73 B4

Post by breeze4me »

BarryG wrote:Doesn't work here - the background is still messed up:
Try this one.

Code: Select all

#MyApp_OldWndProc = "MyAppOldWndProc"

Procedure ImageGadgetWndProc(hWnd, Message, wParam, lParam)
  Protected hBrush, rt.RECT, OldWndProc = GetProp_(hWnd, #MyApp_OldWndProc)
  
  If Message = #WM_ERASEBKGND
    hBrush = CreateSolidBrush_(GetSysColor_(#COLOR_3DLIGHT))
    ;hBrush = CreateSolidBrush_(GetSysColor_(#COLOR_3DHIGHLIGHT))
    ;hBrush = CreateSolidBrush_(GetWindowColor(0))
    
    If hBrush
      GetClientRect_(hWnd, rt)
      FillRect_(wParam, rt, hBrush)
      
      DeleteObject_(hBrush)
      ProcedureReturn 1
    EndIf
    
  EndIf
  
  If Message = #WM_NCDESTROY
    RemoveProp_(hWnd, #MyApp_OldWndProc)
  EndIf
  
  ProcedureReturn CallWindowProc_(OldWndProc, hWnd, Message, wParam, lParam)
EndProcedure

Procedure MyImageGadget(Gadget, x, y, Width, Height, ImageID, Flags = 0)
  Protected Result = ImageGadget(Gadget, x, y, Width, Height, ImageID, Flags)
  Protected hWnd
  
  If Result
    If Gadget = #PB_Any
      hWnd = GadgetID(Result)
    Else
      hWnd = Result
    EndIf
    
    SetProp_(hWnd, #MyApp_OldWndProc, SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, @ImageGadgetWndProc()))
  EndIf
  
  ProcedureReturn Result
EndProcedure




w=OpenWindow(0, 100, 100, 145, 105, "ICO test", #PB_Window_Invisible|#PB_Window_BorderLess)

im=LoadImage(#PB_Any, "d:\test.ico")

;ig=ImageGadget(#PB_Any, 16, 16, 16, 16, 0)
ig= MyImageGadget(#PB_Any, 16, 16, 16, 16, 0)
SetGadgetState(ig, ImageID(im))

bg=ButtonGadget(#PB_Any, 10, 10, 78, 78, "", #PB_Button_MultiLine|#WS_CLIPSIBLINGS)

hWnd=WindowID(0)
SetWindowLongPtr_(hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(hWnd,#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW)

SetWindowColor(0, GetSysColor_(#COLOR_3DLIGHT)) ; *** This breaks 5.73 Beta 4 ***

ShowWindow_(hWnd,#SW_SHOW)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Transparency regression in 5.73 B4

Post by Blue »

BarryG wrote:[...]
It doesn't work here on 32-bit PureBasic 5.73 Beta 4 with #PB_Button_MultiLine removed. Still results in a black background. [...]
Yes, sorry, BarryG. I just keep forgetting that there is a 32-bit version of PB.

At any rate, your reasoning obviously holds water. Something has changed between versions, and a gone bug has reappeared, albeit in a different guise.

Sorry I can't help any further. I admire your determination, though.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Transparency regression in 5.73 B4

Post by Fred »

The problem is you are overlapping gadgets and PureBasic doesn't support this, so things like this can happen. It 'worked', but it was more a side effect than something really wanted. For example, your code also fail with SmartWindowRefresh() activated.
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: Transparency regression in 5.73 B4

Post by BarryG »

Okay, I will have to abort the overlapped method and come up with something else. Thanks for looking, Fred.
Post Reply