MSEide MSEgui Howto: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | ## Demos and examples | |
| 2 | 2 | ||
| 3 | 3 | <https://github.com/mse-org/mseuniverse/> | |
| 4 | 4 | ||
| 5 | 5 | ## Win32 Application Icon and Properties | |
| 6 | 6 | ||
| 7 | 7 | 1\) Prepare the resource source files in the directory of your program: | |
| 8 | 8 | ||
| 9 | 9 | File "version_data.rc": | |
| 10 | 10 | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 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 | + | ``` | |
| 33 | 35 | ||
| 34 | 36 | File "icon_data.rc": | |
| 35 | 37 | ||
| 36 | - | ||
| 38 | + | ```text | |
| 39 | + | AppIcon ICON "app_icon.ico" | |
| 40 | + | ``` | |
| 37 | 41 | ||
| 38 | 42 | where "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. | |
| 39 | 43 | ||
| 40 | 44 | My favorite editor to prepare such (and any kind of image) files is "Embellish". | |
| 41 | 45 | ||
| 42 | 46 | 2\) From within Win-32 command shell, compile the prepared files with the supplied FPC resource compiler: | |
| 43 | 47 | ||
| 44 | - | ||
| 45 | - | ||
| 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 | + | ``` | |
| 46 | 52 | ||
| 47 | 53 | 3\) use the compiled resources in your application : | |
| 48 | 54 | ||
| 49 | 55 | ``` pascal | |
| 50 | 56 | program super_puper; | |
| 51 | 57 | ||
| 52 | 58 | {$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif} | |
| 53 | 59 | {$ifdef FPC} | |
| 54 | 60 | {$ifdef mswindows} | |
| 55 | 61 | {$apptype console} | |
| 56 | 62 | {$endif} | |
| 57 | 63 | {$endif} | |
| 58 | 64 | uses | |
| 59 | 65 | {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}msegui,mseforms, | |
| 60 | 66 | main,dmmain,dmprint, dmacnt1, dmf18,dmrefs, | |
| 61 | 67 | connsetupform,mseconsts,mseconsts_ru,mseconsts_uzcyr; | |
| 62 | 68 | ||
| 63 | 69 | // importing the compiled resources | |
| 64 | 70 | ||
| 65 | 71 | {$ifdef mswindows} | |
| 66 | 72 | {$R version_data.res} | |
| 67 | 73 | {$R icon_data.res} | |
| 68 | 74 | {$endif} | |
| 69 | 75 | ||
| 70 | 76 | begin | |
| 71 | 77 | setlangconsts('ru'); | |
| 72 | 78 | application.createdatamodule(tdmmainmo,dmmainmo); | |
| 73 | 79 | application.createdatamodule(tdmprintmo, dmprintmo); | |
| 74 | 80 | application.createdatamodule(tdmacnt1mo, dmacnt1mo); | |
| 75 | 81 | application.createdatamodule(tdmf18mo, dmf18mo); | |
| 76 | 82 | application.createdatamodule(tdmrefsmo, dmrefsmo); | |
| 77 | 83 | application.createform(tmainfo,mainfo); | |
| 78 | 84 | application.run; | |
| 79 | 85 | end. | |
| 80 | 86 | ``` | |
| 81 | 87 | ||
| 82 | 88 | That's all at the moment. | |
| 83 | 89 | ||
| 84 | 90 | ## Dynamic widget creation | |
| 85 | 91 | ||
| 86 | 92 | To dynamically create a new widget (without using IDE), you need to do the following steps: | |
| 87 | 93 | ||
| 88 | 94 | - Instantiate a class with its `Create` constructor (passing the owner as the argument). | |
| 89 | 95 | - Create a `frame` for the component and set up its properties. | |
| 90 | 96 | - Optionally, create a `face` for the component and set up its properties. | |
| 91 | 97 | - Set up the component size with `bounds_cx` and `bounds_cy` properties. | |
| 92 | 98 | - Add the component to the window or other container by calling the container's `insertwidget`. | |
| 93 | 99 | - Show the component by calling its `show` method, or by setting `visible` to `true`. | |
| 94 | 100 | ||
| 95 | 101 | Here is an example of dynamically creating a `tedit` (for this code to work, you need to add `dynedit: tedit;` property declaration): | |
| 96 | 102 | ||
| 97 | 103 | ``` pascal | |
| 98 | 104 | procedure tmainfo.mainformcreated(const sender: TObject); | |
| 99 | 105 | begin | |
| 100 | 106 | dynedit := tedit.Create(self); | |
| 101 | 107 | dynedit.bounds_cx := 100; | |
| 102 | 108 | dynedit.bounds_cy := 21; | |
| 103 | 109 | dynedit.createframe; | |
| 104 | 110 | dynedit.frame.levelo := -2; | |
| 105 | 111 | insertwidget(dynedit, makepoint(300, 10)); | |
| 106 | 112 | dynedit.show; | |
| 107 | 113 | end; | |
| 108 | 114 | ``` | |
| 109 | 115 | ||
| 110 | 116 | If you need custom value for the `face` property, you can set it up as follows: | |
| 111 | 117 | ||
| 112 | 118 | ``` pascal | |
| 113 | 119 | dynedit.createface; | |
| 114 | 120 | with dynedit.face do begin | |
| 115 | 121 | fade_color.count := 2; | |
| 116 | 122 | fade_color[0] := cl_ltgreen; | |
| 117 | 123 | fade_color[1] := cl_dkgreen; | |
| 118 | 124 | fade_direction := gd_down; | |
| 119 | 125 | end; | |
| 120 | 126 | ``` | |
| 121 | 127 | ||
| 122 | 128 | --- | |
| 123 | 129 | *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).* | |
| 124 | 130 | Category: MSEide+MSEgui | |
| 125 | 131 | Category: Tutorials | |
| 126 | 132 | Category: Windows |
