Windows without titlebar but with icons lazarus / 31-LCL ---------------------------------------------------------------------- Pascal · 2017-05-10 18:41 How can i accomplish this: A window without titlebar but with minimize, maximize and close buttons. ---------------------------------------------------------------------- taazz · 2017-05-10 19:01 you add the buttons manually ---------------------------------------------------------------------- PatBayford · 2017-05-24 20:57 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. :-( ---------------------------------------------------------------------- rvk · 2017-05-24 21:33 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 · 2017-05-24 21:39 What's the problem? Take 3 PNG's (TImage) and place them in the upper right corner (bsNone-Window)... done ---------------------------------------------------------------------- marcov · 2017-05-24 21:44 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 · 2017-05-24 22:09 Quote from: marcov on May 24, 2017, 11:44:13 pmAll 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). ---------------------------------------------------------------------- sky_khan · 2017-05-24 23:40 This is how you can imitate it. See attachment. ---------------------------------------------------------------------- RAW · 2017-05-25 04:43 @SkyKhan: Nice idea...  I added nice buttons and a nice and easy click-effect... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;                           Shift : TShiftState; X, Y: Integer); Begin  If Sender = ImgMin  Then   If Button = mbLeft   Then    Begin     ImgMinSh.Hide;   ImgMin.SetBounds(ImgMin.Left+2, ImgMin.Top+2, Width, Height);      Update;      Sleep(70);     ImgMin.SetBounds(ImgMin.Left-2, ImgMin.Top-2, Width, Height);     ImgMinSh.Show;      Update;      Sleep(70);      Application.Minimize;    End;   If Sender = ImgMax  Then   If Button = mbLeft   Then    Begin     ImgMaxSh.Hide;     ImgMax.SetBounds(ImgMax.Left+2, ImgMax.Top+2, Width, Height);      Update;      Sleep(70);     ImgMax.SetBounds(ImgMax.Left-2, ImgMax.Top-2, Width, Height);     ImgMaxSh.Show;      Update;      Sleep(70);      ToggleState(0);    End;   If Sender = ImgClose  Then   If Button = mbLeft   Then    Begin     ImgCloseSh.Hide;     ImgClose.SetBounds(ImgClose.Left+2, ImgClose.Top+2, Width, Height);    Update;      Sleep(70);     ImgClose.SetBounds(ImgClose.Left-2, ImgClose.Top-2, Width, Height);     ImgCloseSh.Show;      Update;    Sleep(70);      Close;    End; End;  Procedure TForm1.ShpTitleMouseDown(Sender: TObject; Button: TMouseButton;                                 Shift : TShiftState; X, Y: Integer); Begin  If WindowState <> WsMaximized  Then   Begin    FDragStartPoint:= Point(Mouse.CursorPos.x-Left, Mouse.CursorPos.y-Top);    Mouse.Capture  := Handle;    FDragging      := True;   End;   If ssDouble In Shift  Then   Begin    FDragging:= False;    Application.QueueAsyncCall(@ToggleState, 0);   End; End;  Procedure TForm1.ShpTitleMouseMove(Sender: TObject; Shift: TShiftState;                                 X, Y  : Integer); Begin  If FDragging  Then   Begin    Left:= Mouse.CursorPos.x-FDragStartPoint.x;    Top := Mouse.CursorPos.y-FDragStartPoint.y;   End; End; ---------------------------------------------------------------------- Handoko · 2017-05-25 18:38 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 · 2017-05-25 18:52 Well, It is not my fault if Application.Minimize does not work ---------------------------------------------------------------------- RAW · 2017-05-25 18:58 @Handoko Is Application.Minimize generally working on your system? BTW: I think it's better to use "FormMouseUp" or "OnClick" ... I overlooked that.. ---------------------------------------------------------------------- Handoko · 2017-05-25 19:10 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 · 2017-05-26 07:27 I made a simple test today. Started a new project, added a button and put this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  Application.Minimize;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 · 2017-05-26 10:14 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 ---------------------------------------------------------------------- Handoko · 2017-05-26 10:28 Quote from: jma_sp on May 26, 2017, 12:14:53 pmIt´s unable to find back.png so i created a simple image file with this name. Or change/point the back.png to any of your image file. The author forgot to include it in the zip files, or maybe the size is too big so it is removed. ---------------------------------------------------------------------- RAW · 2017-05-26 17:20 @Handoko: ...must be the weather !!! Did you check if the program really executes the code "Application.Minimize" ? ---------------------------------------------------------------------- sky_khan · 2017-05-26 17:27 It works on win32 widgetset but fails on Gtk2. I checked on a linux VM with gtk2 widgetset. Minimize or maximize does not work when form has no border and border icons. So my code is not so cross-platform but unfortunately my experience is mostly windows specific . I dont really know if it can be done with gtk2. ---------------------------------------------------------------------- Handoko · 2017-05-26 17:36 Maximize works on my Linux GTK 2. For the minimize feature I use TForm.Hide, which works like minimize. ---------------------------------------------------------------------- jc99 · 2017-05-26 18:44 If you also want to move the Window it's slightly more complicated: BTW: You could use the patch of LMDI to see something like that, you only need to exchange the bitmaps... https://bugs.freepascal.org/view.php?id=31924 ---------------------------------------------------------------------- RAW · 2017-05-27 16:02 Resizing can be done like this: For example (of course there are several ways...): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState;                             X, Y  : Integer);  Var   rCheckMouse  : TRect;   booChangedCur: Boolean; Begin  booChangedCur:= False;   // BORDER TOP  rCheckMouse:= Rect(iEdgeSize, 0, Width-iEdgeSize, iBorderWidth);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeNS;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F003, 0);       End;    End;   // BORDER RIGHT  rCheckMouse:= Rect(Width-iBorderWidth, iEdgeSize, Width, Height-iEdgeSize);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeWE;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F002, 0);       End;    End;   // BORDER BOTTOM  rCheckMouse:= Rect(iEdgeSize, Height-iBorderWidth, Width-iEdgeSize, Height);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeNS;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F006, 0);     End;    End;   // BORDER LEFT  rCheckMouse:= Rect(0, iEdgeSize, iBorderWidth, Height-iEdgeSize);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor     := crSizeWE;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F001, 0);     End;    End;   // EDGE UPPER LEFT  rCheckMouse:= Rect(0, 0, iEdgeSize, iEdgeSize);   If PtInRect(rCheckMouse, Point(X,Y))   Then  Begin     booChangedCur:= True;     Cursor       := crSizeNWSE;      If ssLeft In Shift      Then       Begin        ReleaseCapture;      SendMessage(Handle, LM_SysCommand, $F004, 0);       End;    End;   // EDGE UPPER RIGHT  rCheckMouse:= Rect(Width - iEdgeSize, 0, Width, iEdgeSize);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeNESW;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F005, 0);       End;    End;   // EDGE BOTTOM RIGHT  rCheckMouse:= Rect(Width-iEdgeSize, Height- iEdgeSize, Width, Height);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeNWSE;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F008, 0);     End;    End;   // EDGE BOTTOM LEFT  rCheckMouse:= Rect(0, Height- iEdgeSize, iEdgeSize, Height);   If PtInRect(rCheckMouse, Point(X,Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSizeNESW;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F007, 0);     End;    End;   // NORMAL CURSOR  If Not booChangedCur  Then Cursor:= crDefault; End;  Procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;                             Shift : TShiftState; X, Y: Integer); Begin  If Button = mbRight  Then Close; End;  Procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;                               Shift : TShiftState; X, Y: Integer);  Var   rMoveWnd     : TRect;   booChangedCur: Boolean; Begin  booChangedCur:= False;  rMoveWnd:= Rect(iEdgeSize, iBorderWidth, Width-iEdgeSize, 30);    If PtInRect(rMoveWnd, Point(X, Y))   Then    Begin     booChangedCur:= True;     Cursor       := crSize;      If ssLeft In Shift      Then       Begin        ReleaseCapture;        SendMessage(Handle, LM_SysCommand, $F012, 0);     End;    End;   If Not booChangedCur  Then Cursor:= crDefault; End;         Is this working on a MAC and under LINUX too ??? And what about Win10 ???