1. David Hepburn
  2. PowerBuilder
  3. Tuesday, 25 July 2023 00:29 AM UTC

I have made a Powerbuilder classic window with a transparent background which works almost perfectly for the task I'm trying to achieve. I'm trying to have a transparent window topmost over all other applications (achieved that part so far), which has a static text control on it. I need the window and the text background to be 100% transparent but to have the actual text 100% visible. The plan is to have text overlay a 3rd party video player but have everything else in my PB app transparent so only the text shows. NOTE: I do not want to embed the video player as part of my window, this will always be a 3rd party app (that has no text overlays possible within that app).
Ignoring the video playing part for now, how can I make a window with both it's background and static text control background totally invisible but allow the text itself to be 100% visible?
PB2019.

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 31 July 2023 06:46 AM UTC
  2. PowerBuilder
  3. # Permalink

Here a small example window that works for me with PB 2019 R3.

I've only copied the external functions declarations. If you want to use the example in a 64bit application you shound change the pointer variables! 

There is still a remaining small shadow of window background color around the text. I don't know how to remove this. Because of this I choosed two almost identical colors  (blue and navy) for window background and text color in my example.

forward
global type w_test from window
end type
type st_1 from statictext within w_test
end type
end forward

global type w_test from window
integer width = 873
integer height = 372
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 16711680
string icon = "AppIcon!"
boolean center = true
st_1 st_1
end type
global w_test w_test

type prototypes
Function long GetWindowLong (ulong hWnd, int nIndex) Library "user32.dll" Alias for "GetWindowLongW"
Function long SetWindowLong (ulong hWnd, int nIndex, long dwNewLong) Library "user32.dll" Alias for "SetWindowLongW"
Function Long SetLayeredWindowAttributes(ulong hWnd, Long crKey , byte bAlpha , Long dwFlags) Library "user32.dll"
Function Boolean SetMenu(ulong hWnd, ulong hMenu) Library "user32.dll"

end prototypes

on w_test.create
this.st_1=create st_1
this.Control[]={this.st_1}
end on

on w_test.destroy
destroy(this.st_1)
end on

event open;Constant long LWA_COLORKEY = 1
Constant long GWL_EXSTYLE = -20
Constant long WS_EX_LAYERED = Long(2^19)
Constant long GWL_STYLE = -16
Constant long WS_VISIBLE = 268435456
Constant long WS_MAXIMIZE = 16777216
Constant long WS_CLIPCHILDREN = 33554432
Constant long WS_CLIPSIBLINGS = 67108864
long ll_null_handle


SetWindowLong ( Handle(this), GWL_EXSTYLE, &
GetWindowLong( Handle (this), GWL_EXSTYLE ) + WS_EX_LAYERED)
SetLayeredWindowAttributes(Handle(this), This.BackColor , BYTE(0), LWA_COLORKEY)

SetWindowLong(Handle(THIS), GWL_STYLE, WS_VISIBLE /*+ WS_MAXIMIZE */ + WS_CLIPCHILDREN + WS_CLIPSIBLINGS)

THIS.ClientEdge = FALSE

SetNull(ll_null_handle)
SetMenu(Handle(THIS), ll_null_handle)

end event

type st_1 from statictext within w_test
integer x = 197
integer y = 56
integer width = 439
integer height = 160
integer textsize = -20
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 8388608
long backcolor = 553648127
string text = "TEST"
alignment alignment = center!
boolean focusrectangle = false
end type

Comment
  1. David Hepburn
  2. Tuesday, 1 August 2023 01:13 AM UTC
WOW!!!! Yes you cracked it! Thank you sooo much.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 31 July 2023 08:58 AM UTC
  2. PowerBuilder
  3. # 1

Maybe it would help if you could explain a bit more.

- why use powerbuilder for overlaying a third party video player?

- does your 3rd party video player allow for LUA programming?

Maybe someone could have a better solution for what you are trying to achieve here, it seems pretty twisted to me :S

