Sunday, July 16, 2006

Time measuring without timers

GetTickCount (WinAPI)

The GetTickCount gives to you the number of miliseconds that have passed since this Windows session started.
If you have to cut an interval to compare if the time of execution in a function and the last time is between an interval you can use GetTickCount.


if (GettickCount - TimeOfLastExecution) < style="font-weight: bold;">then

This can be used to prevent errors when a critic code (that would consume more than 40% of CPU time) is triggered by user actions without the need to disable controls and enabling them after (what makes your code mess with the interface).

Windows FileMapping

Windows FileMapping (WinAPI)










Have you ever tried to access a file by chunks with BlockRead, BlockWrite? It works fine with types files but if you want to access files with different structures (read a byte at the position 300, an integer at the position 2999, a negative byte in the position 1000? All without the need to declare variables to intermediate these interchanges and without a file handle... is it possible? Yes!).

It is not hard to create complex files. Its enough to store more than one thing in a same place (it is very commom to have a file with different elements). For text only files, a header would solve but not for multimedia files (joining text, video, sound, graphics.. structures, raw data..). Using file of byte) does not give you easy access because does not release you from the work of declaring buffers to interchange data.

Immediate access in memory? Without variables? Use Windows Filemapping! And typecasting.

Canvas and Winamp Skins


GetWindowDC (WinAPI)

Sometimes winamp stops and shows that it draws its skins over a simple window, after Windows! Its when I can see that winamp is "human" because it uses normal window handles as any other program does but overrides this and draws over the entire window canvas (including title bar). How it works? WinAPI. GetWindowDC.

Without VCL ?


Waterfields, softfields, linked by bold colors and red signals, limits of memory and inspiration, the hard fixed aesthetic of the final Assembly code and the Windows GDI covering what happens internally.

I have already tought about free myself from the VCL components as a way to see if I was able to create a Windows program starting from zero however that was impossible. I wanted to use not too much code and to know what the program was doing but this is not productive because in RAD environment this issue is a matter for the tool to solve (Delphi). I tried to see programming as an oasis between mountains: the water is in the lower lands. The VCL code is wonderful. It is time to use RAD and to stop my stupid vainglory to C and Assembly as it was a short path for anything. The shortest path is to not reconcept the wheel. Always.

Search in this blog:
Web DelphiEArte.blogspot.com
ip-location