Forum > Other
Make form or window transparent and keep all the control visible
KodeZwerg:
--- Quote from: Awesome Programmer on November 03, 2023, 03:30:07 pm ---How would you achieve Method 1?
--- End quote ---
Like this: (uses Windows....)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure CutForm(const AForm: TForm);var i: Integer; Rgn, CompRgn: HRGN;begin AForm.BorderStyle := bsNone; Rgn := CreateRectRgn(AForm.Left, AForm.Top, AForm.Width, AForm.Height); for i := 0 to Pred(AForm.ControlCount) do begin CompRgn := CreateRectRgn(AForm.Controls[i].Left, AForm.Controls[i].Top, AForm.Controls[i].Left + AForm.Controls[i].Width, AForm.Controls[i].Top + AForm.Controls[i].Height); CombineRgn(Rgn, Rgn, CompRgn, RGN_OR); DeleteObject(CompRgn); end; SetWindowRgn(AForm.Handle, Rgn, True); DeleteObject(Rgn);end;Now your form is gone and just the controls are left, you can finetune it to just react on visible controls etc.... just written in a hurry for you
ASerge:
--- Quote from: KodeZwerg on November 05, 2023, 06:09:38 pm ---Like this: (uses Windows....)
--- End quote ---
Did you test your code when the form is in the upper left corner?
Corrected version:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows; procedure CutForm(AForm: TForm);var Rgn, CompRgn: HRGN; C: TControl;begin AForm.BorderStyle := bsNone; Rgn := CreateRectRgn(0, 0, 0, 0); for C in AForm.GetEnumeratorControls do begin CompRgn := CreateRectRgnIndirect(C.BoundsRect); CombineRgn(Rgn, Rgn, CompRgn, RGN_OR); DeleteObject(CompRgn); end; SetWindowRgn(AForm.Handle, Rgn, True); DeleteObject(Rgn);end;
KodeZwerg:
--- Quote from: KodeZwerg on November 05, 2023, 06:09:38 pm ---just written in a hurry for you
--- End quote ---
--- Quote from: ASerge on November 06, 2023, 05:22:38 am ---Did you test your code when the form is in the upper left corner?
--- End quote ---
No, I just run it, pushed a button to check and posted it here, thank you for testing all possible situations and correcting it.
paweld:
SetWindowRgn is multiplatform, just instead of the Windows unit add LCLType, LCLIntf
@KodeZwerg's example runs on linux without a problem
r.lukasiak:
Hi everyone,
I'm sorry for reheating an old post but I've been looking for something that's been discussed here.
I wanna make a form of a modal window transparent but still keep all controls on it visible.
I tried both @ASerge's and @KodeZwerg's solutions, taking into account @paweld's hint on uses LCLType, LCLIntf (as I use Linux) but all I got is the title bar to disappear, the body is still visible.
I see that @paweld uses XFCE/GTK but I'm KDE/Qt5, may it make the difference or I did something wrong?
At what point shall I call procedure CutForm(AForm: TForm)?? I tried it before MyModalShowModal from the main form and within its OnCreate, both with no expected result.
any hint?
Navigation
[0] Message Index
[#] Next page
[*] Previous page