Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Systray
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
01033877
Message ID:
01033983
Vues:
14
I do not remember what changes did we in the Systray class, but We have 3 Icons in the SysTray that use our own implementation of the solution class, and I can not reproduce the problem.

We have (I must say "I have", for all this icons are optional for the users) a 4th icon in the systray for a program I created long time ago, that it uses an OCX created by an Uruguayan guy (I believe the name is SysTrayProj.Icon) that I chosed over bbSysTray for it had no limitation on how many icons you can have active (If I remember correctly bbSysTray can only handle 5), the problem with the OCX was that it had no menu, so I create the menu using API calls, and although the code is ugly (I used a trial an error aproach, for I did not have at the moment much documentation) it works quite well, here is the code if anyone is interested, remember it is old and it is ugly, it has no error checking etc, but it can give an idea of how to create a Top Level Menu when there is no VFP Screen or Window visible
*******************************************************************************
* Function TopLevelMenu                                                       *
*                                                                             *
* This function creates a simple menu from an array passed as a parameter and *
* returns the selected item, 0 or -1 where 0 means no selection and -1 an     *
* error has occurred. This menu is useful when there is no visible screen.    *
*                                                                             *
*******************************************************************************


lparameters lpaMenuItems, lpnX, lpnY, lpnCheckedItem, lplTopAlign
local i, lnMenuItems, llaMenuItems, lnColumns, lnItems, lhMenu
local lhMainWindow, llReleaseFoxtools, lnX, lnY, lnSelected, lnCheckedItem, lnAlign

#define MF_STRING		0x00000000
#define MF_SEPARATOR		0x00000800
#define MF_ENABLED		0x00000000
#define MF_GRAYED		0x00000001
#define MF_DISABLED		0x00000002
#define MF_CHECKED		0x00000008
#define TPM_RIGHTALIGN		0x0008
#define TPM_BOTTOMALIGN		0x0020
#define TPM_RETURNCMD		0x0100
#define TPM_RIGHTBUTTON		0x0002


* Initialize Variables to default values
lhMenu			= 0									&& Handle to the Menu
lnItems			= 2									&& # of Items
lnSelected		= -1	&& Selected Item, or
				&& zero if no item selected, or
				&& -1 if an error occurred
lnX		= iif(vartype(lpnX)='N', lpnX, 0)	&& X coordinate of the popup menu
lnY		= iif(vartype(lpnY)='N', lpnY, 0)	&& Y coordinate of the popup menu
lnCheckedItem	= iif(vartype(lpnCheckedItem)='N', ;
		  lpnCheckedItem, 0)			&& Item to display checked (only one)
lnAlign		= iif(lplTopAlign, 0, TPM_RIGHTALIGN+TPM_BOTTOMALIGN)

* declare all API functions

declare integer CreatePopupMenu in Win32API

declare integer DestroyMenu in Win32API ;
	integer hMenu

declare integer IsMenu in Win32API ;
	integer hMenu

declare integer TrackPopupMenu in Win32API ;
	integer hMenu, ;
	integer uFlags, ;
	integer x, ;
	integer y, ;
	integer nReserved, ;
	integer hwnd, ;
	integer prcRect

declare integer AppendMenu in Win32API ;
	integer hMenu, ;
	integer uFlags, ;
	integer UIDNewItem, ;
	string @ lpNew_Item

* Verify that lpaMenuItems is an Array, and if it is not, use default values

if type('lpaMenuItems[1]')='U'
	* Use default values
	dimension laMenuItems(2, 2)
	laMenuItems[1, 1]='&Restore'
	laMenuItems[1, 2]=MF_STRING
	laMenuItems[2, 1]='&Close'
	laMenuItems[2, 2]=MF_STRING
else
	* The parameter was an array
	lnItems=alen(lpaMenuItems, 1)
	acopy(lpaMenuItems, laMenuItems)
endif

* Verify the # of columns, should be 2 for future upgrades
lnColumns=alen(laMenuItems, 2)
if lnColumns<2
	dimension laMenuItems(lnItems, 2)
	for i=lnItems*2-1 to 1 step -2
		laMenuItems[int(i/2)+1,1]=laMenuItems[int(i/2)+1]
	next i
	for i=1 to lnItems
		laMenuItems[i, 2]=0
	next i
endif

* Create the API Menu
lhMenu=CreatePopupMenu()
if IsMenu(lhMenu)=0
	skydialog('*Error Creating Menu', 'Contact MIS', '', 0)
	return lnSelected
endif

* Append the Items
for i=1 to lnItems
	* Disable items that starts with "\"
	if left(laMenuItems[i, 1], 1)='\'
		laMenuItems[i, 1]=substr(laMenuItems[i, 1], 2)
		laMenuItems[i, 2]=MF_STRING+MF_DISABLED+MF_GRAYED
	endif
	if lnCheckedItem<>0		&& To allow multiple selections if parameter not passed
		laMenuItems[i, 2]=iif(i=lnCheckedItem, MF_CHECKED, 0)+MF_STRING
	endif
	if AppendMenu(lhMenu, laMenuItems[i, 2], i, laMenuItems[i, 1])=0
		skydialog('*Error Creating Items for the Menu', 'Contact MIS', '', 0)
		return lnSelected
	endif
next i

lnSelected=0
llReleaseFoxtools=not ('\foxtools'$lower(set('library')))
if llReleaseFoxtools
	set library to ('x:\foxv\prog\foxtools.fll') additive
endif

* Grab the handle to the main FoxPro Window
lhMainWindow=_WHToHWnd( _WMainWind())
if lhMainWindow < 1
	skydialog('*Error Getting the Main Window Handler', 'Contact MIS', '', 0)
	return -1
endif

* Read the Menu
lnSelected=TrackPopupMenu(lhMenu, lnAlign+TPM_RETURNCMD+TPM_RIGHTBUTTON, lnX, lnY, 0, lhMainWindow, 0)

* Restore settings and destroy the menu
if llReleaseFoxtools
	release library ('x:\foxv\prog\foxtools.fll')
endif
DestroyMenu(lhMenu)

return lnSelected
I was just laughing at my "Future upgrades" comment....

SkyDialog is just a customized MessageBox replacement.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform