Recent

Author Topic: Custom Drawing user interface  (Read 6956 times)

440bx

  • Hero Member
  • *****
  • Posts: 4067
Re: Custom Drawing user interface
« Reply #15 on: April 10, 2020, 07:25:42 pm »
A Writer said 'Mind is just like parachutte! it only works when you open it'!
That's true but, for peace of mind it's better to stay in the airplane (parachutes fail sometimes with results that are not particularly pretty.)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Custom Drawing user interface
« Reply #16 on: April 10, 2020, 07:37:46 pm »
The border of any window is controlled by the OS, not the application. Nothing stops you from setting your borderstyle to bsNone and draw your own (though you also need to handle window movement yourself then).
 

Hi!

Very simple solution:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. const BorderCol = clRed;
  3. begin
  4. canvas.pen.width := 5;
  5. canvas.Pen.Color := BorderCol;
  6. canvas.Rectangle(2,2,width -2, height - 2 );
  7. end;        

Winni

furious programming

  • Hero Member
  • *****
  • Posts: 858
Re: Custom Drawing user interface
« Reply #17 on: April 10, 2020, 08:17:32 pm »
there are so many holes of securities in that torrent, and so many (especialy multithreding) leaks that made me call it 'windoze'

Hmm... interesting... but who cares?

Anyway, this has nothing to do with the problem raised in this thread, so do not do offtop, and even more do not start another storm about the superiority of one OS over the other — I'm too old for this crap.

Very simple solution: […]

And very limited solution. Please, read this post carefully (second paragraph). 8)
« Last Edit: April 10, 2020, 08:20:45 pm by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

Otto

  • Full Member
  • ***
  • Posts: 226
Re: Custom Drawing user interface
« Reply #18 on: April 10, 2020, 09:55:16 pm »
[...]
What about WM_NCPAINT?
[...]

In my opinion, such a solution should be adequate to axisdj in his request:

[...]
I am in the process of becoming comfortable with Lazarus, and making a goal to move from vb6.
[...]
he says he wants to "migrate" from vb6 to FPC; vb6 was usually used to produce executables for Windows.

Otto.
Kind regards.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5486
  • Compiler Developer
Re: Custom Drawing user interface
« Reply #19 on: April 11, 2020, 02:20:29 pm »
The border of any window is controlled by the OS, not the application.

What about WM_NCPAINT?

As mentioned this isn't cross platform and especially on Linux with X11 dealing with the Window Managers can be quite a mess...

Quote
Nothing stops you from setting your borderstyle to bsNone and draw your own (though you also need to handle window movement yourself then).

Yep, but if I set the BorderStyle to bsNone, then I will automatically lose the system context menu, which is available by clicking LMB on the form icon or RMB on caption bar, or by pressing Alt+Space. And, because of this, I will lose the whole system mechanism to moving and resizing the form too.

That's what I meant with though you also need to handle window movement yourself then.

NOT portable.
That depends on the definition of portable.  My definition of portable is: put it on a USB drive and run it without any "unusual" dependencies such as a C runtime library (dll), IOW, a stand alone program.

440bx, please, I know you are rather Windows centered, but even you should be aware that “portable” on this forum more often than not means “cross platform”.

[...]
What about WM_NCPAINT?
[...]

In my opinion, such a solution should be adequate to axisdj in his request:

[...]
I am in the process of becoming comfortable with Lazarus, and making a goal to move from vb6.
[...]
he says he wants to "migrate" from vb6 to FPC; vb6 was usually used to produce executables for Windows.

