Project tree simplified

This commit is contained in:
2020-05-23 16:55:40 +03:00
parent 238356dff9
commit c012f5134c
59 changed files with 74 additions and 74 deletions

View File

@@ -0,0 +1,58 @@
program ColorButtons;
uses
KolibriOS;
const
COLOR_BLUE = $000000FF;
COLOR_RED = $00FF0000;
COLOR_GREEN = $0000FF00;
COLOR_BLACK = $00000000;
BLACK_BUTTON = 1000;
BLUE_BUTTON = 2000;
GREEN_BUTTON = 3000;
RED_BUTTON = 4000;
var
Left, Right, Top, Bottom: Integer;
begin
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Color Buttons', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
DrawButton(10, 20, 50, 30, COLOR_RED, 0, RED_BUTTON);
DrawButton(70, 20, 50, 30, COLOR_GREEN, 0, GREEN_BUTTON);
DrawButton(10, 60, 50, 30, COLOR_BLUE, 0, BLUE_BUTTON);
DrawButton(70, 60, 50, 30, COLOR_BLACK, 0, BLACK_BUTTON);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
case GetButton.ID of
BLUE_BUTTON:
SetWindowCaption('Blue');
GREEN_BUTTON:
SetWindowCaption('Green');
RED_BUTTON:
SetWindowCaption('Red');
BLACK_BUTTON:
SetWindowCaption('Black');
1:
TerminateThread;
end;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0ColorButtons"

View File

@@ -0,0 +1,54 @@
program DateTime;
uses
KolibriOS;
var
hConsole: Pointer;
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
Printf: function(const Format: PKolibriChar): Integer; cdecl varargs;
GetConsoleCursorPos: procedure(X, Y: PInteger); stdcall;
SetConsoleCursorPos: procedure(X, Y: Integer); stdcall;
kbhit: function: Boolean;
SetConsoleCursorHeight: function(Height: Integer): Integer; stdcall;
// ConsoleCls: procedure;
SystemDate: TSystemDate;
SystemTime: TSystemTime;
X, Y: Integer;
begin
hConsole := LoadLibrary('/sys/lib/console.obj');
ConsoleInit := GetProcAddress(hConsole, 'con_init');
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
GetConsoleCursorPos := GetProcAddress(hConsole, 'con_get_cursor_pos');
SetConsoleCursorPos := GetProcAddress(hConsole, 'con_set_cursor_pos');
SetConsoleCursorHeight := GetProcAddress(hConsole, 'con_set_cursor_height');
Printf := GetProcAddress(hConsole, 'con_printf');
KBHit := GetProcAddress(hConsole, 'con_kbhit');
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Date/Time');
SetConsoleCursorHeight(0);
SetConsoleCursorPos(27, 11);
Printf(
'SystemDate and SystemTime'#10 +
' '
);
GetConsoleCursorPos(@X, @Y);
repeat
SystemDate := GetSystemDate;
SystemTime := GetSystemTime;
with SystemDate, SystemTime do
begin
Printf('%02x.%02x.%02x', Day, Month, Year);
Printf(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
end;
SetConsoleCursorPos(X, Y);
Sleep(50);
until KBHit;
ConsoleExit(1);
TerminateThread;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0DateTime"

View File

@@ -0,0 +1,95 @@
program DrawImageApp;
uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
type
THeader = packed record
IDLength: Byte;
ColorMapType: Byte;
ImageType: Byte;
CMapStart: Word;
CMapLength: Word;
CMapDepth: Byte;
XOffset: Word;
YOffset: Word;
Width: Word;
Height: Word;
PixelDepth: Byte;
ImageDescriptor: Byte;
end;
PTargaFile = ^TTargaFile;
TTargaFile = packed record
Header: THeader;
end;
procedure ExtractFileDirectory(Source, Dest: PKolibriChar); stdcall;
asm
PUSH ESI
PUSH EDI
XOR EAX, EAX
MOV EDI, Source
MOV ESI, EDI
MOV ECX, $FFFFFFFF
REPNE SCASB
MOV AL, '/'
STD
REPNE SCASB
CLD
SUB EDI, ESI
MOV ECX, EDI
INC ECX
MOV EDI, Dest
REP MOVSB
MOV byte [EDI], 0
POP EDI
POP ESI
end;
var
Left, Right, Top, Bottom: Integer;
TargaFile: PTargaFile;
Image: Pointer;
FileSize: LongWord;
begin
HeapCreate;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
TargaFile := LoadFile('Lena.tga', FileSize);
with TargaFile^ do
Image := Pointer(PKolibriChar(TargaFile) + SizeOf(Header) + Header.IDLength);
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Draw Image', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
with TargaFile.Header do
DrawImage(Image^, 30, 20, Width, Height);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

BIN
Examples/DrawImage/Lena.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@@ -0,0 +1,3 @@
@echo off
call "%~dp0..\..\Lib\build.bat" "%~dp0DrawImage"
copy "%~dp0*.tga" "%~dp0..\..\Bin" >nul

View File

@@ -0,0 +1,153 @@
program DrawImageExApp;
uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
Picture1 = 'Flower(4bpp).bmp';
Picture2 = 'Mario(1bpp).bmp';
Picture3 = 'House(24bpp).bmp';
type
TBitmapFileHeader = packed record
bfType: Word;
bfSize: LongWord;
bfReserved1: Word;
bfReserved2: Word;
bfOffBits: LongWord;
end;
TBitmapInfoHeader = packed record
biSize: LongWord;
biWidth: LongInt;
biHeight: LongInt;
biPlanes: Word;
biBitCount: Word;
biCompression: LongWord;
biSizeImage: LongWord;
biXPelsPerMeter: LongInt;
biYPelsPerMeter: LongInt;
biClrUsed: LongWord;
biClrImportant: LongWord;
end;
TRGBQuad = packed record
Blue: Byte;
Green: Byte;
Red: Byte;
Reserved: Byte;
end;
PBitmapFile = ^TBitmapFile;
TBitmapFile = packed record
BitmapFileHeader: TBitmapFileHeader;
BitmapInfoHeader: TBitmapInfoHeader;
Palette: array[0..0] of TRGBQuad;
end;
procedure ExtractFileDirectory(Src, Dst: PKolibriChar); stdcall;
asm
PUSH ESI
PUSH EDI
XOR EAX, EAX
MOV EDI, Src
MOV ESI, EDI
MOV ECX, $FFFFFFFF
REPNE SCASB
MOV AL, '/'
STD
REPNE SCASB
CLD
SUB EDI, ESI
MOV ECX, EDI
INC ECX
MOV EDI, Dst
REP MOVSB
MOV BYTE [EDI], 0
POP EDI
POP ESI
end;
var
Left, Right, Top, Bottom: Integer;
BitmapFile1, BitmapFile2, BitmapFile3: PBitmapFile;
Image1, Image2, Image3: Pointer;
Padding1, Padding2, Padding3: LongWord;
BytesRead: LongWord;
FileAttributes: TFileAttributes;
begin
HeapCreate;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
GetFileAttributes(Picture1, FileAttributes);
BitmapFile1 := HeapAllocate(FileAttributes.SizeLo);
ReadFile(Picture1, BitmapFile1^, FileAttributes.SizeLo, 0, 0, BytesRead);
with BitmapFile1^, BitmapFileHeader, BitmapInfoHeader do
begin
Padding1 := (32 - biWidth * biBitCount mod 32) and not 32 div 6;
Image1 := Pointer(LongWord(BitmapFile1) + bfOffBits);
end;
GetFileAttributes(Picture2, FileAttributes);
BitmapFile2 := HeapAllocate(FileAttributes.SizeLo);
ReadFile(Picture2, BitmapFile2^, FileAttributes.SizeLo, 0, 0, BytesRead);
with BitmapFile2^, BitmapFileHeader, BitmapInfoHeader do
begin
Padding2 := (32 - biWidth * biBitCount mod 32) and not 32 div 6;
Image2 := Pointer(LongWord(BitmapFile2) + bfOffBits);
end;
GetFileAttributes(Picture3, FileAttributes);
BitmapFile3 := HeapAllocate(FileAttributes.SizeLo);
ReadFile(Picture3, BitmapFile3^, FileAttributes.SizeLo, 0, 0, BytesRead);
with BitmapFile3^, BitmapFileHeader, BitmapInfoHeader do
begin
Padding3 := (32 - biWidth * biBitCount mod 32) and not 32 div 6;
Image3 := Pointer(LongWord(BitmapFile3) + bfOffBits);
end;
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Draw Image Extended', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
(* these image files was saved with 'flip row order' parameter *)
(* therefore they have negative biHeight field *)
(* also it is possible to use Nil instead of @Palette if you sure palette is absent *)
with BitmapFile1^, BitmapFileHeader, BitmapInfoHeader do
DrawImageEx(Image1^, 20, 35, biWidth, -biHeight, biBitCount, @Palette, Padding1);
with BitmapFile2^, BitmapFileHeader, BitmapInfoHeader do
DrawImageEx(Image2^, 120, 35, biWidth, -biHeight, biBitCount, @Palette, Padding2);
with BitmapFile3^, BitmapFileHeader, BitmapInfoHeader do
DrawImageEx(Image3^, 220, 45, biWidth, -biHeight, biBitCount, @Palette, Padding3);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,3 @@
@echo off
call "%~dp0..\..\Lib\build.bat" "%~dp0DrawImageEx"
copy "%~dp0*.bmp" "%~dp0..\..\Bin" >nul

View File

@@ -0,0 +1,48 @@
program DrawTextApp;
uses
KolibriOS;
var
Left, Right, Top, Bottom, CurX, CurY: Integer;
Key: TKeyboardInput;
begin
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
CurX := 0;
CurY := 0;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
CurX := 0;
CurY := 0;
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Get Key', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
EndDraw;
end;
KEY_EVENT:
begin
Key := GetKey;
DrawText(CurX, CurY, @Key.Code, $00000000, $00FFFFFF, 0, 1);
Inc(CurX, 6);
if CurX > 100 then
begin
Inc(CurY, 10);
CurX := 0;
end;
end;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0DrawText"

63
Examples/Examples.bpg Normal file
View File

@@ -0,0 +1,63 @@
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = ColorButtons.exe DateTime.exe DrawImage.exe DrawImageEx.exe DrawText.exe GetCurrentDirectory.exe GetPixel.exe \
GetPointOwner.exe Hello.exe LoadFile.exe ReadFolder.exe Screenshot.exe SetCursor.exe SetPixel.exe SetWindowPos.exe
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
ColorButtons.exe: ColorButtons\ColorButtons.dpr
$(DCC)
DateTime.exe: DateTime\DateTime.dpr
$(DCC)
DrawImage.exe: DrawImage\DrawImage.dpr
$(DCC)
DrawImageEx.exe: DrawImageEx\DrawImageEx.dpr
$(DCC)
DrawText.exe: DrawText\DrawText.dpr
$(DCC)
GetCurrentDirectory.exe: GetCurrentDir\GetCurrentDir.dpr
$(DCC)
GetPixel.exe: GetPixel\GetPixel.dpr
$(DCC)
GetPointOwner.exe: GetPointOwner\GetPointOwner.dpr
$(DCC)
Hello.exe: Hello\Hello.dpr
$(DCC)
LoadFile.exe: LoadFile\LoadFile.dpr
$(DCC)
ReadFolder.exe: ReadFolder\ReadFolder.dpr
$(DCC)
Screenshot.exe: Screenshot\Screenshot.dpr
$(DCC)
SetCursor.exe: SetCursor\SetCursor.dpr
$(DCC)
SetPixel.exe: SetPixel\SetPixel.dpr
$(DCC)
SetWindowPos.exe: SetWindowPos\SetWindowPos.dpr
$(DCC)

View File

@@ -0,0 +1,36 @@
program GetCurrentDir;
uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
CmdLine = PPKolibriChar(28);
BUFFER_SIZE = 256;
var
hConsole: Pointer;
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
printf: function(const Format: PKolibriChar): Integer; CDecl varargs;
Buffer: array[0..BUFFER_SIZE - 1] of Char;
begin
hConsole := LoadLibrary('/sys/lib/console.obj');
ConsoleInit := GetProcAddress(hConsole, 'con_init');
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
printf := GetProcAddress(hConsole, 'con_printf');
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Test');
GetCurrentDirectory(Buffer, BUFFER_SIZE);
printf('AppPath is "%s"'#10, AppPath^);
printf('CmdLine is "%s"'#10, CmdLine^);
printf('CurrentDirectory is "%s"'#10, Buffer);
ConsoleExit(0);
TerminateThread;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0GetCurrentDir"

View File

@@ -0,0 +1,58 @@
program GetPixelApp;
uses
KolibriOS;
var
Window, Rectangle: TRect;
Point: TPoint;
begin
with Window, GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
with Rectangle do
begin
Left := 10;
Top := 10;
Right := Window.Right - 20;
Bottom := Window.Bottom - 40;
end;
SetEventMask(EM_REDRAW + EM_BUTTON + EM_MOUSE);
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
with Window do
DrawWindow(Left, Top, Right, Bottom, 'Get Pixel', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
with Rectangle do
begin
DrawLine(Left, Top, Left, Bottom, 0);
DrawLine(Right, Top, Right, Bottom, 0);
DrawLine(Left, Top, Right, Top, 0);
DrawLine(Left, Bottom, Right, Bottom, 0);
end;
EndDraw;
end;
MOUSE_EVENT:
begin
Point := GetMousePos;
with Rectangle, Point do
DrawRectangle(Left + 1, Top + 1, Right - Left - 1, Bottom - Top - 1, GetPixel(X, Y));
end;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0GetPixel"

View File

@@ -0,0 +1,64 @@
program GetPointOwnerApp;
uses
KolibriOS;
procedure UpdateInfo;
const
CHAR_WIDTH = 8;
CHAR_HEIGHT = 16;
var
MousePos: TPoint;
ID: LongWord;
ThreadInfo: TThreadInfo;
I: LongWord;
begin
MousePos := GetMousePos;
with MousePos do
ID := GetPointOwner(X, Y);
GetThreadInfo(ID, ThreadInfo);
(* get length of current name *)
I := 0;
while ThreadInfo.Name[I] <> #0 do
Inc(I);
(* clear unnecessary part of possible previous name by white rectangle *)
DrawRectangle(64 + I * CHAR_WIDTH, 16, (SizeOf(ThreadInfo.Name) - I) * CHAR_WIDTH, CHAR_HEIGHT, $00FFFFFF);
(* draw current name *)
DrawText(64, 16, ThreadInfo.Name, $00000000, $00FFFFFF, DT_CP866_8X16 + DT_FILL_OPAQUE + DT_ZSTRING, 0);
end;
const
NO_EVENT = 0;
var
Left, Top, Width, Height: Integer;
Screen: TSize;
begin
Screen := GetScreenSize;
Width := 189;
Height := 79;
Left := (Screen.Width - Width) div 2;
Top := (Screen.Height - Height) div 2;
SetEventMask(EM_BUTTON + EM_REDRAW);
while True do
case WaitEventByTime(5) of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Width, Height, 'Get Point Owner', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
DrawText(16, 16, 'Name:', $00000000, $00FFFFFF, DT_CP866_8X16 + DT_ZSTRING, 0);
EndDraw;
end;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
NO_EVENT:
UpdateInfo;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0GetPointOwner"

33
Examples/Hello/Hello.dpr Normal file
View File

@@ -0,0 +1,33 @@
program Hello;
uses
KolibriOS;
var
Left, Right, Top, Bottom: Integer;
begin
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Hello!', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

1
Examples/Hello/build.bat Normal file
View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0Hello"

View File

@@ -0,0 +1,28 @@
program LoadFileApp;
uses
KolibriOS;
var
hConsole: Pointer;
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
WriteN: procedure(Str: PKolibriChar; Count: LongWord); stdcall;
FileSize: LongWord;
Buffer: Pointer;
begin
hConsole := LoadLibrary('/sys/lib/console.obj');
ConsoleInit := GetProcAddress(hConsole, 'con_init');
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
WriteN := GetProcAddress(hConsole, 'con_write_string');
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Test');
Buffer := LoadFile('/sys/example.asm', FileSize);
WriteN(Buffer, FileSize);
ConsoleExit(0);
TerminateThread;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0LoadFile"

View File

@@ -0,0 +1,64 @@
program ReadFolderApp;
uses
KolibriOS;
var
hConsole: Pointer;
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
printf: function(const Format: PKolibriChar): Integer; cdecl varargs;
const
FolderPath = '/sys';
var
FolderInformation: TFolderInformation;
BlocksRead: LongWord;
Pos: LongWord;
begin
hConsole := LoadLibrary('/sys/lib/console.obj');
ConsoleInit := GetProcAddress(hConsole, 'con_init');
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
printf := GetProcAddress(hConsole, 'con_printf');
if ReadFolder(FolderPath, FolderInformation, 0, 0, 0, BlocksRead) = 0 then
with FolderInformation do
begin
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, {11 printf In Loop}11 * FileCount + {2 printf below}2 + 1, 'ReadFolder');
printf('Folder "%s" contains %u files and/or folders.'#10, FolderPath, FileCount);
printf(#10);
end
else
begin
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'ReadFolder');
printf('Folder "%s" can not be read.'#10, FolderPath);
end;
Pos := 0;
while ReadFolder(FolderPath, FolderInformation, 1, Pos, 0, BlocksRead) = 0 do
begin
with FolderInformation, FileInformation[0] do
begin
printf('FileName = %s'#10, FileName);
with FileAttributes do
begin
printf('SizeHi = %u'#10, SizeHi);
printf('SizeLo = %u'#10, SizeLo);
with modifyDate do printf('modifyDate = %02d.%02d.%02d'#10, Day, Month, Year);
with modifyTime do printf('modifyTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
with AccessDate do printf('AccessDate = %02d.%02d.%02d'#10, Day, Month, Year);
with AccessTime do printf('AccessTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
with CreationDate do printf('CreationDate = %02d.%02d.%02d'#10, Day, Month, Year);
with CreationTime do printf('CreationTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
printf('Attributes = 0x%08x'#10, Attributes);
end;
end;
printf(#10);
Inc(Pos);
end;
ConsoleExit(0);
TerminateThread;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0ReadFolder"

View File

@@ -0,0 +1,95 @@
program Screenshot;
uses
KolibriOS;
const
BORDER_SIZE = 5;
type
TRGBTriple = packed record
Blue: Byte;
Green: Byte;
Red: Byte;
end;
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array[0..0] of TRGBTriple;
var
Left, Right, Top, Bottom: Integer;
Screen: TSize;
Image, Preview: PRGBTripleArray;
function Red(A, B: LongWord): LongWord;
begin
Red := Image[(Screen.Width * B + A)].Red;
end;
function Green(A, B: LongWord): LongWord;
begin
Green := Image[(Screen.Width * B + A)].Green;
end;
function Blue(A, B: LongWord): LongWord;
begin
Blue := Image[(Screen.Width * B + A)].Blue;
end;
procedure ResizeImage;
var
A, B, I: LongWord;
begin
A := 0;
while A < Screen.Width do
begin
B := 0;
while B < Screen.Height do
begin
I := ((Screen.Width div 2) * B + A) div 2;
Preview[i].Red := (Red(A, B) + Red(A+ 1, B) + Red(A, B + 1) + Red(A + 1, B + 1)) div 4;
Preview[i].Green := (Green(A, B) + Green(A + 1, B) + Green(A, B + 1) + Green(A + 1, B + 1)) div 4;
Preview[i].Blue := (Blue(A, B) + Blue(A + 1, B) + Blue(A, B + 1) + Blue(A + 1, B + 1)) div 4;
Inc(B, 2);
end;
Inc(A, 2);
end;
end;
begin
HeapCreate;
Screen := GetScreenSize;
with Screen do
begin
Right := BORDER_SIZE * 2 + Width div 2 - 1;
Bottom := BORDER_SIZE + GetSkinHeight + Height div 2 - 1;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
Image := HeapAllocate(Width * Height * 3);
Preview := HeapAllocate(Width * Height * 3 div 2);
GetScreenImage(Image^, 0, 0, Width, Height);
ResizeImage;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Screenshot', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION + WS_FILL_TRANSPARENT, CAPTION_MOVABLE);
with Screen do
DrawImage(Preview^, 0, 0, Width div 2, Height div 2);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0Screenshot"

View File

@@ -0,0 +1,136 @@
program SetCursorApp;
uses
KolibriOS;
const
AppPath = PPKolibriChar(32);
ARROW_BUTTON = 2;
POINT_BUTTON = 3;
WAIT_BUTTON = 4;
type
TBitmapFileHeader = packed record
bfType: Word;
bfSize: LongWord;
bfReserved1: Word;
bfReserved2: Word;
bfOffBits: LongWord;
end;
TBitmapInfoHeader = packed record
biSize: LongWord;
biWidth: LongInt;
biHeight: LongInt;
biPlanes: Word;
biBitCount: Word;
biCompression: LongWord;
biSizeImage: LongWord;
biXPelsPerMeter: LongInt;
biYPelsPerMeter: LongInt;
biClrUsed: LongWord;
biClrImportant: LongWord;
end;
PBitmapFile = ^TBitmapFile;
TBitmapFile = packed record
BitmapFileHeader: TBitmapFileHeader;
BitmapInfoHeader: TBitmapInfoHeader;
end;
procedure ExtractFileDirectory(Src, Dst: PKolibriChar); stdcall;
asm
PUSH ESI
PUSH EDI
XOR EAX, EAX
MOV EDI, Src
MOV ESI, EDI
MOV ECX, $FFFFFFFF
REPNE SCASB
MOV AL, '/'
STD
REPNE SCASB
CLD
SUB EDI, ESI
MOV ECX, EDI
INC ECX
MOV EDI, Dst
REP MOVSB
MOV BYTE [EDI], 0
POP EDI
POP ESI
end;
var
Left, Right, Top, Bottom: Integer;
ArrowBitmapFile, PointBitmapFile, WaitBitmapFile: PBitmapFile;
ArrowBitmap, PointBitmap, WaitBitmap: Pointer;
hArrowCursor, hPointCursor, hWaitCursor: LongWord;
FileSize: LongWord;
begin
HeapCreate;
ExtractFileDirectory(AppPath^, AppPath^);
SetCurrentDirectory(AppPath^);
ArrowBitmapFile := LoadFile('arrow.bmp', FileSize);
PointBitmapFile := LoadFile('point.bmp', FileSize);
WaitBitmapFile := LoadFile('wait.bmp', FileSize);
ArrowBitmap := Pointer(LongWord(ArrowBitmapFile) + ArrowBitmapFile.BitmapFileHeader.bfOffBits);
PointBitmap := Pointer(LongWord(PointBitmapFile) + PointBitmapFile.BitmapFileHeader.bfOffBits);
WaitBitmap := Pointer(LongWord(WaitBitmapFile) + WaitBitmapFile.BitmapFileHeader.bfOffBits);
hArrowCursor := LoadCursorIndirect(ArrowBitmap^, 0, 0);
hPointCursor := LoadCursorIndirect(PointBitmap^, 12, 0);
hWaitCursor := LoadCursorIndirect(WaitBitmap^, 0, 0);
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Cursor', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
DrawText( 8, 8, 'Click on picture buttons', 0, $00FFFFFF, DT_CP866_8X16 + DT_FILL_OPAQUE + DT_ZSTRING, 0);
DrawText( 8, 25, 'below to select cursor:', 0, $00FFFFFF, DT_CP866_8X16 + DT_FILL_OPAQUE + DT_ZSTRING, 0);
DrawButton(8, 40, 32, 32, 0, BS_FILL_TRANSPARENT, ARROW_BUTTON);
DrawButton(52, 40, 32, 32, 0, BS_FILL_TRANSPARENT, POINT_BUTTON);
DrawButton(96, 40, 32, 32, 0, BS_FILL_TRANSPARENT, WAIT_BUTTON );
Blit(ArrowBitmap^, 0, 0, 32, 32, 8, 40, 32, 32, 32*4, BLIT_CLIENT_RELATIVE);
Blit(PointBitmap^, 0, 0, 32, 32, 52, 40, 32, 32, 32*4, BLIT_CLIENT_RELATIVE);
Blit(WaitBitmap^, 0, 0, 32, 32, 96, 40, 32, 32, 32*4, BLIT_CLIENT_RELATIVE);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
case GetButton.ID of
ARROW_BUTTON:
SetCursor(hArrowCursor);
POINT_BUTTON:
SetCursor(hPointCursor);
WAIT_BUTTON:
SetCursor(hWaitCursor);
1:
TerminateThread;
end;
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,3 @@
@echo off
call "%~dp0..\..\Lib\build.bat" "%~dp0SetCursor"
copy "%~dp0*.bmp" "%~dp0..\..\Bin" >nul

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
Examples/SetCursor/wait.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,51 @@
program SetPixelApp;
uses
KolibriOS;
var
Left, Right, Top, Bottom: Integer;
X, Y: Integer;
begin
with GetScreenSize do
begin
Right := 180;
Bottom := 180;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Pixel', $00FFFFFF,
WS_SKINNED_FIXED + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
for Y := 0 to 50 do
for X := 0 to 50 do
if ((X mod 2) = 0) or ((Y mod 2) = 0) then
SetPixel(X, Y, $00FF0000);
for Y := 50 to 100 do
for X := 50 to 100 do
if ((X mod 3) = 0) or ((Y mod 3) = 0) then
SetPixel(X, Y, $00007F00);
for Y := 100 to 150 do
for X := 100 to 150 do
if ((X mod 4) = 0) or ((Y mod 4) = 0) then
SetPixel(X, Y, $000000FF);
EndDraw;
end;
KEY_EVENT:
GetKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0SetPixel"

View File

@@ -0,0 +1,84 @@
program SetWindowPosApp;
uses
KolibriOS;
const
KS_UP = #$48;
KS_DOWN = #$50;
KS_LEFT = #$4B;
KS_RIGHT = #$4D;
MOVE_STEP = 10;
LEFT_CTRL_PRESSED = 4;
RIGHT_CTRL_PRESSED = 8;
procedure OnKey;
var
Key: TKeyboardInput;
ThreadInfo: TThreadInfo;
ControlKeyState: LongWord;
begin
GetThreadInfo($FFFFFFFF, ThreadInfo);
ControlKeyState := GetControlKeyState;
Key := GetKey;
with ThreadInfo.Window do
begin
if Boolean(ControlKeyState and (RIGHT_CTRL_PRESSED or LEFT_CTRL_PRESSED)) then
case Key.Scan of
KS_UP:
Dec(Bottom, MOVE_STEP);
KS_DOWN:
Inc(Bottom, MOVE_STEP);
KS_LEFT:
Dec(Right, MOVE_STEP);
KS_RIGHT:
Inc(Right, MOVE_STEP);
end
else
case Key.Scan of
KS_UP:
Dec(Top, MOVE_STEP);
KS_DOWN:
Inc(Top, MOVE_STEP);
KS_LEFT:
Dec(Left, MOVE_STEP);
KS_RIGHT:
Inc(Left, MOVE_STEP);
end;
SetWindowPos(Left, Top, Right, Bottom);
end;
end;
var
Left, Right, Top, Bottom: Integer;
begin
with GetScreenSize do
begin
Right := Width div 4;
Bottom := Height div 4;
Left := (Width - Right) div 2;
Top := (Height - Bottom) div 2;
end;
while True do
case WaitEvent of
REDRAW_EVENT:
begin
BeginDraw;
DrawWindow(Left, Top, Right, Bottom, 'Set Window Position', $00FFFFFF,
WS_SKINNED_SIZABLE + WS_COORD_CLIENT + WS_CAPTION, CAPTION_MOVABLE);
DrawText(24, 26, 'Use arrow keys(Left, Right, Up, Down)', $00000000, $00FFFFFF, DT_ZSTRING, 0);
DrawText(24, 35, 'to move the window.', $00000000, $00FFFFFF, DT_ZSTRING, 0);
DrawText(24, 44, 'Use Ctrl+arrow keys to resize window.', $00000000, $00FFFFFF, DT_ZSTRING, 0);
EndDraw;
end;
KEY_EVENT:
OnKey;
BUTTON_EVENT:
if GetButton.ID = 1 then
TerminateThread;
end;
end.

View File

@@ -0,0 +1 @@
@call "%~dp0..\..\Lib\build.bat" "%~dp0SetWindowPos"