CAST II Game Engine

   MAIN       FEATURES       SCREENSHOTS       FORUMS       MANUAL       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Unit OSUtils

Description

Operating systems support unit

(C) 2006-2007 George "Mirage" Bakhtadze. www.casteng.com
The source code may be used under either MPL 1.1 or LGPL 2.1 license. See included license.txt file
Unit contains basic OS-related classes

Functions and Procedures

Overview

function ActivateWindow(hwnd: THandle): Boolean;
function AdjustCursorVisibility(Show: Boolean): Integer;
procedure ClientToScreen(Handle: THandle; out X, Y: Integer);
procedure ClipCursor(Rect: TRect);
procedure Delay(Microseconds: Integer);
procedure Exec(const Command: string);
function GetActiveWindow: THandle;
function GetAsyncKeyState(Key: Integer): Integer;
procedure GetClientRect(Handle: THandle; out Rect: TRect);
function GetClipCursor: TRect;
function GetCurrentMs: Cardinal;
function GetOSErrorStr(ErrorID: Integer): string;
function GetPerformanceCounter: Int64;
function GetSysFolder(SysFolder: TSysFolder): string;
function GetTextFromClipboard: string;
procedure GetWindowRect(Handle: THandle; out Rect: TRect);
procedure HideCursor;
procedure HideWindow(Handle: THandle);
function IsWindowVisible(Handle: THandle): Boolean;
procedure MinimizeWindow(Handle: THandle);
procedure ObtainCursorPos(var X, Y: Integer);
procedure ObtainKeyboardState(var State: TKbdState);
procedure ObtainPerformanceFrequency;
procedure OpenURL(const URL: string);
procedure OpenWith(ParentHandle: Cardinal; const FileName: string);
procedure ScreenToClient(Handle: THandle; out X, Y: Integer);
procedure SetCursorPos(X, Y: Integer);
procedure SetCursorVisibility(Counter: Integer);
procedure SetWindowCaption(Handle: THandle; const ACaption: string);
procedure ShowCursor;
procedure ShowWindow(Handle: THandle);
procedure Sleep(Milliseconds: Integer);
function ThreadSafeDecrement(var Addend: Integer): Integer; stdcall; external kernel name 'InterlockedDecrement';
function ThreadSafeIncrement(var Addend: Integer): Integer; stdcall; external kernel name 'InterlockedIncrement';
function WMToMessage(MsgID: Cardinal; wParam, lParam: Integer): TMessage; overload;
function WMToMessage(const Msg: Messages.TMessage): TMessage; overload;

Description

function ActivateWindow(hwnd: THandle): Boolean;

 

function AdjustCursorVisibility(Show: Boolean): Integer;

 

procedure ClientToScreen(Handle: THandle; out X, Y: Integer);

 

procedure ClipCursor(Rect: TRect);

 

procedure Delay(Microseconds: Integer);

Not accurate (~10ms)

procedure Exec(const Command: string);

Accurate

function GetActiveWindow: THandle;

 

function GetAsyncKeyState(Key: Integer): Integer;

 

procedure GetClientRect(Handle: THandle; out Rect: TRect);

 

function GetClipCursor: TRect;

 

function GetCurrentMs: Cardinal;

 

function GetOSErrorStr(ErrorID: Integer): string;

 

function GetPerformanceCounter: Int64;

 

function GetSysFolder(SysFolder: TSysFolder): string;

 

function GetTextFromClipboard: string;

 

procedure GetWindowRect(Handle: THandle; out Rect: TRect);

 

procedure HideCursor;

 

procedure HideWindow(Handle: THandle);

 

function IsWindowVisible(Handle: THandle): Boolean;

 

procedure MinimizeWindow(Handle: THandle);

 

procedure ObtainCursorPos(var X, Y: Integer);

OS dependent

procedure ObtainKeyboardState(var State: TKbdState);

 

procedure ObtainPerformanceFrequency;

 

procedure OpenURL(const URL: string);

 

procedure OpenWith(ParentHandle: Cardinal; const FileName: string);

 

procedure ScreenToClient(Handle: THandle; out X, Y: Integer);

 

procedure SetCursorPos(X, Y: Integer);

 

procedure SetCursorVisibility(Counter: Integer);

OS independent

procedure SetWindowCaption(Handle: THandle; const ACaption: string);

 

procedure ShowCursor;

 

procedure ShowWindow(Handle: THandle);

 

procedure Sleep(Milliseconds: Integer);

 

function ThreadSafeDecrement(var Addend: Integer): Integer; stdcall; external kernel name 'InterlockedDecrement';

 

function ThreadSafeIncrement(var Addend: Integer): Integer; stdcall; external kernel name 'InterlockedIncrement';

 

function WMToMessage(MsgID: Cardinal; wParam, lParam: Integer): TMessage; overload;

 

function WMToMessage(const Msg: Messages.TMessage): TMessage; overload;

 

Types

Overview

THandle = Cardinal;
TKbdState = array[0..255] of Byte;
TRect = Windows.TRect;

Description

THandle = Cardinal;

 

TKbdState = array[0..255] of Byte;

 

TRect = Windows.TRect;

 

Enumerations

TSysFolder
System path
 sfRecycled 
 sfDesktop 
 sfStartMenu 
 sfPrograms 
 sfStartup 
 sfPersonal 
 sfTemplates 
 sfRecent 
 sfSendTo 
 sfNetHood 
 sfAppData 
 sfWinRoot 
 sfWinSys 

Constants

Overview

kernel = 'kernel32.dll';

Description

kernel = 'kernel32.dll';

ToDo: Move to advanced unit

Variables

Overview

OneOverPerformanceFrequency: Single;
PerformanceFrequency: Int64;

Description

OneOverPerformanceFrequency: Single;

 

PerformanceFrequency: Int64;

 

Last modified: Jan 6, 2010
Copyright (C) 2006-2010, casteng.com