Recent

Author Topic: Form1.BorderStyle := bsNone, then the form disappeared  (Read 6488 times)

tomitomy

  • Full Member
  • ***
  • Posts: 223
Form1.BorderStyle := bsNone, then the form disappeared
« on: October 21, 2017, 02:50:20 pm »
Is this a bug ?

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   BorderStyle := bsNone;
  4. end;

After I click Button1, the form disappeared.

OS: Linux Mint MATE-64Bit
Lazarus: 1.8.0 RC4 GTK2

Munair

  • Sr. Member
  • ****
  • Posts: 468
  • Try to KISS (keep it simple, smart)
    • Ditrianum
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #1 on: October 21, 2017, 03:53:23 pm »
Could be a GTK related problem, either within LCL or your GTK version. It could even be a theme error. I suggest  you first change your theme to a stable one if not already and see what happens.

When I do the same on KDE the program runs as expected. To test this further, I modified the code to see what happens. This runs as expected too (swapping style with each click):

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   if BorderStyle = bsSizeable then
  4.     BorderStyle := bsNone
  5.   else
  6.     BorderStyle := bsSizeable;
  7. end;
« Last Edit: October 21, 2017, 03:56:01 pm by Munair »
Lazarus 2.0.4; Manjaro, Debian, Windows

Munair

  • Sr. Member
  • ****
  • Posts: 468
  • Try to KISS (keep it simple, smart)
    • Ditrianum
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #2 on: October 21, 2017, 04:03:58 pm »
BTW, gtk theme related issues may also occur when your theme is primarily a gtk3 theme and does not support gtk2 (very well). I had issues with that in the past even to the point that it screwed my desktop session.

If you use the default Mint theme or Adwaita, you can check if this is the case.
Lazarus 2.0.4; Manjaro, Debian, Windows

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #3 on: October 21, 2017, 05:00:31 pm »
Could be a GTK related problem, either within LCL or your GTK version. It could even be a theme error. I suggest  you first change your theme to a stable one if not already and see what happens.

Thank you for your reply, my system is Linux Mint 18.2 MATE 64-Bit, I have not changed the theme, I just changed the size of the system font.

I copied the compiled program to the XUbuntu LiveCD virtual machine, the same problem.

I will install Linux Mint 18.2 MATE 64-Bit and Other Linux in VirtualBox, and then test it again.

Thaddy

  • Hero Member
  • *****
  • Posts: 8673
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #4 on: October 21, 2017, 06:22:39 pm »
If you change a border style at run-time please be so kind to repaint - on some platforms recreate - the window..... You will be a much happier person....
Border styles are usually for creation, not for run-time manipulation. That requires a repaint or recreation.
Most people that want to use threading should learn to patch their jeans first: use a needle.

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #5 on: October 22, 2017, 08:39:56 am »
If you change a border style at run-time please be so kind to repaint - on some platforms recreate - the window..... You will be a much happier person....
Border styles are usually for creation, not for run-time manipulation. That requires a repaint or recreation.

Thank you, I just want to achieve full-screen function. Set up BorderStyle:=bsNone in Windows can be achieved, but not in Linux. (wsFullScreen does not work properly in Linux)

if I am not so demanding, maybe I will be easier.

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #6 on: October 22, 2017, 10:00:31 am »
I recorded the screen in Linux Mint Cinnamon and showed more problems.

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #7 on: October 22, 2017, 10:16:38 am »
Here's another screen recording of wsFullScreen.

Munair

  • Sr. Member
  • ****
  • Posts: 468
  • Try to KISS (keep it simple, smart)
    • Ditrianum
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #8 on: October 22, 2017, 10:20:51 am »
What happens if you set the borderstyle to bsNone in the object inspector and then run it? Do you see a borderless form or nothing?
Lazarus 2.0.4; Manjaro, Debian, Windows

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #9 on: October 22, 2017, 11:00:10 am »
What happens if you set the borderstyle to bsNone in the object inspector and then run it? Do you see a borderless form or nothing?

Yes, a borderless form is shown, but there is a new problem, the FullScreen button is invalid.

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #10 on: October 22, 2017, 11:59:49 am »
This code works normally, but it needs another form to work with:

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   if BorderStyle <> bsNone then
  4.   begin
  5.     BorderStyle := bsNone;
  6.     Parent := Form2;
  7.     Parent := nil;
  8.   end
  9.   else
  10.     BorderStyle := bsSizeable;
  11. end;

Munair

  • Sr. Member
  • ****
  • Posts: 468
  • Try to KISS (keep it simple, smart)
    • Ditrianum
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #11 on: October 22, 2017, 01:51:15 pm »
You can set the border style in the object inspector. You don't need to do that in an event like ButtonClick or FormCreate. See attachment.

Like Thaddy said, if you really want to set it at runtime, do a repaint or recreate of the form.

Code: Pascal  [Select]
  1.     procedure TForm1.Button1Click(Sender: TObject);
  2.     begin
  3.       if BorderStyle = bsSizeable then
  4.         BorderStyle := bsNone
  5.       else
  6.         BorderStyle := bsSizeable;
  7.       Repaint;
  8.     end;
Lazarus 2.0.4; Manjaro, Debian, Windows

tomitomy

  • Full Member
  • ***
  • Posts: 223
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #12 on: October 22, 2017, 03:16:53 pm »
You can set the border style in the object inspector. You don't need to do that in an event like ButtonClick or FormCreate. See attachment.

Like Thaddy said, if you really want to set it at runtime, do a repaint or recreate of the form.

Ok, I see, Thank you and Thaddy, I will use "Parent := Form2; Parent := nil;" to refresh it ("Repaint" has no effect), Thank you very much! :)

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   Form: TForm;
  4. begin
  5.   if BorderStyle = bsNone then
  6.     BorderStyle := bsSizeable
  7.   else
  8.   begin
  9.     BorderStyle := bsNone;
  10.     // In Linux, need a form to assist
  11.     Form := TForm.Create(nil);
  12.     try
  13.       Parent := Form;
  14.       Parent := nil;
  15.     finally
  16.       Form.Free;
  17.     end;
  18.   end;
  19. end;
« Last Edit: October 23, 2017, 03:37:51 am by tomitomy »

torumyax

  • New Member
  • *
  • Posts: 33
Re: Form1.BorderStyle := bsNone, then the form disappeared
« Reply #13 on: February 20, 2018, 02:05:19 pm »
@tomitomy

I tried your trick, and it works beautifully. Thanks!