regards.

Comment
  1. David Hepburn
  2. Monday, 31 July 2023 22:52 PM UTC
Reason is I'm running a video over 6 displays, something the 3rd party video player can do, but we can't create a window that is 6 displays wide (9600x1080), right?

6 x 1920x1080 = 9600x1080

If I'm missing something here and somehow we can create a window that wide then let me know...
  1. Helpful
  1. David Hepburn
  2. Monday, 31 July 2023 23:00 PM UTC
Just to clarify further, the videos we run is 9600x1080 and it spans across 6 displays using a 6-head PC. This video shows products we sell that require pricing to be displayed dynamically due to the frequency in which the pricing changes, so I need to overlay the video with text which is the pricing. The 3rd party multimedia player is capable to activated from my PB app but it can't run within it due to the window size limitations of PB.

The idea is I kick off the multimedia player then open 6 x 1920x1080 transparent windows over the top of the video player which has the pricing text.

The 3rd party player itself does not support text overlay.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Tuesday, 1 August 2023 02:29 AM UTC
Impressive! Thanks for explaining.

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 26 July 2023 13:32 PM UTC
  2. PowerBuilder
  3. # 2

I think it should work with Windows API.

You can start with this article. Set window background color to a standard color (e.g. "White" not "buttonface").

A short test seems to work.

https://answers.sap.com/questions/11170828/transparent-window-in-pb.html

 

Comment
  1. David Hepburn
  2. Monday, 31 July 2023 03:57 AM UTC
getting the window transparent is the easy part, I need text, whether it be a ST/SLE/DW to not be transparent while it's background is transparent.

I tried the above and no joy unfortunately.
  1. Helpful
  1. René Ullrich
  2. Monday, 31 July 2023 05:18 AM UTC
With my small test window I had a transparent window and a non transparent static text. I've already deleted it. I think I had set the statics text background to transparent and text color could be windowtext or black.
  1. Helpful
  1. David Hepburn
  2. Monday, 31 July 2023 06:14 AM UTC
I have tried that previously. If you got it working I'd love a copy of your code...
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 26 July 2023 11:32 AM UTC
  2. PowerBuilder
  3. # 3

Hi, David -

You might consider using a DataWindow to display the text instead of a Static Text or Single Line Edit control, as the latters are rendered by the Windows O/S and the former is rendered by PB. This is what I would try if I were trying to solve this issue.

It might also help for you to show us your code in order for us to perform a little experimentation, as Miguel has suggested.

Best regards, John

Comment
  1. Miguel Leeuwe
  2. Wednesday, 26 July 2023 13:03 PM UTC
That's a great suggestion. However I'm afraid that 'transparency' in powerbuilder is going to be a 'static' thing. It will adopt the background color, but I highly doubt it will be something dynamic in such a way that, when you move the window around it will show the changing things in the background.

Worth a try though!

regards
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 25 July 2023 01:23 AM UTC
  2. PowerBuilder
  3. # 4

Hi,

Try using a single line edit control instead of a static text.

Set the transparency for the background in its font. Not in the control itself.

Hope it works!

Comment
  1. Miguel Leeuwe
  2. Wednesday, 26 July 2023 07:16 AM UTC
I'm guessing you use some kind of windows API functions to set the Window itself to transparent. Maybe the problem is that your SLE already adapted the background color before those API functions have executed. What if you'd use OpenUserobject() to create a standard SLE custom userobject That way you could call it after the API functions have been executed.

I'm just guessing, if I have some time I'll try it myself, but I don't know how to make the window transparent?
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 26 July 2023 07:17 AM UTC
*Correction: "use OpenUserobject() to create a standard SLE custom userobject " should be "use OpenUserobject() to open a created standard SLE custom userobject "
  1. Helpful
  1. David Hepburn
  2. Monday, 31 July 2023 03:55 AM UTC
Unfortunately this has not worked either. Even using the OpenUserObject function still makes the text of the SLE transparent as well.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.