Page 1 of 2

Delphi7 examples

Posted: Sat Feb 04, 2017 10:00 pm
by 0CodErr
Here are some Delphi7 examples of using wrappers to call system functions from KolibriOS.lib.
Also, it is possible to use FreePascal compiler i hope. Newer version is more compatible with Delphi.
The main goal is more convenient programming with KolibriOS API.

Tools needed:

Code: Select all

dcc32   — Delphi compiler
omf2d   — utility for converting from Borland omf to Intel omf
link    — Microsoft linker
ld      — GNU linker
objcopy — utility to convert object files
Here omf2d utility just in case:
OMF2D.7z (40.7 KiB)
Downloaded 604 times
Some examples and KolibriOS.lib:
KOSLib_Demo.7z (23.75 KiB)
Downloaded 613 times
It contains these 5 examples:
{1} Just a simple window.
Used functions: DrawWindow, GetScreenSize, WaitEvent, BeginDraw, EndDraw, GetKey, GetButton, ThreadTerminate.
Spoiler:Image
{2} When you click on the buttons the window caption changes.
Used functions: DrawButton, GetButton, SetWindowCaption, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetKey, ThreadTerminate.
Spoiler:
2.PNG
2.PNG (2.92 KiB)
Viewed 17478 times
{3} Press on the keyboard and text will be drawn in window.
Used functions: GetKey, DrawText, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetButton, ThreadTerminate.
Spoiler:
3.PNG
3.PNG (3.92 KiB)
Viewed 17478 times
{4} Load example.asm into console window.
Used functions: LoadFile, LoadLibrary, GetProcAddress, ThreadTerminate.
Spoiler:Image
{5} Show CurrentDirectory, AppPath and CmdLine in console window.
Used functions: GetCurrentDirectory, LoadLibrary, GetProcAddress, ThreadTerminate.

In the case of new examples they will be added to this topic below.

Re: Delphi7 examples

Posted: Sat Feb 11, 2017 11:43 pm
by 0CodErr
DrawImage example.

Load 24 bits per pixel targa file and draw it into the window.
This image file is uncompressed and was saved with top to bottom pixel order.
Used functions: DrawImage, LoadFile, HeapCreate, SetCurrentDirectory, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetKey, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
6.PNG
6.PNG (12 KiB)
Viewed 17426 times
Source:
{6} DrawImage.7z (9.26 KiB)
Downloaded 539 times

Re: Delphi7 examples

Posted: Sun Feb 19, 2017 11:47 pm
by 0CodErr
Just a simple example. Drawing in the window with SetPixel function.
Used functions: SetPixel, BeginDraw, DrawWindow, EndDraw, WaitEvent, GetKey, GetButton, GetScreenSize, ThreadTerminate.

Screenshot:
Spoiler:
7.PNG
7.PNG (2.66 KiB)
Viewed 17359 times
Source:
{7} SetPixel.7z (814 Bytes)
Downloaded 520 times

Re: Delphi7 examples

Posted: Mon May 15, 2017 2:12 pm
by 0CodErr
Show info about the thread with given slot in the console window.
Used functions: LoadLibrary, GetProcAddress, GetThreadInfo, ThreadTerminate.

Screenshot:
Spoiler:
8.PNG
8.PNG (12.68 KiB)
Viewed 16964 times
Source:
Downloaded 485 times

Re: Delphi7 examples

Posted: Sat May 27, 2017 3:44 pm
by 0CodErr
Draw the rectangle with a color of the pixel under the mouse.
Used functions: GetPixel, GetMousePos, DrawRectangle, GetScreenSize, SetEventMask, WaitEvent, BeginDraw, DrawWindow, DrawLine, EndDraw, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
9.PNG
9.PNG (2.79 KiB)
Viewed 16886 times
Source:
{9} GetPixel.7z (865 Bytes)
Downloaded 480 times

Re: Delphi7 examples

Posted: Sun Jun 04, 2017 9:10 am
by 0CodErr
Reading the contents of a folder in the console window.
Used functions: ReadFolder, LoadLibrary, GetProcAddress, ThreadTerminate.

