Board.KolibriOS.org

Official KolibriOS board
It is currently Mon Jan 18, 2021 8:14 pm

All times are UTC+03:00




Post new topic  Reply to topic  [ 28 posts ]  Go to page 1 2 Next
Author Message
 Post subject: Delphi7 examples
PostPosted: Sat Feb 04, 2017 10:00 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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:
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:
Attachment:
OMF2D.7z [40.7 KiB]
Downloaded 300 times
Some examples and KolibriOS.lib:
Attachment:
KOSLib_Demo.7z [23.75 KiB]
Downloaded 302 times
It contains these 5 examples:
{1} Just a simple window.
Used functions: DrawWindow, GetScreenSize, WaitEvent, BeginDraw, EndDraw, GetKey, GetButton, ThreadTerminate.
Spoiler: Show
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: Show
Attachment:
2.PNG
2.PNG [ 2.92 KiB | Viewed 6968 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: Show
Attachment:
3.PNG
3.PNG [ 3.92 KiB | Viewed 6968 times ]
{4} Load example.asm into console window.
Used functions: LoadFile, LoadLibrary, GetProcAddress, ThreadTerminate.
Spoiler: Show
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.


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sat Feb 11, 2017 11:43 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
6.PNG
6.PNG [ 12 KiB | Viewed 6916 times ]
Source:
Attachment:
{6} DrawImage.7z [9.26 KiB]
Downloaded 247 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sun Feb 19, 2017 11:47 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
Just a simple example. Drawing in the window with SetPixel function.
Used functions: SetPixel, BeginDraw, DrawWindow, EndDraw, WaitEvent, GetKey, GetButton, GetScreenSize, ThreadTerminate.

Screenshot:
Spoiler: Show
Attachment:
7.PNG
7.PNG [ 2.66 KiB | Viewed 6849 times ]
Source:
Attachment:
{7} SetPixel.7z [814 Bytes]
Downloaded 230 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Mon May 15, 2017 2:12 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
Show info about the thread with given slot in the console window.
Used functions: LoadLibrary, GetProcAddress, GetThreadInfo, ThreadTerminate.

Screenshot:
Spoiler: Show
Attachment:
8.PNG
8.PNG [ 12.68 KiB | Viewed 6454 times ]


Source:
Attachment:
{8} GetThreadInfo.7z [1.15 KiB]
Downloaded 198 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sat May 27, 2017 3:44 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
9.PNG
9.PNG [ 2.79 KiB | Viewed 6376 times ]

Source:
Attachment:
{9} GetPixel.7z [865 Bytes]
Downloaded 204 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sun Jun 04, 2017 9:10 am 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
Reading the contents of a folder in the console window.
Used functions: ReadFolder, LoadLibrary, GetProcAddress, ThreadTerminate.

Screenshot:
Spoiler: Show
Attachment:
10.PNG
10.PNG [ 16.22 KiB | Viewed 6339 times ]

Source:
Attachment:
{10} ReadFolder.7z [959 Bytes]
Downloaded 214 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sun Jun 11, 2017 9:24 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
11.PNG
11.PNG [ 16.49 KiB | Viewed 6283 times ]

Source:
Attachment:
{11} DrawImageEx.7z [10.58 KiB]
Downloaded 214 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Mon Jun 19, 2017 10:12 am 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
12.PNG
12.PNG [ 2.7 KiB | Viewed 6232 times ]

Source:
Attachment:
{12} RunFile, MinimizeWindowByID, RestoreWindowByID.7z [1006 Bytes]
Downloaded 201 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Mon Jun 26, 2017 7:49 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
13.PNG
13.PNG [ 4.08 KiB | Viewed 6158 times ]

Source:
Attachment:
{13} LoadCursorIndirect, SetCursor.7z [1.76 KiB]
Downloaded 190 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Fri Jul 07, 2017 9:27 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
14.PNG
14.PNG [ 72.08 KiB | Viewed 6112 times ]

Source:
Attachment:
{14} GetScreenImage.7z [1.14 KiB]
Downloaded 193 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Thu Sep 14, 2017 6:07 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
SystemDate_SystemTime.PNG
SystemDate_SystemTime.PNG [ 7.6 KiB | Viewed 5891 times ]

Source:
Attachment:
{15} GetSystemDate, GetSystemTime.7z [928 Bytes]
Downloaded 185 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Sat Sep 23, 2017 11:18 am 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
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: Show
Attachment:
16.PNG
16.PNG [ 4.58 KiB | Viewed 5826 times ]

Source:
Attachment:
{16} CreateFolder, CreateFile, WriteFile.7z [1.36 KiB]
Downloaded 190 times


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Wed Sep 27, 2017 9:15 pm 
Offline

Joined: Tue Mar 08, 2016 11:00 pm
Posts: 439
Какого размера бинарники от Д7 получаются?


Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Wed Sep 27, 2017 9:24 pm 
Offline

Joined: Sun Oct 30, 2011 6:43 pm
Posts: 1498
Siemargl, для примера приложение CoffDump viewtopic.php?f=9&t=3577
Сжатый kpaсk-ом: 1,91 КБ (1964 байта)
Несжатый: 3,72 КБ (3812 байтов)

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


Last edited by 0CodErr on Wed Sep 27, 2017 9:41 pm, edited 2 times in total.

Top
   
 Post subject: Re: Delphi7 examples
PostPosted: Wed Sep 27, 2017 9:30 pm 
Offline

Joined: Tue Mar 08, 2016 11:00 pm
Posts: 439
лучше по всем примерам прилагать. не было инфы - пришлось на хабре не упоминать (


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 28 posts ]  Go to page 1 2 Next

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited