Systray en PowerBuilder

Requiero que una aplicacion de PB pueda ponerse en el systray de window ya que la aplicacion debe de monitorear la llegada de ciertos archivos pero no debe interrumpir con el uso normal de la computadora y como que tenerla en la barra de tareas es siempre molesto.
Respuesta
1
Encontré esto entre mis archivos, tal vez te sirva
Cualquier cosa avisame
Saludos
AldoB
----------------
Building a Systray Icon
By Ken Howe
I've been getting a lot of requests for an example of how to put an icon in the systray. The systay is that small box near the time on the task bar. The object I've described is the main work horse and you should import this object into your Powerbuilder library.
Basically there are a bunch of API calls which this object calls. The functions on the object provide a nice friendly interface to the API calls:
--START OF OBJECT
$PBExportHeader$nca_systray.sru
$PBExportComments$Systray Utilities V2.0
forward
global type nca_systray from nonvisualobject
end type
end forward
type notifyicondata from structure
long cbsize
long hwnd
long uid
long uflags
long ucallbackmessage
long hicon
character sztip[ 64 ]
end type
global type nca_systray from nonvisualobject autoinstantiate
end type
type prototypes
function long Shell_NotifyIcon ( long dwMessage, ref notifyicondata lpData )
library "shell32"
function long LoadImageA ( long hInstance, string lpszName, uint uType, int
a, int b, uint l ) library "user32"
function long LoadIconA( long hInstance, long lpcstr ) library 'user32'
end prototypes
type variables
Protected:
notifyicondata istr_lpdata
window iw_win
boolean ib_SystemTrayExists
CONSTANT long NIF_MESSAGE=1
CONSTANT long NIF_ICON=2
CONSTANT long NIF_TIP=4
CONSTANT long NIM_ADD=0
CONSTANT long NIM_MODIFY=1
CONSTANT long NIM_DELETE=2
end variables
forward prototypes
public subroutine addicon (string as_iconname, string as_tiptext, window aw_win)
public subroutine delicon ()
public subroutine changeicon (string as_IconName)
public subroutine changetip (string as_TipText)
public function boolean ib_systemtrayexists ()
end prototypes
public subroutine addicon (string as_iconname, string as_tiptext, window aw_win);
IF ib_SystemTrayExists THEN RETURN
iw_Win = aw_Win
istr_lpData.szTip = as_TipText + Char ( 0 )
istr_lpData.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE
istr_lpData.uID = 100
istr_lpData.cbSize = 88
istr_lpData.hwnd = Handle ( iw_Win )
istr_lpData.uCallbackMessage = 1024
istr_lpData.hIcon = LoadImageA( 0, as_IconName, 1, 0, 0, 80 )
shell_notifyicon ( NIM_ADD, istr_lpData )
ib_SystemTrayExists = TRUE
end subroutine
public subroutine delicon ();
IF NOT ib_SystemTrayExists THEN RETURN
istr_lpData.uID = 100
istr_lpData.cbSize = 88
istr_lpData.hwnd = Handle ( iw_Win )
shell_notifyicon ( NIM_DELETE, istr_lpData )
ib_SystemTrayExists = FALSE
end subroutine
public subroutine changeicon (string as_IconName);
IF NOT ib_SystemTrayExists THEN RETURN
istr_lpData.hIcon = LoadImageA ( 0, as_IconName, 1, 0, 0, 80 )
istr_lpData.uFlags = NIF_ICON
shell_notifyicon( NIM_MODIFY, istr_lpData )
end subroutine
public subroutine changetip (string as_TipText);
IF NOT ib_SystemTrayExists THEN RETURN
istr_lpData.szTip = as_TipText + Char ( 0 )
istr_lpData.uFlags = NIF_TIP
shell_notifyicon ( NIM_MODIFY, istr_lpData )
end subroutine
public function boolean ib_systemtrayexists ();
RETURN ib_systemtrayexists
end function
on nca_systray.create
TriggerEvent( this, "constructor" )
end on
on nca_systray.destroy
TriggerEvent( this, "destructor" )
end on
event destructor;
IF ib_SystemTrayExists THEN this.DelIcon()
end event
--END OF OBJECT
Then in your window you need to instantiate the object and call the addicon function. In your open event call the function like:
inca_sysTray.AddIcon( 'pbbrtray.ico', 'PBBrowse V2', this )
Then you need to add an event to your window so you can receive notification of when the user clicked your systray icon. Add an event called systray for pbm_custom01.
Then to make the following script work, add a static text called st_status to the window and add this code to the systay eve
Mi estimado amigo, gracias tu codigo si lo he entendido, de hecho se parece mucho a uno que tengo en VB (Tambien por API functions), ahora bien lo que yo ocupo en esta aplicacion es que se ponga en el Systray cuando lo minimize y que cuando le de click derecho al Icono en el Systray me aparezca un menu popup, espero y puedas ayudarme thanks.
Disculpá la demora pero estoy buscando en mis archivos ya que me parece recordar algo de código similar a lo que solicitas y he tenido una semana bastante dificil
AldoB

1 respuesta más de otro experto

Respuesta

Thanks for sharing the article, and more importantly, your personal experienceMindfully using our emotions as data about our inner state and knowing when it’s better to de-escalate by taking a time out are great tools. Ap https://vidmate.onl/ preciate you reading and sharing your story, since I can certainly relate and I think others can too

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas