Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Modify report in run time
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00409711
Message ID:
00410239
Vues:
18
In skip for I place call DeleteBars() I place code to cleanup menu.
Function DeleteBars
Local lcBarName
Local i

oMenu=CREATEOBJECT('menu97cls')

hwnd = thisform.hwnd && Here my toplevel form class have hwnd (you can use FindWIndow api function

delta=-1

If cntbar('_msm_view')>0
	For i=1 to cntbar('_msm_view')
		lcBarName = PRMBAR('_msm_view',getbar('_msm_view',i))
		If UPPER(LEFT(lcBarName,6))="BROWSE" OR ;
				UPPER(lcBarName)="DATABASE DESIGNER" OR ;
				UPPER(lcBarName)="TABLE DESIGNER" OR ;
				UPPER(lcBarName)="DATAENVIRONMENT" 
*!* Here I call the class method for remove menu item
				oMenu.RemoveMenuItem(hwnd,3,i+delta) 

*!* Or possible to use DISABLE menu item 
*!*				oMenu.SetMenuDisabled(hwnd,3,i-2,lcBarName)
				delta=delta-1
		Endif
	Endfor
Endif
Return .f. && For _msm_view was accessable

Define CLASS Menu97cls AS CUSTOM

	Procedure SetMenuDisabled
	Parameters hwnd,;                 && Handle of window
		tnMenuIndex,;             && Pad index
		tnSubmenuIndex,;          && Bar index
		tcItemCaption             && Caption of menu item

	Local HMENU
	Local MenuID
	Local lcPadName
	Local x


	Declare INTEGER GetMenu IN user32.DLL ;
		INTEGER HWND

	Declare INTEGER GetSubMenu IN user32.DLL ;
		INTEGER hmenu, ;
		INTEGER npos

	Declare INTEGER GetMenuItemID IN user32.DLL ;
		INTEGER hmenu, ;
		INTEGER nPos

	Declare INTEGER ModifyMenu IN user32.DLL ;
		INTEGER hmenu,;
		INTEGER uItem, ;
		INTEGER fuFlags, ;
		INTEGER idNewItem, ;
		STRING @lcTextMenu

	#Define MF_GRAYED           0x00000001

	HMENU = GetMenu(HWND)
	hSubmenu = GetSubMenu(HMENU,tnMenuIndex)

	MenuID = GetMenuItemID(hSubmenu,tnSubmenuIndex)
	lcPadName = tcItemCaption+CHR(0)
	x =	ModifyMenu(hSubmenu,MenuID,MF_GRAYED,MenuID,@lcPadName)

Endproc


*!* **************************************  *!*
*!* Procedure remove menu item from menu	
*!* Parameters :
*!* hwnd - window handle
*!* tnMenuIndex - pad index
*!* tnSubmenuIndex - bar index
*!* **************************************** *!*
	Procedure RemoveMenuItem

	Parameters hwnd,;
		tnMenuIndex,;
		tnSubmenuIndex

	Local HMENU
	Local MenuID
	Local lcPadName
	Local x


        Declare INTEGER GetMenu IN user32.DLL ;
		INTEGER HWND

	Declare INTEGER GetSubMenu IN user32.DLL ;
		INTEGER hmenu, ;
		INTEGER npos

	Declare INTEGER GetMenuItemID IN user32.DLL ;
		INTEGER hmenu, ;
		INTEGER nPos

	Declare INTEGER RemoveMenu IN user32.DLL ;
		INTEGER hmenu,;
		INTEGER uItem,;
		INTEGER npos

	#Define MF_BYPOSITION		0x00000400

	HMENU = GetMenu(HWND)
	hSubmenu = GetSubMenu(HMENU,tnMenuIndex)

	MenuID = GetMenuItemID(hSubmenu,tnSubmenuIndex)
	x = RemoveMenu(hSubmenu,tnSubmenuIndex,MF_BYPOSITION)
Endproc

Enddefine
Maybe exist more easy way.. but I not found that..
Also my menu97cls support insert bitmap into VFP menu as does most windows application
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform