Sign in Join
Wiki copytemporary

MSEide MSEgui Howto: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Demos and examples
22
33<https://github.com/mse-org/mseuniverse/>
44
55## Win32 Application Icon and Properties
66
771\) Prepare the resource source files in the directory of your program:
88
99File "version_data.rc":
1010
11-`1 VERSIONINFO`\
12-`FILEVERSION 4,0,3,17`\
13-`PRODUCTVERSION 3,0,0,0`\
14-`FILEFLAGSMASK 0`\
15-`FILEOS 0x40000`\
16-`FILETYPE 1`\
17-`{`\
18-` BLOCK "StringFileInfo"`\
19-` {`\
20-`  BLOCK "040904E4"`\
21-`  {`\
22-`  VALUE "CompanyName","JSC TashkentP"`\
23-`  VALUE "FileDescription","The main program file"`\
24-`  VALUE "FileVersion","0.9a"`\
25-`  VALUE "InternalName","ARM Podpiska"`\
26-`  VALUE "LegalCopyright","JSC TashkentP’s property"`\
27-`  VALUE "OriginalFilename","podpiska.pas"`\
28-`  VALUE "ProductName","The program for ARM Podpiska"`\
29-`  VALUE "ProductVersion","0.9a"`\
30-`  }`\
31-` }`\
32-`}`
11+``` pascal
12+1 VERSIONINFO
13+FILEVERSION 4,0,3,17
14+PRODUCTVERSION 3,0,0,0
15+FILEFLAGSMASK 0
16+FILEOS 0x40000
17+FILETYPE 1
18+{
19+ BLOCK "StringFileInfo"
20+ {
21+ BLOCK "040904E4"
22+ {
23+ VALUE "CompanyName","JSC TashkentP"
24+ VALUE "FileDescription","The main program file"
25+ VALUE "FileVersion","0.9a"
26+ VALUE "InternalName","ARM Podpiska"
27+ VALUE "LegalCopyright","JSC TashkentP’s property"
28+ VALUE "OriginalFilename","podpiska.pas"
29+ VALUE "ProductName","The program for ARM Podpiska"
30+ VALUE "ProductVersion","0.9a"
31+ }
32+ }
33+}
34+```
3335
3436File "icon_data.rc":
3537
36-` AppIcon ICON "app_icon.ico"`
38+```text
39+ AppIcon ICON "app_icon.ico"
40+```
3741
3842where "app_icon.ico" is 128x128 24bit ICO image. You may use any size at your favour (usually depends on preferable destop resolution/size) commonly greater or equal to 24x24 pixels.
3943
4044My favorite editor to prepare such (and any kind of image) files is "Embellish".
4145
42462\) From within Win-32 command shell, compile the prepared files with the supplied FPC resource compiler:
4347
44-` # windres -O res -i version_data.rc -o version_data.res`\
45-` # windres -O res -i icon_data.rc -o icon_data.res`
48+```text
49+ # windres -O res -i version_data.rc -o version_data.res
50+ # windres -O res -i icon_data.rc -o icon_data.res
51+```
4652
47533\) use the compiled resources in your application :
4854
4955``` pascal
5056program super_puper;
5157
5258{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
5359{$ifdef FPC}
5460 {$ifdef mswindows}
5561 {$apptype console}
5662 {$endif}
5763{$endif}
5864uses
5965 {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}msegui,mseforms,
6066 main,dmmain,dmprint, dmacnt1, dmf18,dmrefs,
6167 connsetupform,mseconsts,mseconsts_ru,mseconsts_uzcyr;
6268
6369// importing the compiled resources
6470
6571{$ifdef mswindows}
6672 {$R version_data.res}
6773 {$R icon_data.res}
6874{$endif}
6975
7076begin
7177 setlangconsts('ru');
7278 application.createdatamodule(tdmmainmo,dmmainmo);
7379 application.createdatamodule(tdmprintmo, dmprintmo);
7480 application.createdatamodule(tdmacnt1mo, dmacnt1mo);
7581 application.createdatamodule(tdmf18mo, dmf18mo);
7682 application.createdatamodule(tdmrefsmo, dmrefsmo);
7783 application.createform(tmainfo,mainfo);
7884 application.run;
7985end.
8086```
8187
8288That's all at the moment.
8389
8490## Dynamic widget creation
8591
8692To dynamically create a new widget (without using IDE), you need to do the following steps:
8793
8894- Instantiate a class with its `Create` constructor (passing the owner as the argument).
8995- Create a `frame` for the component and set up its properties.
9096- Optionally, create a `face` for the component and set up its properties.
9197- Set up the component size with `bounds_cx` and `bounds_cy` properties.
9298- Add the component to the window or other container by calling the container's `insertwidget`.
9399- Show the component by calling its `show` method, or by setting `visible` to `true`.
94100
95101Here is an example of dynamically creating a `tedit` (for this code to work, you need to add `dynedit: tedit;` property declaration):
96102
97103``` pascal
98104procedure tmainfo.mainformcreated(const sender: TObject);
99105begin
100106 dynedit := tedit.Create(self);
101107 dynedit.bounds_cx := 100;
102108 dynedit.bounds_cy := 21;
103109 dynedit.createframe;
104110 dynedit.frame.levelo := -2;
105111 insertwidget(dynedit, makepoint(300, 10));
106112 dynedit.show;
107113end;
108114```
109115
110116If you need custom value for the `face` property, you can set it up as follows:
111117
112118``` pascal
113119 dynedit.createface;
114120 with dynedit.face do begin
115121 fade_color.count := 2;
116122 fade_color[0] := cl_ltgreen;
117123 fade_color[1] := cl_dkgreen;
118124 fade_direction := gd_down;
119125 end;
120126```
121127
122128---
123129*From the Free Pascal wiki, page "MSEide MSEgui Howto", as it stood on 2023-07-20 after a change by Fredvs, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
124130Category: MSEide+MSEgui
125131Category: Tutorials
126132Category: Windows

Back to history