* * *

Author Topic: Windows without titlebar but with icons  (Read 2710 times)

Pascal

  • Sr. Member
  • ****
  • Posts: 488
Windows without titlebar but with icons
« on: May 10, 2017, 08:41:47 pm »
How can i accomplish this:
A window without titlebar but with minimize, maximize and close buttons.

laz trunk - fpc trunk 32bit - Windows 10 Pro x64

taazz

  • Hero Member
  • *****
  • Posts: 4340
Re: Windows without titlebar but with icons
« Reply #1 on: May 10, 2017, 09:01:09 pm »
you add the buttons manually
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

PatBayford

  • Jr. Member
  • **
  • Posts: 83
Re: Windows without titlebar but with icons
« Reply #2 on: May 24, 2017, 10:57:15 pm »
Not sure even placing them manually will work - I believe the Windows API will insist on adding a Title Bar if you put the system icons on the window. I assume that the later APIs behave like 95/98/XP. :-(
Lazarus 1.6.4 FPC 3.0.2 SVN 54278 Windows 10 64bit

rvk

  • Hero Member
  • *****
  • Posts: 2814
Re: Windows without titlebar but with icons
« Reply #3 on: May 24, 2017, 11:33:58 pm »
It isn't possible in a "normal" Windows application.

My guess is that the image from the opening post is from a Metro (oeps) UWP Windows App. With those apps it is possible to do more with the title-bar space.

RAW

  • Hero Member
  • *****
  • Posts: 542
Re: Windows without titlebar but with icons
« Reply #4 on: May 24, 2017, 11:39:35 pm »
What's the problem?
Take 3 PNG's (TImage) and place them in the upper right corner (bsNone-Window)... done  :P
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8.0RC4 FPC 3.0.4

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5738
Re: Windows without titlebar but with icons
« Reply #5 on: May 24, 2017, 11:44:13 pm »
All three buttons are visible in the far right corner.

So it seems what you are watching is  a very large window that is partially transparent with an extra hand drawn close button in the visible area.

rvk

  • Hero Member
  • *****
  • Posts: 2814
Re: Windows without titlebar but with icons
« Reply #6 on: May 25, 2017, 12:09:36 am »
All three buttons are visible in the far right corner.

So it seems what you are watching is  a very large window that is partially transparent with an extra hand drawn close button in the visible area.
No, those are not hand drawn buttons. Those are the standard buttons.
(also look for SpotBright, which is in that image, you'll see it's a UWP app from Microsoft)

With a metro-app (Universal Windows Platform application) you can request to extend your form to include the titlebar area. Search for ExtendViewIntoTitleBar.

Also see https://www.eternalcoding.com/?p=1952

Unfortunately this is not possible with a standard Windows application so you would need to disable the titlebar and do all that work yourself (including double click on the titlebar area for maximize etc).
« Last Edit: May 25, 2017, 12:11:29 am by rvk »

sky_khan

  • Guest
Re: Windows without titlebar but with icons
« Reply #7 on: May 25, 2017, 01:40:21 am »
This is how you can imitate it. See attachment.

RAW

  • Hero Member
  • *****
  • Posts: 542
Re: Windows without titlebar but with icons
« Reply #8 on: May 25, 2017, 06:43:08 am »
@SkyKhan: Nice idea...  :)

