Recent

Author Topic: fpGui Native Windows Controls  (Read 12748 times)

Derit

  • Jr. Member
  • **
  • Posts: 55
fpGui Native Windows Controls
« on: February 09, 2016, 02:16:05 pm »
hi..
can i make native windows controls with fpgui ?
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: fpGui Native Windows Controls
« Reply #1 on: February 09, 2016, 07:05:32 pm »
Sorry I don't fully understand what you mean, so I'll answer a few different aspects.

fpGUI is a 100% custom drawn toolkit. That means fpGUI does all its own painting of all its widgets (controls). The same applies to any events in widgets - fpGUI handles user interaction and generates events without any OS or other toolkit assistance.

If you were referring to creating an fpGUI applications that looks "native" (there doesn't seem to be any OS that only has one look these days).... fpGUI includes 6 or more themes as standard, an many user contributed themes are available too. So with fpGUI you can have any look you want. There are very few limitations, if any at all.

One of the user contributed themes I have see, queries the underlying OS toolkit (Windows, KDE, Gnome) for system colours, then applies that to fpGUI. That theme isn't standard with fpGUI yet (but is under consideration).

Equally, you can create a theme that asks the underlying OS to paint widgets of equal functionality to a memory bitmap, then paint that bitmap in fpGUI. This is not something I am personally interested in, but it has been done in many other toolkits - Qt is probably the most popular example of this.

You could also create a bitmap based theme, where widgets get painted based on supplied bitmap images. I have experimented with this idea, and my work on this can be found in the <fpgui>/prototypes/ directory. This is actually something I'm interested in added to fpGUI. I have loads of ready made theme sets, consisting of many bitmaps for the most common widgets. There was a old program named "Pixel Image Editor" (also developed with FPC) that had loads of such bitmap themes. Win95, XP (silver), XP (blue/green), Ubuntu Human, Linux Mint are just some of the looks it could reproduce. Those bitmap themes could be reused for a fpGUI theme too.

If I didn't manage to answer your question, please elaborate as much as possible, and I'll try answering again. ;)
« Last Edit: February 09, 2016, 07:07:26 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: fpGui Native Windows Controls
« Reply #2 on: February 10, 2016, 01:20:29 am »
yes i understand,
fpgui fully custom draw controls,
in windows, i not found way, for make my own native controls
you can make abstract class for it, for way make native controls   :)
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Thaddy

  • Hero Member
  • *****
  • Posts: 14160
  • Probably until I exterminate Putin.
Re: fpGui Native Windows Controls
« Reply #3 on: February 10, 2016, 09:11:14 am »
You don't want to use fpGUI in that case. It is meant to be cross-platform and is very good at that.
If you want small and native controls (shameless plug, sorry) use KOL.
Specialize a type, not a var.

Zoran

  • Hero Member
  • *****
  • Posts: 1824
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: fpGui Native Windows Controls
« Reply #4 on: February 10, 2016, 09:39:14 am »
What do you mean by "my own native controls"?

Here, the phrase "native control" is used with the meaning - a widget provided by OS, that is provided by a library which we get as a standard (natively) with OS.
The phrase "my own control" I understand as "my custom drawn control", so exactly opposite from "native".

So, you have to choose - either use a "native" set of controls (use LCL with native widgetset) or "your own", which you make yourself from scratch.

FPGui gives you its own set of controls, which can be (automatically with themes) customized to resemble "native" controls. What you get with FPGui is consistent look and feel, independent from OS.

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: fpGui Native Windows Controls
« Reply #5 on: February 10, 2016, 11:06:23 am »
@thaddy kol is the best native controls independent platform
@zoran yes, i understand,
I mean "native control platform" such as buttons, ListView, TreeView, etc.
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: fpGui Native Windows Controls
« Reply #6 on: February 10, 2016, 11:12:36 am »
I mean "native control platform" such as buttons, ListView, TreeView, etc.

If you want really native controls, just include windows and follow the traditional windows creation and manipulation technique
 

