Canvas transparency broken

Btw it probably should be

Public Function SetWindowPos(hWnd As Integer, hWndInsertAfter As Integer, X as Int32, Y as Int32, cx As Int32, cy As Int32, uFlags As UInt32) as Integer #If TargetWindows 'https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 Declare Function SetWindowPos Lib "User32.dll" (hWnd As Integer, hWndInsertAfter As Integer, X as Int32, Y as Int32, cx As Int32, cy As Int32, uFlags As UInt32) As Integer Return SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags) #Endif End Function

Sorry I don’t mean to tease, I forget that I know where I do things but others don’t when I post a whole test project :slight_smile:

Inside Window1.Resizing I added the Refresh(false) line to the end after the width and height changes. I guess the framework is then told to perform a refresh with without blanking the background which stops the flicker (so it was a framework issue after all). I use this “hack” a lot since the framework windows update to do things like correcting the rendering of containers while scrolling etc.

[quote=389232:@Markus Winter]Btw it probably should be

Public Function SetWindowPos(hWnd As Integer, hWndInsertAfter As Integer, X as Int32, Y as Int32, cx As Int32, cy As Int32, uFlags As UInt32) as Integer #If TargetWindows 'https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 Declare Function SetWindowPos Lib "User32.dll" (hWnd As Integer, hWndInsertAfter As Integer, X as Int32, Y as Int32, cx As Int32, cy As Int32, uFlags As UInt32) As Integer Return SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags) #Endif End Function[/quote]

Oh crikey, if you’re running this on mac then lookout :wink: I’ve done zero crossplatform testing of this code as its just thrown together mainly from code that I’ve worked on in the past which might not even not cope with 64bit :slight_smile: Test test test, don’t just cut and paste :slight_smile: :wink:

Ah it worked on 64bit, bonus! That was totally planned shiftyeyes

There might even be code/constants in there that aren’t used as I just cut out huge portions to negate the need for wndproc so it can probably be tidied up even more.

It‘s an OPC* problem …

  • other people‘s code

Now that’s interesting! Thanks for sharing!

[quote=389238:@Markus Winter]It‘s an OPC* problem …

  • other people‘s code

Now that’s interesting! Thanks for sharing![/quote]

:smiley:

No problem, I just hope it works for Massimo :wink:

Oh by the way, the canvas is in there to trick the framework into not refreshing the background when you resize, if you take the contents of the paint event from the canvas and put it into the window2.paint and change window2.canvas1.refresh(false) inside window1.resizing and remove the canvas then you will see flicker, confusing no. Hacky hack hack :smiley:

PS. More smileys just for the :slight_smile:

Oops, that’s not quite correct. This is what it should have read:

I added the canvas to stop the flickering as adding the canvas over the window causes the framework to behave differently and not cause an extra paint in standard windows grey (probably related to <https://xojo.com/issue/51879>). I then had to add the Refresh as mentioned above to get around the “lagy/gloopy” rendering of the canvas control when its resized. I use this “hack” a lot since the framework windows update to do things like correcting the rendering of containers while scrolling etc.

You also don’t need the transparency on the canvas unless you want to draw controls on the canvas that are infront of the painted image from canvas1.paint. Window2 has a custom background colour so that all controls that are placed onto the canvas have white as their background which is they keyed out with the window transparency.

Clear as mud :wink: Let me know if there’s something that needs more explanation.

Thanks, but my head hurts plenty enough, thank you very much ! :wink:

Julian, you made an awesome job! :smiley:

Maybe I need some tweaks for my particular situation but this does work for me.
Thanks again for the invaluable help and the efforts you put into this.

Sorry for the necro-bump, but is there now a work-around to allow Canvases (and other controls) to be transparent/semi-transparent on Windows?
I looked at the demo app posted above, but that’s WAY over my head.
I’m wondering if there’s a way to have a Canvas “capture” what’s behind it and use it as a background picture to “emulate” transparency?

[quote=453052:@Andy Broughton]Sorry for the necro-bump, but is there now a work-around to allow Canvases (and other controls) to be transparent/semi-transparent on Windows?
I looked at the demo app posted above, but that’s WAY over my head.
I’m wondering if there’s a way to have a Canvas “capture” what’s behind it and use it as a background picture to “emulate” transparency?[/quote]
You might be able to hide the canvas, use DrawInto to draw the window into a picture and then show the canvas with the correct portion of the picture drawn in the paint event.