I'm trying to change the mouse pointer due to a lengthy operation, but the pointer does not change although the macro seems to work.
Can anyone tell me what I'm doing wrong?
sub Worker
...
...
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), True)
...
...
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), False)
end sub
Sub setWindowPointer(oWin As Object, bWait As Boolean)
Dim oPointer As Object
oPointer = CreateUnoService("com.sun.star.awt.Pointer")
If bWait Then
oPointer.SetType(com.sun.star.awt.SystemPointer.WAIT)
Else
oPointer.SetType(com.sun.star.awt.SystemPointer.ARROW)
Endif
oWin.SetPointer(oPointer)
End Sub
Last edited by robleyd on Wed Jan 22, 2020 11:56 pm, edited 1 time in total.
Reason:Added Code tags
The only other thing I can think of is is your operation on a hidden document?
As the code is fine its perhaps something to do with the code you haven't posted (no-one can help you there).
Edit: you can see that the code is fine on its own by putting wait 1000 in between the two changes.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Andrew Pitonyak had the answer: this operation is not supported as of OOo version 1.1.3.
" You can not set the mouse pointer of a document window via UNO-API. VCL manages the mouse pointer based on the window, not the top window. Any VCL window can have its own mouse pointer set. If you want to change the mouse pointer of the document window, you must access its XWindowPeer (not the peer of the frame window), and this is not available in the API. Another problem might be that OOo changes the mouse pointer internally and overrides your setting."
sub Worker
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), True)
wait 1000
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), False)
end sub
Sub setWindowPointer(oWin As Object, bWait As Boolean)
Dim oPointer As Object
oPointer = CreateUnoService("com.sun.star.awt.Pointer")
If bWait Then
oPointer.SetType(com.sun.star.awt.SystemPointer.WAIT)
Else
oPointer.SetType(com.sun.star.awt.SystemPointer.ARROW)
Endif
oWin.SetPointer(oPointer)
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
My code is just the original with a wait statement in. If you move the mouse it will revert to an I pointer. You could try something like this... changing the for next to a do loop with your code in.
sub Worker
for i = 0 to 1000
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), True)
wait 50 ' or your code here
next
setWindowPointer(ThisComponent.CurrentController.Frame.GetContainerWindow(), False)
end sub
Sub setWindowPointer(oWin As Object, bWait As Boolean)
Dim oPointer As Object
oPointer = CreateUnoService("com.sun.star.awt.Pointer")
If bWait Then
oPointer.SetType(com.sun.star.awt.SystemPointer.WAIT)
Else
oPointer.SetType(com.sun.star.awt.SystemPointer.ARROW)
Endif
oWin.SetPointer(oPointer)
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)