Code: Pascal  [Select][+][-]
  1.  
  2. {
  3.   Copyright (c) 1996 by Charlie Calvert
  4.   Modifications by Florian Klaempfl
  5.  
  6.   Standard Windows API application written in Object Pascal.
  7.   No VCL code included. This is all done on the Windows API
  8.   level.
  9. }
  10.  
  11. {$APPTYPE GUI}
  12. {$MODE DELPHI}
  13. program WinHello;
  14.  
  15. uses
  16.   Windows;
  17.  
  18. const
  19.   AppName = 'WinHello';
  20.  
  21. function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
  22.                     LParam: LPARAM): LRESULT; stdcall; export;
  23.  
  24.   var
  25.      dc : hdc;
  26.      ps : paintstruct;
  27.      r : rect;
  28.  
  29. begin
  30.   WindowProc := 0;
  31.  
  32.   case AMessage of
  33.     wm_paint:
  34.       begin
  35.          dc:=BeginPaint(Window,@ps);
  36.          GetClientRect(Window,@r);
  37.          DrawText(dc,'Hello world by Free Pascal',-1,@r,
  38.            DT_SINGLELINE or DT_CENTER or DT_VCENTER);
  39.          EndPaint(Window,ps);
  40.          Exit;
  41.       end;
  42.     wm_Destroy:
  43.       begin
  44.          PostQuitMessage(0);
  45.          Exit;
  46.       end;
  47.   end;
  48.  
  49.   WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
  50. end;
  51.  
  52.  { Register the Window Class }
  53. function WinRegister: Boolean;
  54. var
  55.   WindowClass: WndClass;
  56. begin
  57.   WindowClass.Style := cs_hRedraw or cs_vRedraw;
  58.   WindowClass.lpfnWndProc := WndProc(@WindowProc);
  59.   WindowClass.cbClsExtra := 0;
  60.   WindowClass.cbWndExtra := 0;
  61.   WindowClass.hInstance := system.MainInstance;
  62.   WindowClass.hIcon := LoadIcon(0, idi_Application);
  63.   WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  64.   WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);
  65.   WindowClass.lpszMenuName := nil;
  66.   WindowClass.lpszClassName := AppName;
  67.  
  68.   Result := RegisterClass(WindowClass) <> 0;
  69. end;
  70.  
  71.  { Create the Window Class }
  72. function WinCreate: HWnd;
  73. var
  74.   hWindow: HWnd;
  75. begin
  76.   hWindow := CreateWindow(AppName, 'Hello world program',
  77.               ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
  78.               cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);
  79.  
  80.   if hWindow <> 0 then begin
  81.     ShowWindow(hWindow, CmdShow);
  82.     ShowWindow(hWindow, SW_SHOW);
  83.     UpdateWindow(hWindow);
  84.   end;
  85.  
  86.   Result := hWindow;
  87. end;
  88.  
  89.  
  90. var
  91.   AMessage: Msg;
  92.   hWindow: HWnd;
  93.  
  94. begin
  95.   if not WinRegister then begin
  96.     MessageBox(0, 'Register failed', nil, mb_Ok);
  97.     Exit;
  98.   end;
  99.   hWindow := WinCreate;
  100.   if longint(hWindow) = 0 then begin
  101.     MessageBox(0, 'WinCreate failed', nil, mb_Ok);
  102.     Exit;
  103.   end;
  104.  
  105.   while GetMessage(@AMessage, 0, 0, 0) do begin
  106.     TranslateMessage(AMessage);
  107.     DispatchMessage(AMessage);
  108.   end;
  109.   Halt(AMessage.wParam);
  110. end.
  111.  
  112.  
Holiday season is online now. :-)

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: fpGui Native Windows Controls
« Reply #7 on: February 10, 2016, 11:35:28 am »
I mean "native control platform" such as buttons, ListView, TreeView, etc.
In that case, fpGUI is probably not what you want.

fpGUI does on the other hand include its own Buttons (TfpgButton), ListView (TfpgListView), TreeView (TfpgTreeView) components which act very similar to native OS controls.

Everything you see in these screenshots are custom drawn controls, but they behave very similar to native OS controls, and are fully themeable.
http://fpgui.sourceforge.net/screenshots_apps.shtml
http://fpgui.sourceforge.net/screenshots_widgets.shtml

On a side note:
  Now if you want truly native and as low level as you can, you can create Windows-only applications with an amazing Assembly Language toolkit. [https://www.grc.com/smgassembly.htm]. Here the author managed to create a Windos GUI  application producing an executable of only 13,800 bytes.  ;)
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Derit

  • Jr. Member
  • **
  • Posts: 55
Re: fpGui Native Windows Controls
« Reply #8 on: February 11, 2016, 01:58:15 am »
@Deepaak nice  ;D
Lazarus Trunk/FPC Trunk/2.6.2/2.6.4

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: fpGui Native Windows Controls
« Reply #9 on: July 20, 2016, 01:58:19 am »
Hi, in this post was already say that fpGUI can theme.

The basic question here is how to create a custom theme and how to apply it to my fpGUI application.

There is a tutorial or something?

Edit: found fpGUI\examples\gui\customstyles, it's easy. Thanks Graeme.
« Last Edit: July 20, 2016, 04:15:30 am by lainz »

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: fpGui Native Windows Controls
« Reply #10 on: July 20, 2016, 12:54:27 pm »
You are welcome Lainz. ;)

And you can even have animated themes too. :)

  http://forum.lazarus.freepascal.org/index.php/topic,26121.0.html
« Last Edit: July 20, 2016, 01:01:59 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

 

TinyPortal © 2005-2018