Recent

Author Topic: [SOLVED]I can't find the constant HTBOTTOMRIGHT under Linux  (Read 6606 times)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
[SOLVED]I can't find the constant HTBOTTOMRIGHT under Linux
« on: November 04, 2017, 07:16:10 pm »
I try to change the panel size. There is a code

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  3.   StdCtrls
  4.   , LMessages
  5.   {$IFDEF UNIX}
  6.   , LCLType
  7.   {$ELSE}
  8.   , windows
  9.   {$ENDIF}
  10.   , Types
  11.   ;
  12.  
  13.  
  14. type
  15.  
  16.   { TPanel }
  17.  
  18.   TPanel = class(ExtCtrls.TPanel)
  19.     private
  20.       FSizeable: Boolean;
  21.       procedure SetSizeable(AValue: Boolean);
  22.       procedure LMNCHitTest(var Msg: TLMNCHITTEST); message LM_NCHITTEST;
  23.     public
  24.       property Sizeable: Boolean read FSizeable write SetSizeable default False;
  25.   end;
  26.  
  27.   { TForm1 }
  28.  
  29.   TForm1 = class(TForm)
  30. // <skiped>
  31.     Panel1: TPanel;
  32.     procedure Panel1MouseLeave(Sender: TObject);
  33.     procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
  34.       );
  35. // <skiped>
  36.   end;  
  37.  
  38. procedure TPanel.LMNCHitTest(var Msg: TLMNCHITTEST);
  39. begin
  40.   inherited;
  41.  
  42.   if (Msg.Result = HTCLIENT)
  43.       and PtInRect(Rect(Self.Width - 10, Self.Height - 10, Self.Width, Self.Height), ScreenToClient(Point(Msg.XPos,Msg.YPos)))
  44.       and Sizeable then
  45.       Msg.Result:= HTBOTTOMRIGHT;
  46. end;  
                                 

It works at Windows perfectly. The constant HTBOTTOMRIGHT can be found here ..\fpc_trunk\rtl\win\wininc\defines.inc. But on Linux I receive an error 

Code: Pascal  [Select][+][-]
  1. Error: Identifier not found "HTBOTTOMRIGHT"

How can I change the code to get the same result for Linux?
« Last Edit: November 21, 2017, 10:40:59 pm by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #1 on: November 04, 2017, 07:49:45 pm »
include lclintf
But I am sure they don't want the Trumps back...

wp

  • Hero Member
  • *****
  • Posts: 12682
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #2 on: November 04, 2017, 08:04:46 pm »
Instead of using the nonclient hit test try the first answer in http://delphidabbler.com/tips/92. It works in Lazarus out of the box, and if you replace the windows units by LCLType, LCLIntf, and LMessage it should work in Linux too. Remove the Paint method if you don't want the size grip.

Code: Pascal  [Select][+][-]
  1. unit SizeablePanel;
  2.  
  3. interface
  4.  
  5. uses
  6. //  Windows, Messages,           // <--- remove this
  7.   LclType, LCLIntf, LMessages,   // <--- add this
  8.   SysUtils, Classes, Graphics, Controls, Forms,
  9.   Dialogs, ExtCtrls;
  10.  

[EDIT]
It's even simpler: Just remove Windows and Messages, the LCL-Units are not needed at all.
« Last Edit: November 04, 2017, 10:10:36 pm by wp »

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #3 on: November 04, 2017, 08:52:50 pm »
That's a much more complete answer than I gave and simple tests shows it works...
But I am sure they don't want the Trumps back...

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #4 on: November 05, 2017, 07:39:47 pm »
It works in Lazarus out of the box, and if you replace the windows units by LCLType, LCLIntf, and LMessage it should work in Linux too.
Thanks for the help. You are right. The example #1 works as well at Linux. But, there is the strong time delay of a draw on Linux.

Remove the Paint method if you don't want the size grip.
Besides, on Linux there is no 'Marlett' font therefore I should draw Size Grip manually.
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #5 on: November 05, 2017, 08:53:03 pm »
Besides, on Linux there is no 'Marlett' font therefore I should draw Size Grip manually.
You can simply install it on linux. But mind copyright for commercial programming. Seems no issue: http://www.fontsner.com/font/Marlett-16281.html
« Last Edit: November 05, 2017, 08:57:35 pm by Thaddy »
But I am sure they don't want the Trumps back...

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #6 on: November 05, 2017, 09:03:39 pm »
You can simply install it on linux. But mind copyright for commercial programming. Seems no issue: http://www.fontsner.com/font/Marlett-16281.html
I can install this font of course. But users of my program also have to install this font?
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #7 on: November 06, 2017, 12:17:58 pm »
You can simply install it on linux. But mind copyright for commercial programming.
I drew grip size here such code
Code: Pascal  [Select][+][-]
  1. procedure Paint;
  2. var
  3.   EdgeMarg: Integer;
  4. begin
  5.   inherited Paint;
  6.   with Canvas do
  7.   begin
  8.     Pen.Style:= psSolid;
  9.     Pen.Width:= 1;
  10.     Pen.Color:= clGray;
  11.     EdgeMarg:= 3;
  12.     MoveTo(Self.ClientWidth - 6,Self.ClientHeight - EdgeMarg);
  13.     LineTo(Self.ClientWidth - EdgeMarg,Self.ClientHeight - 6);
  14.     MoveTo(Self.ClientWidth - 9,Self.ClientHeight - EdgeMarg);
  15.     LineTo(Self.ClientWidth - EdgeMarg,Self.ClientHeight - 9);
  16.     MoveTo(Self.ClientWidth - 12,Self.ClientHeight - EdgeMarg);
  17.     LineTo(Self.ClientWidth - EdgeMarg,Self.ClientHeight - 12);
  18.   end;
  19. end;


Now it works at any platform
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #8 on: November 06, 2017, 12:49:57 pm »
For windows the project works successfully, but for linux I watch freezing of the picture. Perhaps it occurs because I set Debian in VMWare. Please, somebody check the project at whom linux costs as the main OS.
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #9 on: November 06, 2017, 01:21:49 pm »
Resizes here without problems on Linux gtk2.

Thaddy

  • Hero Member
  • *****
  • Posts: 16653
  • Kallstadt seems a good place to evict Trump to.
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #10 on: November 06, 2017, 01:30:03 pm »
It works on a native videocard.
The VM? Which VM? virtualbox - with extensions installed - has no problems, QEMU has!
Your picture then freezes, but the borders should resize correctly (slow). After that the picture repaints too.
Is that what you experience?
But I am sure they don't want the Trumps back...

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #11 on: November 06, 2017, 01:34:32 pm »
Resizes here without problems on Linux gtk2.
Thank you very much. Now I am quiet.  ;)

The VM? Which VM? virtualbox - with extensions installed - has no problems, QEMU has!
VMware® Workstation 12 Pro

Means, the image is frozen because my video card rather feeble.

I am very grateful to you for the help and a valuable advice
« Last Edit: November 06, 2017, 01:38:16 pm by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: [SOLVED]I can't find the constant HTBOTTOMRIGHT under Linux
« Reply #12 on: November 21, 2017, 11:01:28 pm »
I have completed the component a little more. Now the sizeable panel can be called for different TEdit. Demo in the attachment

gif (win)
https://imgur.com/a/v7iYX

gif (linux)
https://imgur.com/a/GcOMB

Update: I have corrected some errors (12/25/2017)
« Last Edit: December 25, 2017, 12:21:50 pm by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

 

TinyPortal © 2005-2018