i have one question:
How can i cancel the context menu when the user click right on the spreadsheet?
In normal situation, the user will see the OWC menu of the spreadsheet, when he click right on the spreadsheet, but i will show my own menu. The Spreadsheet support the specificated event "BeforeContextMenu" to catch the context menu event right click on the spreadsheet. To disable the standard right click context menu we have to set the cancel parameter #True ("Cancel = #True), but how did i do this? I try it with the easy callback, see code below, but it doesn't seems to work.
Code: Select all
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
Global ExcelObject.COMateObject
Global ExcelObject1.COMateObject
Procedure myEventCallback(object.COMateObject, eventName.s, parameterCount)
If eventName.s="BeforeContextMenu"
object\Invoke("Cancel = #True")
object\Setproperty("Cancel = #True")
EndIf
EndProcedure
If OpenWindow(0,#PB_Ignore,#PB_Ignore,800,800,"COMate: OWC11.Spreadsheet-Demo",#PB_Window_Invisible|#PB_Window_SystemMenu)
ExcelObject=COMate_CreateActiveXControl(0,0,800,400,"OWC11.Spreadsheet")
If ExcelObject
ExcelObject\SetProperty("Cells(1,1) = 'Özgür'")
ExcelObject\SetProperty("Cells(1,2) = 'Levent'")
ExcelObject\SetProperty("Cells(2,1) = 10")
ExcelObject\SetProperty("Cells(2,2) = 20")
ExcelObject\SetProperty("Cells(1, 1)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(1, 2)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(2, 1)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(2, 2)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(1, 1)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(1, 2)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(2, 1)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(2, 2)\Font\Color = 255255255")
ExcelObject\GetObjectProperty("Sheets('3')\Delete")
ExcelObject\GetObjectProperty("Sheets('2')\Delete")
ExcelObject\SetProperty("Cells(1, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(1, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(2, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(2, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("DisplayToolbar = #False")
ExcelObject\SetProperty("ScreenUpdating = #True")
ExcelObject\SetProperty("ViewOnlyMode = #True") ;Schreibschutz
ExcelObject\SetProperty("DisplayOfficeLogo = #False")
ExcelObject\SetProperty("DisplayTitleBar = #False")
ExcelObject\SetProperty("ActiveWindow\DisplayWorkbookTabs = #False")
HRESULT=ExcelObject\SetEventHandler(#COMate_CatchAllEvents,@myEventCallback())
Else
Debug "!mySpreadsheet"
EndIf
HideWindow(0,0)
If ExcelObject
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
ExcelObject\Release()
EndIf
CloseWindow(0)
EndIf