Screenshot:
Spoiler:
10.PNG
10.PNG (16.22 KiB)
Viewed 16849 times
Source:
{10} ReadFolder.7z (959 Bytes)
Downloaded 500 times

Re: Delphi7 examples

Posted: Sun Jun 11, 2017 9:24 pm
by 0CodErr
Reading image files with different bits per pixel values(4, 1, 24) and draw images in window.
Used functions: DrawImageEx, ReadFile, HeapCreate, HeapAllocate, SetCurrentDirectory, GetFileAttributes, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetKey, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
11.PNG
11.PNG (16.49 KiB)
Viewed 16793 times
Source:
Downloaded 499 times

Re: Delphi7 examples

Posted: Mon Jun 19, 2017 10:12 am
by 0CodErr
Launch application "TextEditor" with parameters for open "example.asm" in it. Also do minimize and restore "TextEditor" window.
Used functions: RunFile, MinimizeWindowByID, RestoreWindowByID, DrawText, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, DrawButton, EndDraw, GetKey, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
12.PNG
12.PNG (2.7 KiB)
Viewed 16742 times
Source:
Downloaded 480 times

Re: Delphi7 examples

Posted: Mon Jun 26, 2017 7:49 pm
by 0CodErr
Load 32 bit bitmaps(top to bottom pixel order) and use it as mouse cursors. Also draw these pictures on window. For this purpose Blit function is used.
Used functions: LoadCursorIndirect, SetCursor, Blit, DrawText, DrawButton, LoadFile, HeapCreate, SetCurrentDirectory, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetKey, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
13.PNG
13.PNG (4.08 KiB)
Viewed 16668 times
Source:
Downloaded 423 times

Re: Delphi7 examples

Posted: Fri Jul 07, 2017 9:27 pm
by 0CodErr
Get image of screen and draw it in the application window.
Used functions: GetScreenImage, DrawImage, GetSkinHeight, HeapCreate, GetScreenSize, HeapAllocate, WaitEvent, BeginDraw, DrawWindow, EndDraw, GetKey, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
14.PNG
14.PNG (72.08 KiB)
Viewed 16622 times
Source:
Downloaded 439 times

Re: Delphi7 examples

Posted: Thu Sep 14, 2017 6:07 pm
by 0CodErr
This example writes the system date and system time to the console window and updates it periodically.
Used functions: LoadLibrary, GetProcAddress, GetSystemDate, GetSystemTime, Sleep, ThreadTerminate.

Screenshot:
Spoiler:
SystemDate_SystemTime.PNG
SystemDate_SystemTime.PNG (7.6 KiB)
Viewed 16401 times
Source:
Downloaded 436 times

Re: Delphi7 examples

Posted: Sat Sep 23, 2017 11:18 am
by 0CodErr
In this example a folder 'test_folder' is created on '/rd/1'.
Then in the folder you created a file is created 'test_file.txt'.
In the created file data is written 'Test100500'.
After that you can open 'test_file.txt' and find in it written data.
Used functions: CreateFolder, CreateFile, WriteFile, SetEventMask, GetScreenSize, WaitEvent, BeginDraw, DrawWindow, DrawButton, DrawText, EndDraw, GetButton, ThreadTerminate.

Screenshot:
Spoiler:
16.PNG
16.PNG (4.58 KiB)
Viewed 16336 times
Source:
Downloaded 434 times

Re: Delphi7 examples

Posted: Wed Sep 27, 2017 9:15 pm
by Siemargl
Какого размера бинарники от Д7 получаются?

Re: Delphi7 examples

Posted: Wed Sep 27, 2017 9:24 pm
by 0CodErr
Siemargl, для примера приложение CoffDump http://board.kolibrios.org/viewtopic.php?f=9&t=3577
Сжатый kpaсk-ом: 1,91 КБ (1964 байта)
Несжатый: 3,72 КБ (3812 байтов)

Или самый первый пример {1} DrawWindow
Сжатый kpaсk-ом: 342 байта
Несжатый: 496 байтов

Re: Delphi7 examples

Posted: Wed Sep 27, 2017 9:30 pm
by Siemargl
лучше по всем примерам прилагать. не было инфы - пришлось на хабре не упоминать (