I added nice buttons and a nice and easy click-effect...
Code: Pascal  [Select]
  1. Procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  2.                              Shift : TShiftState; X, Y: Integer);
  3.  Begin
  4.   If Sender = ImgMin
  5.   Then
  6.    If Button = mbLeft
  7.    Then
  8.     Begin
  9.      ImgMinSh.Hide;
  10.      ImgMin.SetBounds(ImgMin.Left+2, ImgMin.Top+2, Width, Height);
  11.       Update;
  12.       Sleep(70);
  13.      ImgMin.SetBounds(ImgMin.Left-2, ImgMin.Top-2, Width, Height);
  14.      ImgMinSh.Show;
  15.       Update;
  16.       Sleep(70);
  17.  
  18.      Application.Minimize;
  19.     End;
  20.  
  21.   If Sender = ImgMax
  22.   Then
  23.    If Button = mbLeft
  24.    Then
  25.     Begin
  26.      ImgMaxSh.Hide;
  27.      ImgMax.SetBounds(ImgMax.Left+2, ImgMax.Top+2, Width, Height);
  28.       Update;
  29.       Sleep(70);
  30.      ImgMax.SetBounds(ImgMax.Left-2, ImgMax.Top-2, Width, Height);
  31.      ImgMaxSh.Show;
  32.       Update;
  33.       Sleep(70);
  34.  
  35.      ToggleState(0);
  36.     End;
  37.  
  38.   If Sender = ImgClose
  39.   Then
  40.    If Button = mbLeft
  41.    Then
  42.     Begin
  43.      ImgCloseSh.Hide;
  44.      ImgClose.SetBounds(ImgClose.Left+2, ImgClose.Top+2, Width, Height);
  45.       Update;
  46.       Sleep(70);
  47.      ImgClose.SetBounds(ImgClose.Left-2, ImgClose.Top-2, Width, Height);
  48.      ImgCloseSh.Show;
  49.       Update;
  50.       Sleep(70);
  51.  
  52.      Close;
  53.     End;
  54.  End;
  55.  
  56.  
  57. Procedure TForm1.ShpTitleMouseDown(Sender: TObject; Button: TMouseButton;
  58.                                    Shift : TShiftState; X, Y: Integer);
  59.  Begin
  60.   If WindowState <> WsMaximized
  61.   Then
  62.    Begin
  63.     FDragStartPoint:= Point(Mouse.CursorPos.x-Left, Mouse.CursorPos.y-Top);
  64.     Mouse.Capture  := Handle;
  65.     FDragging      := True;
  66.    End;
  67.  
  68.   If ssDouble In Shift
  69.   Then
  70.    Begin
  71.     FDragging:= False;
  72.     Application.QueueAsyncCall(@ToggleState, 0);
  73.    End;
  74.  End;
  75.  
  76.  
  77. Procedure TForm1.ShpTitleMouseMove(Sender: TObject; Shift: TShiftState;
  78.                                    X, Y  : Integer);
  79.  Begin
  80.   If FDragging
  81.   Then
  82.    Begin
  83.     Left:= Mouse.CursorPos.x-FDragStartPoint.x;
  84.     Top := Mouse.CursorPos.y-FDragStartPoint.y;
  85.    End;
  86.  End;        
  87.  
« Last Edit: June 02, 2017, 04:52:56 am by RAW »
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8.0RC4 FPC 3.0.4

Handoko

  • Hero Member
  • *****
  • Posts: 1643
  • My goal: build my own game engine using Lazarus
Re: Windows without titlebar but with icons
« Reply #9 on: May 25, 2017, 08:38:59 pm »
Downloaded and tested SkyKhan's code, it works but nothing happens if I click the minimize button. Tested Raw's version too, I can see the clicking effect of the minimize button, but still nothing happens.

Although not working perfectly, but still many nice tricks I can learn from the codes. Thanks for sharing.

sky_khan

  • Guest
Re: Windows without titlebar but with icons
« Reply #10 on: May 25, 2017, 08:52:16 pm »
Well, It is not my fault if Application.Minimize does not work :)

RAW

  • Hero Member
  • *****
  • Posts: 542
Re: Windows without titlebar but with icons
« Reply #11 on: May 25, 2017, 08:58:44 pm »
@Handoko
Is Application.Minimize generally working on your system?

BTW: I think it's better to use "FormMouseUp" or "OnClick" ... I overlooked that..
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8.0RC4 FPC 3.0.4

Handoko

  • Hero Member
  • *****
  • Posts: 1643
  • My goal: build my own game engine using Lazarus
Re: Windows without titlebar but with icons
« Reply #12 on: May 25, 2017, 09:10:09 pm »
I rarely, maybe never programmed to minimize a TForm. I just found that it's not working. What wrong with mine? Ubuntu Mate 16.10 64-bit or Lazarus 1.6.4 FPC 3.0.2 GTK 2.

Anybody has some issue as mine?

Handoko

  • Hero Member
  • *****
  • Posts: 1643
  • My goal: build my own game engine using Lazarus
Re: Windows without titlebar but with icons
« Reply #13 on: May 26, 2017, 09:27:43 am »
I made a simple test today. Started a new project, added a button and put this code:

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

It works as it should be. I retried the code from SkyKhan and RAW, I even re-downloaded the files, the minimize did nothing. So the issue is not in application.minimize but somewhere on the code. And on those code, if I add a new TButton and put application.minimize, it became no effect. Strange! I will inspect it further when I have time.

jma_sp

  • Full Member
  • ***
  • Posts: 128
  • El conocimiento si ocupa lugar.
Re: Windows without titlebar but with icons
« Reply #14 on: May 26, 2017, 12:14:53 pm »
I have downloaded and it works ok.

It´s unable to find back.png so i created a simple image file with this name.

Then run and minimize / maximize / close works without problem in Windows XP SP3
Debian 8.6 - (JWM/ROX/iDesk) - Devuan Jessie 1.0 ( without systemd ) - Puppy -  Quirky Xerus 8.2 - Windows XP - ReactOS 0.4.xx  - FreeDos - OctaOS - KolibriOS

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus