16
Programmers corner / tray.balloon
« on: September 14, 2010, 02:21:08 PM »
@rejetto
with a little update , it's posible to use the NOTIFY MESSAGE not only with the macro notify
With a small update, it is possible to use the NOTIFY messages except the notify macro
This modification is great important because it will be in the French version, and because if it it is not resumed in the build 270, the silentpliz will not be really satisfied
, because it is him who had the idea.

example:
with a little update , it's posible to use the NOTIFY MESSAGE not only with the macro notify
With a small update, it is possible to use the NOTIFY messages except the notify macro
Quote
SCRIPTLIB.PAS
if name = 'notify' then
begin
tray.balloon(p, par('type'), par('title'), parF('timeout',3));
result:='';
end;
Quote
TRAYLIB.PAS
function balloon(msg:string; MessageType:string=''; title:string=''; secondsTimeout:real=3):boolean; OVERLOAD;
function balloon(msg:string; secondsTimeout:real):boolean; OVERLOAD;
.........
function TmyTrayIcon.balloon(msg:string; MessageType:string; title:string; secondsTimeout:real):boolean;
var kind:TtrayMessageType;
function stringTotrayMessageType(s:string):TtrayMessageType;
begin
if compareText(s,'warning') = 0 then
result:=TM_WARNING
else if compareText(s,'error') = 0 then
result:=TM_ERROR
else if compareText(s,'info') = 0 then
result:=TM_INFO
else
result:=TM_NONE
end; // stringTotrayMessageType
begin
kind:=stringTotrayMessageType(MessageType);
case kind of
TM_WARNING: icondata.dwInfoFlags:=NIIF_WARNING;
TM_ERROR: icondata.dwInfoFlags:=NIIF_ERROR;
TM_INFO: icondata.dwInfoFlags:=NIIF_INFO;
else icondata.dwInfoFlags:=NIIF_NONE;
end;
strPLCopy(icondata.szInfo, msg, sizeOf(icondata.szInfo)-1);
strPLCopy(icondata.szInfoTitle, title, sizeOf(icondata.szInfoTitle)-1);
icondata.uVersion:=round(secondsTimeout*1000);
icondata.uFlags := icondata.uFlags or NIF_INFO;
update();
icondata.uFlags := icondata.uFlags and not NIF_INFO;
result:=TRUE;
end;
function TmyTrayIcon.balloon(msg:string; secondsTimeout:real):boolean;
begin
balloon(msg,'','',secondsTimeout);
end; // balloon
This modification is great important because it will be in the French version, and because if it it is not resumed in the build 270, the silentpliz will not be really satisfied







example:
Quote
varand some others..
s: string;
begin
if externalIP = '' then exit;
mainfrm.setStatusBarText('Updating dynamic DNS...', 5);
tray.balloon('Updating dynamic DNS...', 5);
dyndns.lastTime:=now();
try s:=httpGet(xtpl(dyndns.url, ['%ip%', externalIP]));
........
procedure TmainFrm.Restoredefault1Click(Sender: TObject);
begin
if msgDlg('Continue?', MB_ICONQUESTION+MB_YESNO) = MRNO then exit;
tplFilename:='';
tplLast:=-1;
tplImport:=TRUE;
setStatusBarText('The template has been reset');
tray.balloon('The template has been reset', 5);end;
