rejetto forum

tray.balloon

Mars · 8 · 3411

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2041
    • View Profile
@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

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  >:( :( :-\ :'( :-[, because it is him who had the idea. ;) :D

example:

Quote
var
  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;
and some others..  ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
i don't understand, what's the difference? you can already call balloon() for other purposes


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2041
    • View Profile
The syntax of balloon (string, TtrayMessageType, string, integer) was too much complicated for silentpliz, simpler for him to memorize the following formula (string, string, string, integer) and to add the possibility to use balloon(text,time) and not balloon(text, '', '', time)

Finally it is rather in silentpliz to defend his beefsteak  ;D :D


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13310
    • View Profile
for balloon(text,time) i changed the order of parameters instead of overloading. Ok?

about the TtrayMessageType,
1. it's considered bad practice because the "enum" type prevents you from mistyping 'warming' and wondering why it's not working
2. from 'warning' to TM_WARNING it's just an extra char, not a big deal.


Offline TCube

  • Tireless poster
  • ****
    • Posts: 445
    • View Profile
for balloon(text,time) i changed the order of parameters instead of overloading. Ok?

about the TtrayMessageType,
1. it's considered bad practice because the "enum" type prevents you from mistyping 'warming' and wondering why it's not working
2. from 'warning' to TM_WARNING it's just an extra char, not a big deal.

Rejetto, I agree, as mention by Mars - " .../... this only concernes the 'French Version.../... "  inspite of "improuvements within the code" theses will be never in anyway deployed on any other  Templates "mods"

T3
« Last Edit: September 15, 2010, 04:12:12 PM by TCube »
Make it idiot-proof and I will make a better idiot


Offline SilentPliz

  • Operator
  • Tireless poster
  • *****
    • Posts: 1298
  • ....... chut ! shh!
    • View Profile
Rejetto, I agree, as mention by Mars - " .../... this only concernes the 'French Version.../... "  inspite of "improuvements within the code" theses will be never in anyway deployed on any other  Templates "mods"

T3

This topic only concern internal messages "tray balloon" (error & other...) in hfs.exe. The syntax for templates is not modified.
For tray balloon notifications in templates "mods", an diff template exist... for who want it.

http://www.rejetto.com/forum/index.php/topic,9000.msg1051769.html#msg1051769


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2041
    • View Profile
Quote
for balloon(text,time) i changed the order of parameters instead of overloading. Ok?

To change the order for it would be good

function TmyTrayIcon.balloon(msg:string; secondsTimeout:real; kind:TtrayMessageType; title:string):boolean;

more easy to use tray.balloon('blablabla',10); instead of tray.balloon('blablabla', '', '', 10);


Silentpliz began to complain to have pain in fingers due to writing many of  '', '',

 :D ;D


Offline SilentPliz

  • Operator
  • Tireless poster
  • *****
    • Posts: 1298
  • ....... chut ! shh!
    • View Profile
Quote
for balloon(text,time) i changed the order of parameters instead of overloading. Ok?

It's perfect for me. ;)

Silentpliz began to complain to have pain in fingers due to writing many of   '', '',

Now I have a whitlow as big as a pingpong ball on each fingers. ;D
« Last Edit: September 16, 2010, 02:55:54 PM by SilentPliz »