But axisdj should know the limitations they're facing right away and maybe pursue a better/different way from the start. Otherwise they'll come along in a few months, ask how to do that on Linux (cause they've discovered, hey, with Lazarus one can also do Linux programs!) and then we say, “though luck, axisdj, that won't work on Linux or at least will be very specific to the window manager”.

Don't take me wrong, there is nothing bad about making an application that's only supposed to work on a specific set of platforms. But if one doesn't need to restrict oneself unnecessarily, why do it?

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Custom Drawing user interface
« Reply #20 on: April 11, 2020, 02:44:59 pm »
Hi!

* You dont have to disable the borderstyle to bsNone to draw your own border.

* In gtk2 the LCL draws over the theme - look at the attached image.
   This from KDE Plasma, theme "Altes Büro" with my code from above.

Winni

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Custom Drawing user interface
« Reply #21 on: April 11, 2020, 03:12:27 pm »
You can get a Device Context to the Window border, in fact that is how the menus and title bar are maintain via the OS..

 Also you can handle the WM_NCPAINT message so there isn't really too much if an issue here except with the fact that Lazarus filters the WM_NCPAINT message and thus makes that kind of a trap..
 
   yes I know you can hook it...

The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Custom Drawing user interface
« Reply #22 on: April 11, 2020, 03:16:12 pm »
Hi!

In Linux there is no  WM_NCPAINT

Winni

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: Custom Drawing user interface
« Reply #23 on: April 11, 2020, 04:10:11 pm »
I understand but that does not mean the widgets can't simulate one like it does now...

 Also using the GetWindowDC over GetDC should work in other widgets.

 The only difference is the GetWindowDC  offsets the 0,0 and size to the start of the window frame over what GetDC does …

 basics of DC configurations...

 with the WM_PAINT the DC offered up has the offset placed in it already for the client area.. where as the WM_NCPAINT has it for the whole frame.
The only true wisdom is knowing you know nothing

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Custom Drawing user interface
« Reply #24 on: April 11, 2020, 04:45:52 pm »
I use BGRAControls  :D

Check this custom drawn window, of course it has no menu, it's a ribbon style
https://raw.githubusercontent.com/bgrabitmap/bgracontrols/dev-bgracontrols/docs/img/bgraribbon.png

furious programming

  • Hero Member
  • *****
  • Posts: 858
Re: Custom Drawing user interface
« Reply #25 on: April 12, 2020, 12:24:47 am »
As mentioned this isn't cross platform and especially on Linux with X11 dealing with the Window Managers can be quite a mess...

There is a huge difference between ”is controlled by the system” and ”is not cross-platform”. It is not true that the application can't control the rendering of the window border, but it is a pity that only on Windows platform.

IMO no matter what we have now, Lazarus needs a skinning system. There is a lot of people that needs this great functionality, including me — native controls with non-native appearance, like in RAD Studio. Not only for created projects, but also for IDE itself — I dream of a dark theme similar to that used by VS.

But I know that implementing such a system is a long and hard job and you guys have a million things to implement and fix, so I won't complain that there are no skins support. Maybe in the future. 8)
« Last Edit: April 12, 2020, 12:30:25 am by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Custom Drawing user interface
« Reply #26 on: April 12, 2020, 03:34:31 am »
As mentioned this isn't cross platform and especially on Linux with X11 dealing with the Window Managers can be quite a mess...

There is a huge difference between ”is controlled by the system” and ”is not cross-platform”. It is not true that the application can't control the rendering of the window border, but it is a pity that only on Windows platform.

IMO no matter what we have now, Lazarus needs a skinning system. There is a lot of people that needs this great functionality, including me — native controls with non-native appearance, like in RAD Studio. Not only for created projects, but also for IDE itself — I dream of a dark theme similar to that used by VS.

But I know that implementing such a system is a long and hard job and you guys have a million things to implement and fix, so I won't complain that there are no skins support. Maybe in the future. 8)

Once I said that, and they say that Lazarus must look native.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Custom Drawing user interface
« Reply #27 on: April 12, 2020, 07:09:37 am »
As mentioned this isn't cross platform and especially on Linux with X11 dealing with the Window Managers can be quite a mess...

There is a huge difference between ”is controlled by the system” and ”is not cross-platform”. It is not true that the application can't control the rendering of the window border, but it is a pity that only on Windows platform.

IMO no matter what we have now, Lazarus needs a skinning system. There is a lot of people that needs this great functionality, including me — native controls with non-native appearance, like in RAD Studio. Not only for created projects, but also for IDE itself — I dream of a dark theme similar to that used by VS.

But I know that implementing such a system is a long and hard job and you guys have a million things to implement and fix, so I won't complain that there are no skins support. Maybe in the future. 8)

Once I said that, and they say that Lazarus must look native.
That imply that they can't enable disable skins as requested which might say more about the team.

mercurhyo

  • Full Member
  • ***
  • Posts: 242
Re: Custom Drawing user interface
« Reply #28 on: April 12, 2020, 08:52:26 am »

Hmm... interesting... but who cares?

Noone cares :D war is (if there was a war) over for about 10 years. Since

94% not 98% pardon me, servers, 100% intelligent cars, 77% smartphones, 100% GPS, China (1/3 of mankind) and most industrial robotics (idk percentage yet but assume much more than 95%) are based on nix systems. That means windows has become a sort of niche for deskies computers and lapies-topies ...LOL that is why i did not upgrade my seven  :P

don't worry about my parachute  :D

back to the subject, ... yep it would be fun for lazarus to have its own 'firemonkey' skins like delphi... but due to lhe constraints on the dev team, lack of time and resources, I don't think it would be possible in a near future.
« Last Edit: April 12, 2020, 08:59:38 am by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

PascalDragon

  • Hero Member
  • *****
  • Posts: 5486
  • Compiler Developer
Re: Custom Drawing user interface
« Reply #29 on: April 12, 2020, 11:18:08 am »
back to the subject, ... yep it would be fun for lazarus to have its own 'firemonkey' skins like delphi... but due to lhe constraints on the dev team, lack of time and resources, I don't think it would be possible in a near future.

@anyone who wants custom themeing in LCL:
Lazarus and the LCL are open source. So why not give the dev team a break (as many said, they have enough to work on already) and implement that yourself and provide that as a patch? It might need a few revisions if the implementation doesn't match the dev team's expectations (so don't give up right away), but in the end everyone might profit from that. :) (a first step might be to improve the custom drawn controls as they can be used with the native widgetsets as well)

 

TinyPortal © 2005-2018