Recent

Author Topic: Label on transparent form  (Read 495 times)

PetWey

  • New Member
  • *
  • Posts: 13
Label on transparent form
« on: October 11, 2020, 10:25:25 am »
Hello Forum,

I want to add subtitles to a video and write myself a program with the appropriate properties.
My first problem is the display of visible text on a transparent form.
It is not a problem to place a label on a form and to make the form transparent with AlphaBlend, but then the LabelText has also disappeared.
I have already derived a TLabel and adjusted the paint procedure, but the form seems to set all colors to transparent in a final step.

Is there a solution for this? Maybe a corresponding component or a code snippet?

Under Delphi there was a solution with an AlphaBlendColor, which is no longer available under Lazarus.

Thanks in advance.

BR
petwey

jamie

  • Hero Member
  • *****
  • Posts: 3797
Re: Label on transparent form
« Reply #1 on: October 11, 2020, 06:53:56 pm »
Ok, What target ? and if Windows you can use the SetleyeredWindowsAtrributes of a TPanel for example

With that you can place this panel over your video and write text on it.. the text will block the video but the rest is transparent and clickable.

 Look here for a starter..
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes
The only true wisdom is knowing you know nothing

PetWey

  • New Member
  • *
  • Posts: 13
Re: Label on transparent form
« Reply #2 on: October 11, 2020, 11:53:18 pm »
Hello jamie,

Thanks for the answer. Yes, I would program that under Windows.

Do I understand this in the right manner. I am using a form with AlphaBlend on which there is a TLabel in my case, which I then give different properties to the form with SetleyeredWindowsAtrributes?

I checked out your link. But I haven't worked with API calls before.
Is there a mini manual or a short example?

Thanks in advance.

MfG petwey

----------
I read the answer again in more detail!

The video should not run in my program and the label should not be placed on it.

The idea is the video e.g. to play with VLC and put a transparent form in front of it in which the subtitles appear.

The whole thing would then be resumed with a screen cam.

The result would be a subtitled video.

BUT your approach is interesting too. Here I would have to build a component into my program with which I can play a video. That would also be a solution.

Thanks again.

MfG, petwey
« Last Edit: October 12, 2020, 12:04:41 am by PetWey »

jamie

  • Hero Member
  • *****
  • Posts: 3797
Re: Label on transparent form
« Reply #3 on: October 12, 2020, 02:33:41 am »
You can have a single form app and apply that setting to the form, then use it as a overlay to the player screen.
just a matter of starting your app and bringing it to the front on the desktop.


Something like
 SetWindowLong(form1.handle, GWL_EXSTLE,GetWindowLong(Form1.handle,GWL_EXSTYLE)or WS_Ex_Layered);

 from there you then use the SetLayeredWindowAttribrutes(…)

 I thought I did this already once for someone here..

 maybe I can bang out a demo
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 3797
Re: Label on transparent form
« Reply #4 on: October 12, 2020, 03:10:44 am »
attached is a test demo, kind of rough but I think you will get the idea.
The only true wisdom is knowing you know nothing

PetWey

  • New Member
  • *
  • Posts: 13
[SOLVED] Label on transparent form
« Reply #5 on: October 12, 2020, 08:06:16 am »
Hello jamie,

That is exactly what I have been looking for. With this approach I can build my program.

That solves the problem for me.

Many Thanks.

 

TinyPortal © 2005-2018