Difference between revisions of "Portal:HowTo Demos"

From Lazarus wiki
Jump to navigationJump to search
(New Portal for short demo programs from the Forums)
 
(→‎Networking: Relocate item from General)
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{Portal_HowTo_Demos(pg)}}
 
{{Portal_HowTo_Demos(pg)}}
 
{{Index-Portal}}
 
{{Index-Portal}}
 
+
__NOTOC__
 
{{Portal_Head2|00a0cb|<big>{{PAGENAME}}</big>|dfe2eb|000000}}
 
{{Portal_Head2|00a0cb|<big>{{PAGENAME}}</big>|dfe2eb|000000}}
 
{| width="100%" class = "wikitable"
 
{| width="100%" class = "wikitable"
 
| valign="top" |
 
| valign="top" |
 +
[[File:HowToLogo.png|right]]
 
This portal collects together in one place a significant number of short demonstration programs that have been posted on the [https://forum.lazarus.freepascal.org/ Free Pascal and Lazarus Forums]. Each of the demonstration programs generally provides a simple example of one particular development technique.
 
This portal collects together in one place a significant number of short demonstration programs that have been posted on the [https://forum.lazarus.freepascal.org/ Free Pascal and Lazarus Forums]. Each of the demonstration programs generally provides a simple example of one particular development technique.
  
Line 15: Line 16:
 
'''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]]
 
'''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]]
  
'''Topic Portals:''' [[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]]
+
'''Topic Portals:''' [[Portal:New Users|<font color=green>'''New Users'''</font>]] - [[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]]
  
  
Line 21: Line 22:
 
</div>
 
</div>
 
|}
 
|}
 +
 +
<div style="float:left; width:100%;”>
 +
 +
== Android ==
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44811.msg315311.html#msg315311 OpenGL ES2 Circle]. Requirement: LAMW. Drawing a circle using jCanvasES2.DrawLine instead of DrawCircle.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44708.msg314630.html#msg314630 OpenGL ES2 Rectangle]. Requirement: LAMW. Drawing a rectangle using jCanvasES2.DrawPolyFill instead of DrawRect.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44241.msg310991.html#msg310991 Simple polygon animation]. Requirement: LAMW. A simple animation using jCanvas.
 +
 +
== File handling ==
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43045.msg307111.html#msg307111 Binary file demo]. How to show, append and delete data from a binary file.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37766.msg254800.html#msg254800 Text file demo]. How to read and append data to a text file.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,39769.msg274036.html#msg274036 Text File Demo #2]. How to read and append data to a text file.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42293.msg295057.html#msg295057 Save component values to a file]. Save text data easily using TStringList.SaveToFile.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42144.msg293579.html#msg293579 Load and show image from Resource Stream]. How to add an image to a project resource and load it.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37442.msg251587.html#msg251587 Load a picture and show it]. How to use OpenPictureDialog and LoadFromFile.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,49069.0.html Detect kind of file using DragAndDrop]. How to detect the type of file using drag and drop.
 +
 +
== General ==
 +
 +
* Drawing, moving, making connection between shapes. Shows TShape can be used for [https://forum.lazarus.freepascal.org/index.php/topic,41036.msg284131.html#msg284131 simple diagram drawing].
 +
 +
* Generating a huge text file. Demonstrates a technique for reducing program responsiveness to [https://forum.lazarus.freepascal.org/index.php/topic,43806.msg307101.html#msg307101 improve performance].
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38844.msg265130.html#msg265130 Drag and drop shape]. Drag and drop without using the built-in drag and drop feature.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42124.msg293401.html#msg293401 Minimize to TaskBar or Tray]. A workaround to minimize to tray, not the best solution but works.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42106.msg293281.html#msg293281 TMyCircle Component]. How to write your own component, the OOP way.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,41089.msg284614.html#msg284614 Moving an Object by pressing a key]. How to detect left/right shift key pressing.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,39790.msg274096.html#msg274096 Pausing and Continuing an animation]. How to pause and continue the animation.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,36306.msg241818.html#msg241818 Control an Object's direction using the keyboard]. How to detect user keyboard input.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37887.msg256019.html#msg256019 Convert Unicode to TBytes]. How to use WideBytesOf and WideString functions.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43489.msg304434.html#msg304434 Communicate between two programs]. This demo showing how to use simpleipc.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,52780.msg389815.html#msg389815 Timer demo] - How to use a TTimer control.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,58207.msg433568.html#msg433568 Delete tags] - How to delete HTML tags from text.
 +
 +
== Graphics ==
 +
 +
* Get pixel color of an image. It may sound easy but actually it is [https://forum.lazarus.freepascal.org/index.php/topic,37242.msg252828.html#msg252828 not so easy].
 +
 +
* A very simple single player [https://forum.lazarus.freepascal.org/index.php/topic,42439.msg297949.html#msg297949 Pong game].
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43999.msg309134.html#msg309134 Game Map Editor]. A very basic load and edit map for game.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43823.msg307918.html#msg307918 Fading images using BGRABitmap]. Requirement: BGRABitmap. Build your own slideshow and learn doing proportional scaling using aspect ratio of the picture.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43424.msg303879.html#msg303879 Center, resize image on the screen]. Resize an image at the center position of the image.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,41135.msg284936.html#msg284936 Simple animation]. A very basic animation using a TTimer.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38136.msg263143.html#msg263143 Moving circles]. How to fix an unwanted flickering effect.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37251.msg249962.html#msg249962 Change background color of an image.] A not so accurate colorshift on an image.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,35850.msg238019.html#msg238019 OpenGL 2D Text Using Textures]. Requirement: LazOpenGLContext. How to write text in OpenGL using textures loaded from an image file.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,46775.msg333936.html#msg333936 TCanvas Text]. How to draw superscript and subscript text using TCanvas.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38511.msg262706.html#msg262706 Sticky Balls]. Not so accurate inverse kinematics demo.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,41265.msg286208.html#msg286208 GradientFill Rectangle]. How to use GradientFill.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,41135.msg284928.html#msg284928 Rock, Paper, Scissors]. A simple game. Note for Unix/like operating systems: change the path delimiter to make the code work.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,45729.msg323878.html#msg323878 Bullet and asteroid collision detection]. How to do collision detection between a bullet and a polygonal object.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37425.msg259245.html#msg259245 Draw Circles Using CSMFL]. Requirement: SFML/CSFML headers binding and CSFML libraries. How to use CSFML in FPC.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37242.msg253349.html#msg253349 Get pixel color of an image]. How to load an image, show its information and the pixel color under the mouse pointer.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43376.msg303582.html#msg303582 Move a shape with a mouse]. Move rectangles using a mouse.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,43474.msg304454.html#msg304454 Selection Demo]. A movable and resizeable selection.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246309.html#msg246309 Sprite picking and moving]. Hit Testing - a must learn topic for every graphics programmer.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38511.msg262692.html#msg262692 Dancing Balls]. Balls that connect to each other.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,33138.msg214178.html#msg214178 Screenshot capture]. How to screenshot capture and crop.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,49314.msg357420.html#msg357420 Remove image shadow]. How to remove an image shadow and crop the image.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,49583.msg359879.html#msg359879 Display image in console program]. How to display an image in a console program (Windows API method).
 +
 +
* How to use [https://forum.lazarus.freepascal.org/index.php/topic,49855.0.html bitmap.scanline].
 +
 +
* How to do [https://forum.lazarus.freepascal.org/index.php/topic,42306.msg366256.html#msg366256 offscreen rendering in Metal framework] (macOS only).
 +
 +
* How to [https://forum.lazarus.freepascal.org/index.php/topic,52886.msg390735.html#msg390735 load a TImagelist at run time] Multiplatform.
 +
 +
== Networking ==
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38866.msg266673.html#msg266673 Game Client and Server]. The basics for building a client and server program.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,47015.msg336047.html#msg336047 FTP Connect]. Requirement: Synapse (can be installed using OPM). How to connect to a FTP server.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,35980.msg239199.html#msg239199 HTML to Text]. Requirement: fasthtmlparser. Extract data from a web page.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48677.msg350793.html#msg350793 Synapse TCP/IP client and server]. Requirement: Synapse.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48423.msg348738.html#msg348738 Retrieve https web page]. Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,51189.msg375491.html#msg375491 Simple webserver]. Multi-threaded, cross-platform. No third party components required.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,52773.msg389901.html#msg389901 File download] - How to resume a file download.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,55510.msg413068.html#msg413068 Obtain Redirected URL] - How to obtain the redirected URL using TFPHTTPClient.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44795.msg315238.html#msg315238 Upload file] - How to send a file to a web server using TFPHTTPClient.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,56335.0.html CAPTCHA implementation] - How to implement a CAPTCHA.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48423.msg348738.html#msg348738 Retrieve https web page]. Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required.
 +
 +
== Retrieving system information ==
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,58852.msg438604.html#msg438604 System Information] - Cross-platform unit to retrieve system information (CPU, memory, swap, operating system version etc).
 +
 +
== User Interface ==
 +
 +
* Make your UI look interesting by adding some [https://forum.lazarus.freepascal.org/index.php/topic,37943.msg256549.html#msg256549 simple transition effects].
 +
 +
* Searchable StringGrid. Requirement: DBFLaz. Load data from a dbf, show it on a TStringGrid, search and highlight the cells. See [https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249361.html#msg249361 here] and [https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249208.html#msg249208 here].
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37369.msg250939.html#msg250939 Popup with ListBox]. A custom popup form with a list box.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48291.msg348084.html#msg348084 Frameless popup]. An alternative to ShowMessage.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,45346.msg320626.html#msg320626 Drag a Button to a Panel]. How to do drag and drop.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,45080.msg317949.html#msg317949 Checkbox in a StringGrid]. TStringGrid can show a checkbox instead of text.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42107.msg293431.html#msg293431 Darken a Form]. Requirement: BGRAControls. How to darken a form.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42107.msg293295.html#msg293295 Darkening a Form]. Requirement: BGRAControls. How to darken the Main Form when a modal window is shown.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42058.msg292943.html#msg292943 Open a Form beside the current Form]. Programmatically open and close a form beside the current form.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,39477.msg271075.html#msg271075 Scaling a Form]. How to scale a form by using TForm.ScaleBy. Unfortunately it does not work correctly on Linux.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37537.msg252573.html#msg252573 Vertical Menu]. How to make a vertical menu using TPanel and TScrollBox.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37397.msg251208.html#msg251208 Colorful Panels]. How to use TControl.Align.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,11656.msg251161.html#msg251161 Button with animation]. How to show a TBitButton with animation images.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37346.msg250750.html#msg250750 Small icon in a TEdit]. How to put an icon in a TEdit.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37286.msg250687.html#msg250687 StringGrid Cell Validation]. Automatically set focus on the cell if it contains incorrect input.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,47651.msg341708.html#msg341708 ListBox Work as Tabs For StringGrid]. How to add items to a ListBox and StringGrid at runtime.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37537.msg252612.html#msg252612 Vertical Menu]. A TVerticalMenu component.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42610.msg297603.html#msg297603 Color Fade ProgressBar]. Requirement: BGRAControls. How to use TBGRAFlashProgressBar.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,42610.msg297651.html#msg297651 Color Fade ProgressBar]. How to color fade a progress bar without using a third party component.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44860.0.html Task bar icon progress bar] - Windows only.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,56367.msg418862.html#msg418862 Progress in Status Bar] - Cross-platform.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,37425.msg251457.html#msg251457 ShowMessage in Console Mode]. Requirement: LCL needed to be in the project’s required packages. How to use ShowMessage in a console mode program.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48241.msg347340.html#msg347340 Save & Restore StringGrid]. How to save/load a grid’s content.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,45816.msg324502.html#msg324502 StringGrid With Autosum Column]. How to create a column that can auto calculate the row sum.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,48955.msg353532.html#msg353532 Activate button with keypress]. How to activate a button with a keypress.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,49156.msg355612.html#msg355612 Detect user's language]. How to detect the user's language (multi-platform method).
 +
 +
* [http://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.html#msg261731 Adding CHM Help]. A demo project to call a CHM help file from three buttons as context-sensitive help (press F1), or from a help menu.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,44828.msg315571.html#msg315571 GUI program that allocates a console] whenever it needs one and frees it when it no longer needs it (Windows only).
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,38487.msg261731.html#msg261731 CHM Help Demo] for an application.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,51116.msg374890.html#msg374890 Speedbutton demonstration] of using four arrow speedbuttons for moving an object. Shows how to handle speedbutton glyph states.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,52725.msg389274.html#msg389274 Runtime forms] How to create a form at runtime.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,49251.msg356477.html#msg356477 TAchart example] displaying the time on the X axis.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,16362.msg88566.html#msg88566 How to hide application window] on startup.
 +
 +
* [https://forum.lazarus.freepascal.org/index.php/topic,16436.msg255366.html#msg255366 How to use a Global HotKey] to show a form (Windows only).
 +
 +
* How to [https://forum.lazarus.freepascal.org/index.php/topic,52773.msg389901.html#msg389901 resume a download].
 +
<br/>
 +
</div>

Latest revision as of 12:07, 27 March 2022

English (en)

< Lookup < Portals < Portal:HowTo Demos
Portal:HowTo Demos
HowToLogo.png

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. Each of the demonstration programs generally provides a simple example of one particular development technique.

The Portal was the brainchild of Handoko who also provided the initial list of demonstration programs from the Forums.

Android

  • OpenGL ES2 Circle. Requirement: LAMW. Drawing a circle using jCanvasES2.DrawLine instead of DrawCircle.
  • OpenGL ES2 Rectangle. Requirement: LAMW. Drawing a rectangle using jCanvasES2.DrawPolyFill instead of DrawRect.

File handling

General

  • Generating a huge text file. Demonstrates a technique for reducing program responsiveness to improve performance.

Graphics

  • Get pixel color of an image. It may sound easy but actually it is not so easy.
  • Fading images using BGRABitmap. Requirement: BGRABitmap. Build your own slideshow and learn doing proportional scaling using aspect ratio of the picture.
  • TCanvas Text. How to draw superscript and subscript text using TCanvas.
  • Rock, Paper, Scissors. A simple game. Note for Unix/like operating systems: change the path delimiter to make the code work.

Networking

  • FTP Connect. Requirement: Synapse (can be installed using OPM). How to connect to a FTP server.
  • HTML to Text. Requirement: fasthtmlparser. Extract data from a web page.
  • Retrieve https web page. Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required.
  • Simple webserver. Multi-threaded, cross-platform. No third party components required.
  • Upload file - How to send a file to a web server using TFPHTTPClient.
  • Retrieve https web page. Cross-platform. No openssl DLLs/libraries need to be deployed. No third party components required.

Retrieving system information

  • System Information - Cross-platform unit to retrieve system information (CPU, memory, swap, operating system version etc).

User Interface

  • Searchable StringGrid. Requirement: DBFLaz. Load data from a dbf, show it on a TStringGrid, search and highlight the cells. See here and here.
  • Darkening a Form. Requirement: BGRAControls. How to darken the Main Form when a modal window is shown.
  • Scaling a Form. How to scale a form by using TForm.ScaleBy. Unfortunately it does not work correctly on Linux.
  • Vertical Menu. How to make a vertical menu using TPanel and TScrollBox.
  • ShowMessage in Console Mode. Requirement: LCL needed to be in the project’s required packages. How to use ShowMessage in a console mode program.
  • Adding CHM Help. A demo project to call a CHM help file from three buttons as context-sensitive help (press F1), or from a help menu.
  • Speedbutton demonstration of using four arrow speedbuttons for moving an object. Shows how to handle speedbutton glyph states.