Recent

Author Topic: How can I make a borderless form moveable  (Read 14450 times)

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: How can I make a borderless form moveable
« Reply #15 on: October 31, 2016, 07:19:00 pm »
Quote
This is the same as  SendMessage(Form1.Handle, LM_SYSCOMMAND, 61458, 0) ;
LM_SYSCOMMAND is the same as WM_SYSCOMMAND.
$F012 is the same as 61458.
Good to know... thank you very much...

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: How can I make a borderless form moveable
« Reply #16 on: November 01, 2016, 01:35:44 am »
Quote
I've attached a cropped screen grab to show what I've achieved.
I'm just curious: It looks like an antialiased border, so what API did you use ?

UpdateLayeredWindow or SetWindowRGN ?

Is that only one window ?

J-G

  • Hero Member
  • *****
  • Posts: 992
Re: How can I make a borderless form moveable
« Reply #17 on: November 01, 2016, 11:26:38 am »
Quote
I've attached a cropped screen grab to show what I've achieved.
I'm just curious: It looks like an antialiased border, so what API did you use ?

UpdateLayeredWindow or SetWindowRGN ?

Is that only one window ?
For the transparency coding I was directed by RVK and Fungus to use this :
(I've left in all the comments to explain far better than I can what is happening)
Code: Pascal  [Select][+][-]
  1. Const
  2.   LWA_COLORKEY = 1;
  3.   LWA_ALPHA = 2;
  4.   LWA_BOTH = 3;
  5.   WS_EX_LAYERED = $80000;
  6.   GWL_EXSTYLE = -20;
  7.  
  8.   {Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal Color As Long, ByVal X As Byte, ByVal alpha As Long) As Boolean }
  9.    function SetLayeredWindowAttributes (hWnd:Longint; Color:Longint; X:Byte; alpha:Longint):bool
  10.      stdcall; external 'USER32';
  11.  
  12.    {not sure how to alias these functions here ????   alias setwindowlonga!!}
  13.    {Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long }
  14.    Function SetWindowLongA (hWnd:Longint; nIndex:longint; dwNewLong:longint):longint
  15.      stdcall; external 'USER32';
  16.  
  17.    {Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long }
  18.    Function GetWindowLongA ( hWnd:Longint; nIndex:longint):longint
  19.      stdcall; external 'user32';
  20.  
  21. [...]
  22.  
  23. procedure SetTranslucent(ThehWnd: Longint; Color: Longint; nTrans: Integer);
  24. var
  25.   attrib:longint;
  26. begin
  27.     {SetWindowLong and SetLayeredWindowAttributes are API functions, see MSDN for details }
  28.     attrib := GetWindowLongA(ThehWnd, GWL_EXSTYLE);
  29.     SetWindowLongA (ThehWnd, GWL_EXSTYLE, attrib Or WS_EX_LAYERED);
  30.  
  31.     {anything with color value color will completely disappear if flag = 1 or flag = 3  }
  32.     SetLayeredWindowAttributes (ThehWnd, Color, nTrans,1);
  33. end;
  34.  
  35. [...]
  36.  
  37. procedure TInvClock.FormCreate(Sender: TObject);
  38. var
  39.    transparency:longint;
  40. begin
  41.     {the color were going to make transparent the White that the form background is set to}
  42.   transparency:= clWhite;
  43.     {call the function to do it}
  44.   SetTranslucent (InvClock.Handle, transparency, 0);
  45.  
  46.   Read_Date;
  47. end;
  48.  


The final 'Read_Date' is a separate procedure to initialize the Date and Time at program start-up.

The background image is a .PNG file with a white background and the hands are transparent .PNG Images - I haven't yet coded the analogue hand movement, for that I'm investigating the BGRABitmap routines created by lainz (that's my job for today!).

I coded the digital Time and Date display yesterday so a new image is attached to better show that it can be dragged and the background is transparent.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: How can I make a borderless form moveable
« Reply #18 on: November 02, 2016, 03:56:38 am »
Thank you very much ... interesting...

I found this in another thread and I think you should check this out:
http://www.getlazarus.org/forums/viewtopic.php?f=18&t=40
Someone did a clock (the crossplatform-way) with CROSS CODEBOT library and it can be resized...

There is another alternative: UpdateLayeredWindow or UpdateLayeredWindowIndirect + BGRABitmap or Direct2D or GDI+...
« Last Edit: October 08, 2017, 02:24:52 am by RAW »

RAW

  • Hero Member
  • *****
  • Posts: 871
Re: How can I make a borderless form moveable
« Reply #19 on: November 02, 2016, 03:58:44 am »
 :)
« Last Edit: October 08, 2017, 02:26:23 am by RAW »

J-G

  • Hero Member
  • *****
  • Posts: 992
Re: How can I make a borderless form moveable
« Reply #20 on: November 02, 2016, 01:44:51 pm »
Thank you very much ... interesting...

I found this in another thread and I think you should check this out:
http://www.getlazarus.org/forums/viewtopic.php?f=18&t=40
Someone did a clock (the crossplatform-way) with CROSS CODEBOT library and it can be resized (bigger/smaller) and you can use shadows and probably draw semi-transparent pixels... very interesting...

Thanks for that link SoE - I don't have time to be interested in Cross-Platform but the fact that iSurface uses Vector graphics could prove very useful.

Seeing the sub-seconds dial has prompted me to think about adding a stop-watch/timer option.

I now have three hands (H, M, S) working - albeit in a normal form and without a background - using lainz code as the basis but am stuggling to fully understand WHY! Now working on smoothing the seconds hand movement (just a fact of reading the milliseconds) and moving the code into my main program.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

 

TinyPortal © 2005-2018