Portal:HowTo Demos: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Portal:HowTo Demos
| Old | New | Line | |
|---|---|---|---|
| 1 | + |  This portal collects together in one place a significant number of short demonstration programs that have been posted on the [Free Pascal and Lazarus Forums](https://forum.lazarus.freepascal.org/). Each of the demonstration programs generally provides a simple example of one particular development technique. | |
| 2 | + | ||
| 3 | + | The Portal was the brainchild of [Handoko](https://forum.lazarus.freepascal.org/index.php/topic,48264.0.html) who also provided the initial list of demonstration programs from the Forums. | |
| 4 | + | ||
| 5 | + | **Platform Portals:** [[Portal:Android|Android]] - [[Portal:Embedded|Embedded]] - [[Portal:FreeBSD|FreeBSD]] - [[Portal:iOS|iOS]] - [[Portal:Linux|Linux]] - [[Portal:Mac|Mac]] - [[Portal:WinCE|WinCE]] - [[Portal:Windows|Windows]] | |
| 6 | + | ||
| 7 | + | **Topic Portals:** [[Portal:New Users|New Users]] - [[Portal:Databases|Database Development]] - [[Portal:Game Development|Game Development]] - [[Portal:Hardware and Robotics|Hardware and Robotics]] - [[Portal:HowTo Demos|HowTo Demos]] - [[Portal:SciTech|Science and Technology]] - [[Portal:Web Development|Web Development]] | |
| 8 | + | ||
| 9 | + | **Categories:** **[Code](/wiki-category/Code)** - **[Code Snippets](/wiki-category/Code%20Snippets)** - **[Example Programs](/wiki-category/Example%20programs)** - **[Tutorials](/wiki-category/Tutorials)** | |
| 10 | + | ||
| 11 | + | ## Android | |
| 12 | + | ||
| 13 | + | - [OpenGL ES2 Circle](https://forum.lazarus.freepascal.org/index.php/topic,44811.msg315311.html#msg315311). Requirement: LAMW. Drawing a circle using jCanvasES2.DrawLine instead of DrawCircle. | |
| 14 | + | ||
| 15 | + | - [OpenGL ES2 Rectangle](https://forum.lazarus.freepascal.org/index.php/topic,44708.msg314630.html#msg314630). Requirement: LAMW. Drawing a rectangle using jCanvasES2.DrawPolyFill instead of DrawRect. | |
| 16 | + | ||
| 17 | + | - [Simple polygon animation](https://forum.lazarus.freepascal.org/index.php/topic,44241.msg310991.html#msg310991). Requirement: LAMW. A simple animation using jCanvas. | |
| 18 | + | ||
| 19 | + | ## File handling | |
| 20 | + | ||
| 21 | + | - [Binary file demo](https://forum.lazarus.freepascal.org/index.php/topic,43045.msg307111.html#msg307111). How to show, append and delete data from a binary file. | |
| 22 | + | ||
| 23 | + | - [Text file demo](https://forum.lazarus.freepascal.org/index.php/topic,37766.msg254800.html#msg254800). How to read and append data to a text file. | |
| 24 | + | ||
| 25 | + | - [Text File Demo \#2](https://forum.lazarus.freepascal.org/index.php/topic,39769.msg274036.html#msg274036). How to read and append data to a text file. | |
| 26 | + | ||
| 27 | + | - [Save component values to a file](https://forum.lazarus.freepascal.org/index.php/topic,42293.msg295057.html#msg295057). Save text data easily using TStringList.SaveToFile. | |
| 28 | + | ||
| 29 | + | - [Load and show image from Resource Stream](https://forum.lazarus.freepascal.org/index.php/topic,42144.msg293579.html#msg293579). How to add an image to a project resource and load it. | |
| 30 | + | ||
| 31 | + | - [Load a picture and show it](https://forum.lazarus.freepascal.org/index.php/topic,37442.msg251587.html#msg251587). How to use OpenPictureDialog and LoadFromFile. | |
| 32 | + | ||
| 33 | + | - [Detect kind of file using DragAndDrop](https://forum.lazarus.freepascal.org/index.php/topic,49069.0.html). How to detect the type of file using drag and drop. | |
| 34 | + | ||
| 35 | + | ## General | |
| 36 | + | ||
| 37 | + | - Drawing, moving, making connection between shapes. Shows TShape can be used for [simple diagram drawing](https://forum.lazarus.freepascal.org/index.php/topic,41036.msg284131.html#msg284131). | |
| 38 | + | ||
| 39 | + | - Generating a huge text file. Demonstrates a technique for reducing program responsiveness to [improve performance](https://forum.lazarus.freepascal.org/index.php/topic,43806.msg307101.html#msg307101). | |
| 40 | + | ||
| 41 | + | - [Drag and drop shape](https://forum.lazarus.freepascal.org/index.php/topic,38844.msg265130.html#msg265130). Drag and drop without using the built-in drag and drop feature. | |
| 42 | + | ||
| 43 | + | - [Minimize to TaskBar or Tray](https://forum.lazarus.freepascal.org/index.php/topic,42124.msg293401.html#msg293401). A workaround to minimize to tray, not the best solution but works. | |
| 44 | + | ||
| 45 | + | - [TMyCircle Component](https://forum.lazarus.freepascal.org/index.php/topic,42106.msg293281.html#msg293281). How to write your own component, the OOP way. | |
| 46 | + | ||
| 47 | + | - [Moving an Object by pressing a key](https://forum.lazarus.freepascal.org/index.php/topic,41089.msg284614.html#msg284614). How to detect left/right shift key pressing. | |
| 48 | + | ||
| 49 | + | - [Pausing and Continuing an animation](https://forum.lazarus.freepascal.org/index.php/topic,39790.msg274096.html#msg274096). How to pause and continue the animation. | |
| 50 | + | ||
| 51 | + | - [Control an Object's direction using the keyboard](https://forum.lazarus.freepascal.org/index.php/topic,36306.msg241818.html#msg241818). How to detect user keyboard input. | |
| 52 | + | ||
| 53 | + | - [Convert Unicode to TBytes](https://forum.lazarus.freepascal.org/index.php/topic,37887.msg256019.html#msg256019). How to use WideBytesOf and WideString functions. | |
| 54 | + | ||
| 55 | + | - [Communicate between two programs](https://forum.lazarus.freepascal.org/index.php/topic,43489.msg304434.html#msg304434). This demo showing how to use simpleipc. | |
| 56 | + | ||
| 57 | + | - [Timer demo](https://forum.lazarus.freepascal.org/index.php/topic,52780.msg389815.html#msg389815) - How to use a TTimer control. | |
| 58 | + | ||
| 59 | + | - [Delete tags](https://forum.lazarus.freepascal.org/index.php/topic,58207.msg433568.html#msg433568) - How to delete HTML tags from text. | |
| 60 | + | ||
| 61 | + | ## Graphics | |
| 62 | + | ||
| 63 | + | - Get pixel color of an image. It may sound easy but actually it is [not so easy](https://forum.lazarus.freepascal.org/index.php/topic,37242.msg252828.html#msg252828). | |
| 64 | + | ||
| 65 | + | - A very simple single player [Pong game](https://forum.lazarus.freepascal.org/index.php/topic,42439.msg297949.html#msg297949). | |
| 66 | + | ||
| 67 | + | - [Game Map Editor](https://forum.lazarus.freepascal.org/index.php/topic,43999.msg309134.html#msg309134). A very basic load and edit map for game. | |
| 68 | + | ||
| 69 | + | - [Fading images using BGRABitmap](https://forum.lazarus.freepascal.org/index.php/topic,43823.msg307918.html#msg307918). Requirement: BGRABitmap. Build your own slideshow and learn doing proportional scaling using aspect ratio of the picture. | |
| 70 | + | ||
| 71 | + | - [Center, resize image on the screen](https://forum.lazarus.freepascal.org/index.php/topic,43424.msg303879.html#msg303879). Resize an image at the center position of the image. | |
| 72 | + | ||
| 73 | + | - [Simple animation](https://forum.lazarus.freepascal.org/index.php/topic,41135.msg284936.html#msg284936). A very basic animation using a TTimer. | |
| 74 | + | ||
| 75 | + | - [Moving circles](https://forum.lazarus.freepascal.org/index.php/topic,38136.msg263143.html#msg263143). How to fix an unwanted flickering effect. | |
| 76 | + | ||
| 77 | + | - [Change background color of an image.](https://forum.lazarus.freepascal.org/index.php/topic,37251.msg249962.html#msg249962) A not so accurate colorshift on an image. | |
| 78 | + | ||
| 79 | + | - [OpenGL 2D Text Using Textures](https://forum.lazarus.freepascal.org/index.php/topic,35850.msg238019.html#msg238019). Requirement: LazOpenGLContext. How to write text in OpenGL using textures loaded from an image file. | |
| 80 | + | ||
| 81 | + | - [TCanvas Text](https://forum.lazarus.freepascal.org/index.php/topic,46775.msg333936.html#msg333936). How to draw superscript and subscript text using TCanvas. | |
| 82 | + | ||
| 83 | + | - [Sticky Balls](https://forum.lazarus.freepascal.org/index.php/topic,38511.msg262706.html#msg262706). Not so accurate inverse kinematics demo. | |
| 84 | + | ||
| 85 | + | - [GradientFill Rectangle](https://forum.lazarus.freepascal.org/index.php/topic,41265.msg286208.html#msg286208). How to use GradientFill. | |
| 86 | + | ||
| 87 | + | - [Rock, Paper, Scissors](https://forum.lazarus.freepascal.org/index.php/topic,41135.msg284928.html#msg284928). A simple game. Note for Unix/like operating systems: change the path delimiter to make the code work. | |
| 88 | + | ||
| 89 | + | - [Bullet and asteroid collision detection](https://forum.lazarus.freepascal.org/index.php/topic,45729.msg323878.html#msg323878). How to do collision detection between a bullet and a polygonal object. | |
| 90 | + | ||
| 91 | + | - [Draw Circles Using CSMFL](https://forum.lazarus.freepascal.org/index.php/topic,37425.msg259245.html#msg259245). Requirement: SFML/CSFML headers binding and CSFML libraries. How to use CSFML in FPC. | |
| 92 | + | ||
| 93 | + | - [Get pixel color of an image](https://forum.lazarus.freepascal.org/index.php/topic,37242.msg253349.html#msg253349). How to load an image, show its information and the pixel color under the mouse pointer. | |
| 94 | + | ||
| 95 | + | - [Move a shape with a mouse](https://forum.lazarus.freepascal.org/index.php/topic,43376.msg303582.html#msg303582). Move rectangles using a mouse. | |
| 96 | + | ||
| 97 | + | - [Selection Demo](https://forum.lazarus.freepascal.org/index.php/topic,43474.msg304454.html#msg304454). A movable and resizeable selection. | |
| 98 | + | ||
| 99 | + | - [Sprite picking and moving](https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246309.html#msg246309). Hit Testing - a must learn topic for every graphics programmer. | |
| 100 | + | ||
| 101 | + | - [Dancing Balls](https://forum.lazarus.freepascal.org/index.php/topic,38511.msg262692.html#msg262692). Balls that connect to each other. | |
| 102 | + | ||
| 103 | + | - [Screenshot capture](https://forum.lazarus.freepascal.org/index.php/topic,33138.msg214178.html#msg214178). How to screenshot capture and crop. | |
| 104 | + | ||
| 105 | + | - [Remove image shadow](https://forum.lazarus.freepascal.org/index.php/topic,49314.msg357420.html#msg357420). How to remove an image shadow and crop the image. | |
| 106 | + | ||
| 107 | + | - [Display image in console program](https://forum.lazarus.freepascal.org/index.php/topic,49583.msg359879.html#msg359879). How to display an image in a console program (Windows API method). | |
| 108 | + | ||
| 109 | + | - How to use [bitmap.scanline](https://forum.lazarus.freepascal.org/index.php/topic,49855.0.html). | |
| 110 | + | ||
| 111 | + | - How to do [offscreen rendering in Metal framework](https://forum.lazarus.freepascal.org/index.php/topic,42306.msg366256.html#msg366256) (macOS only). | |
| 112 | + | ||
| 113 | + | - How to [load a TImagelist at run time](https://forum.lazarus.freepascal.org/index.php/topic,52886.msg390735.html#msg390735) Multiplatform. | |
| 114 | + | ||
| 115 | + | ## Networking | |
| 116 | + | ||
| 117 | + | - [Game Client and Server](https://forum.lazarus.freepascal.org/index.php/topic,38866.msg266673.html#msg266673). The basics for building a client and server program. | |
| 118 | + | ||
| 119 | + | - [FTP Connect](https://forum.lazarus.freepascal.org/index.php/topic,47015.msg336047.html#msg336047). Requirement: Synapse (can be installed using OPM). How to connect to a FTP server. | |
| 120 | + | ||
| 121 | + | - [HTML to Text](https://forum.lazarus.freepascal.org/index.php/topic,35980.msg239199.html#msg239199). Requirement: fasthtmlparser. Extract data from a web page. | |
| 122 | + | ||
| 123 | + | - [Synapse TCP/IP client and server](https://forum.lazarus.freepascal.org/index.php/topic,48677.msg350793.html#msg350793). Requirement: Synapse. | |
| 124 | + | ||
| 125 | + | - [Retrieve https web page](https://forum.lazarus.freepascal.org/index.php/topic,48423.msg348738.html#msg348738). Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required. | |
| 126 | + | ||
| 127 | + | - [Simple webserver](https://forum.lazarus.freepascal.org/index.php/topic,51189.msg375491.html#msg375491). Multi-threaded, cross-platform. No third party components required. | |
| 128 | + | ||
| 129 | + | - [File download](https://forum.lazarus.freepascal.org/index.php/topic,52773.msg389901.html#msg389901) - How to resume a file download. | |
| 130 | + | ||
| 131 | + | - [Obtain Redirected URL](https://forum.lazarus.freepascal.org/index.php/topic,55510.msg413068.html#msg413068) - How to obtain the redirected URL using TFPHTTPClient. | |
| 132 | + | ||
| 133 | + | - [Upload file](https://forum.lazarus.freepascal.org/index.php/topic,44795.msg315238.html#msg315238) - How to send a file to a web server using TFPHTTPClient. | |
| 134 | + | ||
| 135 | + | - [CAPTCHA implementation](https://forum.lazarus.freepascal.org/index.php/topic,56335.0.html) - How to implement a CAPTCHA. | |
| 136 | + | ||
| 137 | + | - [Retrieve https web page](https://forum.lazarus.freepascal.org/index.php/topic,48423.msg348738.html#msg348738). Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required. | |
| 138 | + | ||
| 139 | + | ## Retrieving system information | |
| 140 | + | ||
| 141 | + | - [System Information](https://forum.lazarus.freepascal.org/index.php/topic,58852.msg438604.html#msg438604) - Cross-platform unit to retrieve system information (CPU, memory, swap, operating system version etc). | |
| 142 | + | ||
| 143 | + | ## User Interface | |
| 144 | + | ||
| 145 | + | - Make your UI look interesting by adding some [simple transition effects](https://forum.lazarus.freepascal.org/index.php/topic,37943.msg256549.html#msg256549). | |
| 146 | + | ||
| 147 | + | - Searchable StringGrid. Requirement: DBFLaz. Load data from a dbf, show it on a TStringGrid, search and highlight the cells. See [here](https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249361.html#msg249361) and [here](https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249208.html#msg249208). | |
| 148 | + | ||
| 149 | + | - [Popup with ListBox](https://forum.lazarus.freepascal.org/index.php/topic,37369.msg250939.html#msg250939). A custom popup form with a list box. | |
| 150 | + | ||
| 151 | + | - [Frameless popup](https://forum.lazarus.freepascal.org/index.php/topic,48291.msg348084.html#msg348084). An alternative to ShowMessage. | |
| 152 | + | ||
| 153 | + | - [Drag a Button to a Panel](https://forum.lazarus.freepascal.org/index.php/topic,45346.msg320626.html#msg320626). How to do drag and drop. | |
| 154 | + | ||
| 155 | + | - [Checkbox in a StringGrid](https://forum.lazarus.freepascal.org/index.php/topic,45080.msg317949.html#msg317949). TStringGrid can show a checkbox instead of text. | |
| 156 | + | ||
| 157 | + | - [Darken a Form](https://forum.lazarus.freepascal.org/index.php/topic,42107.msg293431.html#msg293431). Requirement: BGRAControls. How to darken a form. | |
| 158 | + | ||
| 159 | + | - [Darkening a Form](https://forum.lazarus.freepascal.org/index.php/topic,42107.msg293295.html#msg293295). Requirement: BGRAControls. How to darken the Main Form when a modal window is shown. | |
| 160 | + | ||
| 161 | + | - [Open a Form beside the current Form](https://forum.lazarus.freepascal.org/index.php/topic,42058.msg292943.html#msg292943). Programmatically open and close a form beside the current form. | |
| 162 | + | ||
| 163 | + | - [Scaling a Form](https://forum.lazarus.freepascal.org/index.php/topic,39477.msg271075.html#msg271075). How to scale a form by using TForm.ScaleBy. Unfortunately it does not work correctly on Linux. | |
| 164 | + | ||
| 165 | + | - [Vertical Menu](https://forum.lazarus.freepascal.org/index.php/topic,37537.msg252573.html#msg252573). How to make a vertical menu using TPanel and TScrollBox. | |
| 166 | + | ||
| 167 | + | - [Colorful Panels](https://forum.lazarus.freepascal.org/index.php/topic,37397.msg251208.html#msg251208). How to use TControl.Align. | |
| 168 | + | ||
| 169 | + | - [Button with animation](https://forum.lazarus.freepascal.org/index.php/topic,11656.msg251161.html#msg251161). How to show a TBitButton with animation images. | |
| 170 | + | ||
| 171 | + | - [Small icon in a TEdit](https://forum.lazarus.freepascal.org/index.php/topic,37346.msg250750.html#msg250750). How to put an icon in a TEdit. | |
| 172 | + | ||
| 173 | + | - [StringGrid Cell Validation](https://forum.lazarus.freepascal.org/index.php/topic,37286.msg250687.html#msg250687). Automatically set focus on the cell if it contains incorrect input. | |
| 174 | + | ||
| 175 | + | - [ListBox Work as Tabs For StringGrid](https://forum.lazarus.freepascal.org/index.php/topic,47651.msg341708.html#msg341708). How to add items to a ListBox and StringGrid at runtime. | |
| 176 | + | ||
| 177 | + | - [Vertical Menu](https://forum.lazarus.freepascal.org/index.php/topic,37537.msg252612.html#msg252612). A TVerticalMenu component. | |
| 178 | + | ||
| 179 | + | - [Color Fade ProgressBar](https://forum.lazarus.freepascal.org/index.php/topic,42610.msg297603.html#msg297603). Requirement: BGRAControls. How to use TBGRAFlashProgressBar. | |
| 180 | + | ||
| 181 | + | - [Color Fade ProgressBar](https://forum.lazarus.freepascal.org/index.php/topic,42610.msg297651.html#msg297651). How to color fade a progress bar without using a third party component. | |
| 182 | + | ||
| 183 | + | - [Task bar icon progress bar](https://forum.lazarus.freepascal.org/index.php/topic,44860.0.html) - Windows only. | |
| 184 | + | ||
| 185 | + | - [Progress in Status Bar](https://forum.lazarus.freepascal.org/index.php/topic,56367.msg418862.html#msg418862) - Cross-platform. | |
| 186 | + | ||
| 187 | + | - [ShowMessage in Console Mode](https://forum.lazarus.freepascal.org/index.php/topic,37425.msg251457.html#msg251457). Requirement: LCL needed to be in the project’s required packages. How to use ShowMessage in a console mode program. | |
| 188 | + | ||
| 189 | + | - [Save & Restore StringGrid](https://forum.lazarus.freepascal.org/index.php/topic,48241.msg347340.html#msg347340). How to save/load a grid’s content. | |
| 190 | + | ||
| 191 | + | - [StringGrid With Autosum Column](https://forum.lazarus.freepascal.org/index.php/topic,45816.msg324502.html#msg324502). How to create a column that can auto calculate the row sum. | |
| 192 | + | ||
| 193 | + | - [Activate button with keypress](https://forum.lazarus.freepascal.org/index.php/topic,48955.msg353532.html#msg353532). How to activate a button with a keypress. | |
| 194 | + | ||
| 195 | + | - [Detect user's language](https://forum.lazarus.freepascal.org/index.php/topic,49156.msg355612.html#msg355612). How to detect the user's language (multi-platform method). | |
| 196 | + | ||
| 197 | + | - [Adding CHM Help](http://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.html#msg261731). A demo project to call a CHM help file from three buttons as context-sensitive help (press F1), or from a help menu. | |
| 198 | + | ||
| 199 | + | - [GUI program that allocates a console](https://forum.lazarus.freepascal.org/index.php/topic,44828.msg315571.html#msg315571) whenever it needs one and frees it when it no longer needs it (Windows only). | |
| 200 | + | ||
| 201 | + | - [CHM Help Demo](https://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.html#msg261731) for an application. | |
| 202 | + | ||
| 203 | + | - [Speedbutton demonstration](https://forum.lazarus.freepascal.org/index.php/topic,51116.msg374890.html#msg374890) of using four arrow speedbuttons for moving an object. Shows how to handle speedbutton glyph states. | |
| 204 | + | ||
| 205 | + | - [Runtime forms](https://forum.lazarus.freepascal.org/index.php/topic,52725.msg389274.html#msg389274) How to create a form at runtime. | |
| 206 | + | ||
| 207 | + | - [TAchart example](https://forum.lazarus.freepascal.org/index.php/topic,49251.msg356477.html#msg356477) displaying the time on the X axis. | |
| 208 | + | ||
| 209 | + | - [How to hide application window](https://forum.lazarus.freepascal.org/index.php/topic,16362.msg88566.html#msg88566) on startup. | |
| 210 | + | ||
| 211 | + | - [How to use a Global HotKey](https://forum.lazarus.freepascal.org/index.php/topic,16436.msg255366.html#msg255366) to show a form (Windows only). | |
| 212 | + | ||
| 213 | + | - How to [resume a download](https://forum.lazarus.freepascal.org/index.php/topic,52773.msg389901.html#msg389901). | |
| 214 | + | ||
| 215 | + | --- | |
| 216 | + | *From the Free Pascal wiki, page "Portal:HowTo Demos", as it stood on 2022-03-27 after a change by Trev, 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).* |
