Lazarus

Programming => Widgetset => Other => Topic started by: dieselnutjob on April 13, 2014, 08:34:10 pm

Title: change title bar icon in fpgui program?
Post by: dieselnutjob on April 13, 2014, 08:34:10 pm
Is there a way to change the icon in the title bar of a program written using fpgui?

thanks
Title: Re: change title bar icon in fpgui program?
Post by: marcov on April 14, 2014, 10:06:27 am
Setting the lazarus form caption should propagate that to the FPGUI widgetset backend. If not, that is a bug in lcl-fpgui
Title: Re: change title bar icon in fpgui program?
Post by: dieselnutjob on April 14, 2014, 11:05:41 am
I haven't been using a Lazarus form.  I created the project using "Create a new project" then "Program" and then the form is defined in the text source.  I can't actually see it until I compile the program.
Title: Re: change title bar icon in fpgui program?
Post by: dieselnutjob on August 02, 2014, 11:50:25 am
I figured it out.

In Lazarus do Project > Project Options...

Under "Application" you can select an icon file just the same as you would for an LCL app.

Works in Windows but not Linux but I think that this is not unique to fpgui
Title: Re: change title bar icon in fpgui program?
Post by: benohb on August 02, 2014, 03:34:15 pm



Quote
I haven't been using a Lazarus form.  I created the project using "Create a new project" then "Program" and then the form is defined in the text source.  I can't actually see it until I compile the program.



You can use the form designer




1- http://wiki.lazarus.freepascal.org/fpGUI_Interface#Creating_your_first_LCL_application_with_fpGUI (http://wiki.lazarus.freepascal.org/fpGUI_Interface#Creating_your_first_LCL_application_with_fpGUI)
2-Project->Project options->Compiler Option-> Additions and Overrides
click "Set LCLwidgetTYpe"/SELECT "value fpgui"
Note : Some tools do not work
*not work :PageControl
*work      : buttons-input-memo-edit-ProgressBar-MenuItem-ListBox-GroupBox

Title: Re: change title bar icon in fpgui program?
Post by: benohb on August 02, 2014, 03:47:58 pm

Quote
Works in Windows but not Linux but I think that this is not unique to fpgui


Yes ..in linux it is use a fixed Icon (array of pixel)
..../fpgui/src/corelib/x11/fpg_x11.pas  **line 48
IconBitmapBits: packed array[1..32] of Byte = (
    $00, $00, $78, $07, $08, $00, $00, $00, $08, $07, $08, $01,
    $08, $01, $00, $00, $00, $00, $98, $74, $a4, $24, $84, $24,
    $b4, $24, $a4, $24, $18, $73, $00, $00); 
Title: Re: change title bar icon in fpgui program?
Post by: dieselnutjob on August 09, 2014, 08:58:23 pm

Quote
Works in Windows but not Linux but I think that this is not unique to fpgui


Yes ..in linux it is use a fixed Icon (array of pixel)
..../fpgui/src/corelib/x11/fpg_x11.pas  **line 48
IconBitmapBits: packed array[1..32] of Byte = (
    $00, $00, $78, $07, $08, $00, $00, $00, $08, $07, $08, $01,
    $08, $01, $00, $00, $00, $00, $98, $74, $a4, $24, $84, $24,
    $b4, $24, $a4, $24, $18, $73, $00, $00); 

I got this working in Linux
if you change the code to this

IconBitmapBits: packed array[1..32] of Byte = (
%00000000,%00000000,
%01111000,%00000111,
%00001000,%00001001,
%00111000,%00001001,
%00001000,%00000111,
%00001000,%00000001,
%00001000,%00000001,
%00000000,%00000000,
%00000000,%00000000,
%10011000,%01110100,
%10100100,%00100100,
%10000100,%00100100,
%10110100,%00100100,
%10100100,%00100100,
%00011000,%01110011,
%00000000,%00000000);

you can actually see the icon that you are getting but the way it is drawn has an opposite endianness or something.
so on the left you can see the "F" but back to front on the right the "P" but back to front.
Title: Re: change title bar icon in fpgui program?
Post by: engkin on August 10, 2014, 05:18:56 am
You can use words instead of bytes:
Code: [Select]
IconBitmapBitsW: packed array[1..16] of Word = (
%0000000000000000,
%0000011101111000,
%0000100100001000,
%0000100100111000,
%0000011100001000,
%0000000100001000,
%0000000100001000,
%0000000000000000,
%0000000000000000,
%0111010010011000,
%0010010010100100,
%0010010010000100,
%0010010010110100,
%0010010010100100,
%0111001100011000,
%0000000000000000);

and if you insist on using bytes:
Code: [Select]
IconBitmapBits: packed array[1..32] of Byte absolute IconBitmapBitsW;

and if you care, you can reverse the bits using any of the methods mentioned here (http://graphics.stanford.edu/~seander/bithacks.html?1=1#BitReverseObvious).
Title: Re: change title bar icon in fpgui program?
Post by: Graeme on August 10, 2014, 09:33:39 am
Is there a way to change the icon in the title bar of a program written using fpgui?
fpGUI doesn't currently have support for setting individual forms to have different window title icons. In Windows you can set the application icon using a standard *.rc file, which then becomes the default icon for all windows. In Linux it is hard-coded to a 2-bit (Black & White only) fpGUI logo.

The ability to set individual form icons has been on my todo list for a long time. I've got some time now, and will quickly knock out a solution. I'll post here as soon as it is done.
Title: Re: change title bar icon in fpgui program?
Post by: dieselnutjob on August 14, 2014, 04:03:36 pm
You can use words instead of bytes:

Yes your solution is better than mine.

and if you care, you can reverse the bits using any of the methods mentioned here (http://graphics.stanford.edu/~seander/bithacks.html?1=1#BitReverseObvious).

I just wanted other people to be able to figure out how to do without having to reverse engineer it like I did.
Title: Re: change title bar icon in fpgui program?
Post by: benohb on February 01, 2019, 11:37:12 am

  WindowTitle := 'blabla';
  IconName := 'stdimg.quit';   
Title: Re: change title bar icon in fpgui program?
Post by: Graeme on February 01, 2019, 11:54:04 am
Thanks Benohb for updating this thread with the correct answer. The original question was from 2014 (5 years ago). fpGUI has indeed improved since then.  ;)
TinyPortal © 2005-2018