home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 November
/
Chip_2004-11_cd1.bin
/
tema
/
fax
/
download
/
ventafax5
/
vfvh5519i.exe
/
RCDATA
/
CABINET
/
informer.dpr
< prev
next >
Wrap
Text File
|
2003-09-02
|
15KB
|
441 lines
library informer;
uses
Windows,
Messages,
CommDlg,
Sysutils;
type
TColor = -$7FFFFFFF-1..$7FFFFFFF;
const
BoolValues: array[Boolean] of string = ('0', '1');
MaskIsRecFile = $20;
WS_EX_LAYERED = $00080000;
LWA_COLORKEY = $00000001;
WindowHeight = 110;
WindowWidth = 420;
clBlack = TColor($000000);
clMaroon = TColor($000080);
clGreen = TColor($008000);
clOlive = TColor($008080);
clNavy = TColor($800000);
clPurple = TColor($800080);
clTeal = TColor($808000);
clGray = TColor($808080);
clSilver = TColor($C0C0C0);
clRed = TColor($0000FF);
clLime = TColor($00FF00);
clYellow = TColor($00FFFF);
clBlue = TColor($FF0000);
clFuchsia = TColor($FF00FF);
clAqua = TColor($FFFF00);
clLtGray = TColor($C0C0C0);
clDkGray = TColor($808080);
clWhite = TColor($FFFFFF);
clNone = TColor($1FFFFFFF);
clDefault = TColor($20000000);
cNameLength = 16;
cDescriptionLength = 1024;
type
pTPluginName = ^TPluginName;
TPluginName = array[0..cNameLength-1] of Char;
pTPluginDescription = ^TPluginDescription;
TPluginDescription = array[0..cDescriptionLength-1] of Char;
TSetLayeredWindowAttributes = function(Handle: THandle;
crKey: DWord;
bAlpha: Byte;
dwFlags: DWord): HRESULT; stdcall;
PInfStatus = ^TInfStatus;
TInfStatus = packed record
bAlreadyRun : Boolean;
iNumFaxMessage : DWord;
iNumVoiceMessage : DWord;
end;
TDaTi = packed record
Year : Word;
Month : Word;
Day : Word;
Hour : Word;
Min : Word;
Sec : Word;
end;
PTRec32C = ^TRec32C;
TRec32C = packed Record
phone : array[0..63] of Char;
firm : array[0..63] of Char;
ToAbonent : array[0..73] of Char;
filename : array[0..255] of Char;
DocName : array[0..63] of Char;
result : Word;
speed : Word;
quality : Word;
Date : TDaTi;
Min, Sec : Word;
Pages : Word;
LastPage : Word;
NBlock : LongInt;
NBadBlock : LongInt;
Attr : Word;
ExtData : array[0..63] of Char;
CSI : array[0..21] of Char;
NCF : array[0..63] of Char;
RecId : LongInt;
AbId : LongInt;
CompName : array[0..31] of Char;
PhoneCardID : DWORD;
LocationID : DWORD;
ExtOption : DWORD;
VLine : WORD;
Reserve : array[0..49] of char;
end;
var
ShowCount : Integer;
Inst : Integer;
hLib : Integer;
Handle : Integer;
hMessageFont : Integer;
hCountFont : Integer;
hOkFont : Integer;
hMapObj : Integer;
hlMessage : Integer;
hlCount : Integer;
hlOk : Integer;
TextColor : TColor;
// BackgroundColor : TColor;
bMMFWasCreated : Boolean;
bExit : Boolean;
bSoundOn : Boolean;
wFlag : Cardinal;
WinClass : TWndClassA;
Msg : TMsg;
pInfSt : PInfStatus;
IniFileName : array[0..255] of Char;
SetLayeredWindowAttributes : TSetLayeredWindowAttributes;
function ColorToRGB(Color: TColor): Longint;
begin
if Color < 0
then Result := GetSysColor(Color and $000000FF)
else Result := Color;
end;
function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;
begin
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
if uMsg = WM_CTLCOLORSTATIC then
begin
if (lParam =hlMessage) or (lParam =hlCount) then
begin
SetTextColor(WParam, ColorToRGB(TextColor));
SetBkColor(WParam, ColorToRGB(clNone));
end
else if lParam =hlOk then
begin
SetTextColor(WParam, ColorToRGB(clNone));
SetBkColor(WParam, ColorToRGB(TextColor));
end;
end;
if uMsg = WM_TIMER then
begin
if pInfSt<> nil then SetWindowText(hlCount, PChar('Fax: '
+IntToStr(pInfSt.iNumFaxMessage)
+' Voice: '
+IntToStr(pInfSt.iNumVoiceMessage)));
if ShowCount = 2
then begin
SetWindowText(hlMessage, ' ');
ShowCount := 0;
end
else begin
SetWindowText(hlMessage, ' Message received');
if bSoundOn and (ShowCount=0) then MessageBeep(MB_ICONASTERISK);
Inc(ShowCount);
end;
end;
if (uMsg = WM_LBUTTONDOWN) or (uMsg = WM_DESTROY) then bExit := true;
end;
function AfterSession(R : TRec32C): LongInt; stdcall; export;
var
Buffer : array[0..2047] of Char;
begin
Result := 0;
if (StrPas(R.filename)='') or ((R.Attr and MaskIsRecFile)<>0) then Exit;
hMapObj := OpenFileMapping(FILE_MAP_ALL_ACCESS,true,'VFInformer');
bMMFWasCreated := hMapObj=0;
if bMMFWasCreated then hMapObj := CreateFileMapping($ffffffff,nil,PAGE_READWRITE,0,SizeOf(TInfStatus),'VFInformer');
pInfSt := MapViewOfFile(hMapObj,FILE_MAP_ALL_ACCESS,0,0,0);
if pInfSt.bAlreadyRun then
begin
if pInfSt <> nil then
begin
if Pos('wav',LowerCase(ExtractFileExt(StrPas(R.filename))))<>0
then Inc(pInfSt.iNumVoiceMessage)
else Inc(pInfSt.iNumFaxMessage);
end;
CloseHandle(hMapObj);
Exit;
end;
GetPrivateProfileString('setting','color',PChar(IntToStr(clRed)),Buffer, SizeOf(Buffer),IniFileName);
TextColor := StrToIntDef(StrPas(Buffer),clRed);
WritePrivateProfileString('setting','color',PChar(IntToStr(TextColor)),IniFileName);
GetPrivateProfileString('setting','sound','0',Buffer, SizeOf(Buffer),IniFileName);
bSoundOn := StrToInt(StrPas(Buffer)) = 1;
WritePrivateProfileString('setting','sound',PChar(BoolValues[bSoundOn]),IniFileName);
FillChar(pInfSt^,SizeOf(TInfStatus),#0);
if pInfSt <> nil then
begin
if Pos('wav',LowerCase(ExtractFileExt(StrPas(R.filename))))<>0
then Inc(pInfSt.iNumVoiceMessage)
else Inc(pInfSt.iNumFaxMessage);
end;
pInfSt.bAlreadyRun := true;
bExit := false;
Inst := hInstance;
ShowCount := 0;
hLib := LoadLibrary('user32.dll');
if hLib>=32 then @SetLayeredWindowAttributes := GetProcAddress(HLib,'SetLayeredWindowAttributes');
if Assigned(SetLayeredWindowAttributes)
then wFlag := WS_POPUP
else wFlag := WS_POPUP or WS_VISIBLE;
with WinClass do
begin
style := 2;
lpfnWndProc := @WindowProc;
hInstance := Inst;
hbrBackground := CreateSolidBrush(clNone);
lpszClassname := 'INFORMER_WINDOW';
hCursor := LoadCursor(0, IDC_HAND);
end;
RegisterClass(WinClass);
Handle := CreateWindowEx(WS_EX_TOOLWINDOW, 'INFORMER_WINDOW', '',
wFlag,
(GetSystemMetrics(SM_CXSCREEN)-WindowWidth) div 2,
(GetSystemMetrics(SM_CYSCREEN)-WindowHeight) div 2,
WindowWidth,
WindowHeight-15,
0,
0,
Inst,
nil);
SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
if Assigned(SetLayeredWindowAttributes) then
begin
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE) or WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle,clNone,0,LWA_COLORKEY);
end;
SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) or WS_VISIBLE);
hlMessage := CreateWindow('Static',
'',
WS_VISIBLE or WS_CHILD or SS_CENTER or SS_SIMPLE,
0,
0,
WindowWidth,
WindowHeight div 2,
Handle,
0,
Inst,
nil);
hlOk := CreateWindow('Static',
'',
WS_VISIBLE or WS_CHILD or SS_CENTER or SS_SIMPLE,
WindowWidth-94,
WindowHeight div 2,
WindowWidth,
WindowHeight div 2,
Handle,
0,
Inst,
nil);
hlCount := CreateWindow('Static',
'',
WS_VISIBLE or WS_CHILD or SS_CENTER or SS_SIMPLE,
WindowWidth div 2 - 140,
(WindowHeight div 2) + 10,
WindowWidth,
WindowHeight div 2,
Handle,
0,
Inst,
nil);
hMessageFont := CreateFont(60,
17,
0,
0,
800,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE,
'Arial Black');
hCountFont := CreateFont(28,
12,
0,
0,
800,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE,
'Arial Black');
hOkFont := CreateFont(40,
17,
0,
0,
800,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE,
'Arial Black');
if hMessageFont <> 0 then SendMessage(hlMessage, WM_SETFONT, hMessageFont, 0);
if hCountFont <> 0 then SendMessage(hlCount, WM_SETFONT, hCountFont, 0);
if hOkFont <> 0 then SendMessage(hlOk, WM_SETFONT, hOkFont, 0);
SetWindowText(hlMessage, ' Message received');
SetWindowText(hlOk, ' OK ');
if pInfSt<> nil then SetWindowText(hlCount, PChar('Fax: '
+IntToStr(pInfSt.iNumFaxMessage)
+' Voice: '
+IntToStr(pInfSt.iNumVoiceMessage)));
UpdateWindow(Handle);
SetTimer(Handle,0,400,nil);
while GetMessage(Msg, Handle, 0, 0) and (not bExit) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
Killtimer(Handle,0);
DestroyWindow(hlCount);
DestroyWindow(hlOk);
DestroyWindow(hlMessage);
DestroyWindow(Handle);
DeleteObject(hMessageFont);
DeleteObject(hCountFont);
DeleteObject(hOkFont);
pInfSt.bAlreadyRun := false;
UnmapViewOfFile(pInfSt);
CloseHandle(hMapObj);
FreeLibrary(HLib);
end;
procedure PluginName(const pPluginName: pTPluginName; const Size: DWord); stdcall; export;
const
csPluginName = 'Informer v1.2';
begin
StrPLCopy(Pointer(pPluginName),csPluginName,Size);
end;
procedure PluginDescription(const pPluginDescription: pTPluginDescription; const Size: DWord); stdcall; export;
const
csPluginDescription = 'VentaFax Informer Plugin v1.2'#13#10+
'(c) 2003 Venta Association'#13#10+
'This sample plug-in displays number of received voice and fax messages.'#13#10+
'http://www.ventafax.com'#13#10+
'Build date: September 1, 2003';
begin
StrPLCopy(Pointer(pPluginDescription),csPluginDescription,Size);
end;
procedure Configure(hWnd: THandle); stdcall; export;
const
MaxCustomColors = 16;
type
TCustomColors = array[0..MaxCustomColors - 1] of Longint;
var
tagChooseColor : TChooseColor;
aCustomColors : TCustomColors;
i : LongInt;
Buffer : array[0..2047] of Char;
begin
GetPrivateProfileString('setting','color',PChar(IntToStr(clRed)),Buffer, SizeOf(Buffer),IniFileName);
TextColor := StrToIntDef(StrPas(Buffer),clRed);
WritePrivateProfileString('setting','color',PChar(IntToStr(TextColor)),IniFileName);
FillChar(tagChooseColor,SizeOf(TChooseColor),#0);
for i := 0 to MaxCustomColors - 1 do aCustomColors[i] := -1;
tagChooseColor.lStructSize := SizeOf(TChooseColor);
tagChooseColor.hWndOwner := hWnd;
tagChooseColor.Flags := CC_RGBINIT;
tagChooseColor.rgbResult := ColorToRGB(TextColor);
tagChooseColor.lpCustColors := @aCustomColors;
if ChooseColor(tagChooseColor) then
begin
TextColor := TColor(tagChooseColor.rgbResult);
WritePrivateProfileString('setting','color',PChar(IntToStr(TextColor)),IniFileName);
end;
if Handle<>0 then InvalidateRect(Handle,nil,true);
bSoundOn := MessageBox(hWnd,'Sound On?','Sound setup',MB_YESNO or MB_ICONQUESTION) = IDYES;
WritePrivateProfileString('setting','sound',PChar(BoolValues[bSoundOn]),IniFileName);
end;
exports
Configure,
PluginName,
PluginDescription,
AfterSession;
begin
Handle := 0;
GetModuleFileName(hInstance,@IniFileName,SizeOf(IniFileName)-1);
StrPCopy(IniFileName,ChangeFileExt(StrPas(IniFileName),'.ini'));
end.