OBJECT Codeunit 50000 balloontip { OBJECT-PROPERTIES { Date=28-01-12; Time=14:46:02; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN ShowBalloontip('Notifyicon can show text up to 256 characters', 'Title goes here', 1); END; } CODE { PROCEDURE ShowBalloontip@1000000003(iTxtMessage@1000000003 : Text[256];iTxtTitle@1000000006 : Text[60];iOptTooltipIcon@1000000005 : 'None,Info,Warning,Error'); VAR lFile@1000000000 : File; lAutWshShell@1000000001 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell"; lIntWinState@1000000002 : Integer; BEGIN lFile.TEXTMODE := TRUE; lFile.CREATE('c:\temp\message.ps1'); lFile.WRITE('[system.reflection.assembly]::loadwithpartialname("System.Windows.Forms")'); lFile.WRITE('[system.reflection.assembly]::loadwithpartialname("System.Drawing")'); lFile.WRITE('$icon=[system.drawing.icon]::ExtractAssociatedIcon(("'+APPLICATIONPATH+'fin.exe"))'); //Use Powershell-icon instead of NAV's: //lFile.WRITE('$icon=[system.drawing.icon]::ExtractAssociatedIcon((join-path $pshome powershell.exe))'); lFile.WRITE('$notify=new-object system.windows.forms.notifyicon'); lFile.WRITE('$notify.icon=$icon'); lFile.WRITE('$notify.visible=$true'); lFile.WRITE('$notify.balloontiptext="'+iTxtMessage+'"'); lFile.WRITE('$notify.balloontiptitle="'+iTxtTitle+'"'); lFile.WRITE('$notify.balloontipicon=[system.windows.forms.tooltipicon]::'+FORMAT(iOptTooltipIcon)); lFile.WRITE('$notify.showballoontip(10000)'); // get rid of the following two lines if you don't want the tray-icon to disappear after 10 seconds // the icon will disappear however as soon as you mouseover it. lFile.WRITE('sleep(10)'); lFile.WRITE('$notify.dispose()'); lFile.CLOSE; CREATE(lAutWshShell); lIntWinState:=0; // hide window lAutWshShell.Run('powershell.exe -executionPolicy Remotesigned c:\temp\message.ps1',lIntWinState); // you'll need to create a timer if you want to delete the message file // 1 sec of sleep is not sufficient to give powershell enough time //SLEEP(2000); //ERASE('c:\temp\message.ps1'); END; BEGIN END. } }
Comments
We might use it for notifying the user, when he sends multiple e-mails from Navision.
Sending price lists, reminders etc. to customers. Then after each e-mail a balloontip could show, showing which customer has been e-mailed.
Just like when you get a balloontip when you send a print to the printer queue.
Tip: instead of
lFile.CREATE('c:\temp\message.ps1');
you could use
lFile.CREATE(DELCHR(ENVIRON('TEMP'),'>','\') + '\' + 'NAV_balloontip.ps1');
And instead of deleting the file in function ShowBalloontip you could delete it in CodeUnit 1 in funtion LoginEnd and/or LoginStart.
That's not quite ideal, but works fine for me.
Remember that users can have two Navision-clients open at the same time.
FileRec: Datatype Record, Subtype File.
http://msdn.microsoft.com/en-us/library/dd301088.aspx
http://www.BiloBeauty.com
http://www.autismspeaks.org
This script isn't showing a tooltip on a control, but a code-controlled balloon showing up as a tray icon
Also we can enable clicking on the Balloontip to open NAV with whatever parameters we want.
@fverkel : this can be useful for not only notify the user but also to make him easily open NAV, and I think also we can open a specific form (not sure about that)
notes that i added the -sta parameter, otherwise the BalloonTipClicked event will not work
check this website to see what else you can do :
http://msdn.microsoft.com/en-us/library/9szb3e6y.aspx
Thanks man.