GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Standalone viewer and Listers

I spend an awful lot of time in Opus browsing images and then viewing them in the standalone image viewer. Moving through a lister full of images is not practical as the next image I want to view is probably 120 images away from the last. Scrolling through the lister to find it is much quicker.

It struck me there must be a better way to do this that will keep both the image viewer and the lister in view at all times, whether the image is landscape or portrait.

to this end I created a couple of very simple VB macros to automate the whole process. Basically, the main macro decides whether the image to be viewed is portrait or landscape, and then in accordance with those findings it optimises both the lister size and viewer size to make full use of my 3840 x 2160 screen.

(Of course if your screen is of a different size you will have to make some adjustments to the macro, but it really is very simple to do

This shows the screen when the macro has detected a portrait orientation

And this shows the screen when the the macro has detected a landscape image.

In both cases the viewer and the lister do not overlap.

I have attached this button

Open In Viewer.dcf (3.9 KB)

to the left double click event in my images group. The result is that If I double click on an image the viewer either opens in landscape or portrait mode in a position of the screen which does not interfere with the use of the lister.

Close.dcf (930 Bytes)

I have added this button the the viewer bar. When I use it to close the viewer, it returns the lister to its previous size and shape on he screen.

I find it very useful.

2 Likes

If you wanted that to happen when closing the viewer via the normal X button, you can do that as well. The OnViewerEvent "destroy" event will be called any time a viewer is closed.

That is a nice idea Leo and one I have been trying for several hours to bring off.

The script I have created in the scripts directory so far reads:

option explicit

' ViewerClose
' (c) 2019 Rodger

' This is a script for Directory Opus.
' See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.



' Called by Directory Opus to initialize the script
Function OnInit(initData)
	initData.name = "ViewerClose"
	initData.version = "1.0"
	initData.copyright = "(c) 2019 Rodger"
'	initData.url = "https://resource.dopus.com/viewforum.php?f=35"
	initData.desc = ""
	initData.default_enable = true
	initData.min_version = "12.0"
End Function

' Called when an event takes place in the standalone viewer
Function OnViewerEvent(viewerEventData)

End Function

Then I am stuck. How do I tell if the closeviewer event has been triggered so that I can put in my code?

Function OnViewerEvent(viewerEventData)
    if viewerEventData.event = "destroy" then
        ' viewer has been destroyed
    end if
End Function

Thanks Jon, but that was the first thing I tried and nothing at all happens.

This is the whole script, now:

option explicit

' ViewerClose
' (c) 2019 Rodger

' This is a script for Directory Opus.
' See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.



' Called by Directory Opus to initialize the script
Function OnInit(initData)
	initData.name = "ViewerClose"
	initData.version = "1.0"
	initData.copyright = "(c) 2019 Rodger"
'	initData.url = "https://resource.dopus.com/viewforum.php?f=35"
	initData.desc = "Restire Lister to previous size"
	initData.default_enable = true
	initData.min_version = "12.0"
End Function

' Called when an event takes place in the standalone viewer
Function OnViewerEvent(viewerEventData)
    if viewerEventData.event = "destroy" then
' viewer has been destroyed
	ClickData.Func.Command.AddLine("Set LISTERSIZE=2800,1786")
	ClickData.Func.Command.AddLine("Set LISTERPOS=100,10")
	ClickData.Func.command.Run
    end if
End Function

When I run a very similar script on a button on the viewer toolbar, the lister on screen is re-sized. However when I call this script by clicking on the "X" in the viewer window, nothing happens. Am missing something obvious?

Where's the ClickData object coming from in that instance?

That's a good question. What should I be using?

There's an example here: Viewer Select - Make file display track standalone viewer

What should I be using?

Instead of ClickData.Func.Command you need to generate your own object with DOpus.Create.Command.

You also need to tell the created object which tab/lister to use. The script I linked shows how.

I am way outside my vb comfort zone here and I really do appreciate you guys taking the time to help a slow coach like me. This is what I have now:

option explicit

' ViewerClose
' (c) 2019 Rodger

' This is a script for Directory Opus.
' See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.



' Called by Directory Opus to initialize the script
Function OnInit(initData)
	initData.name = "ViewerClose"
	initData.version = "1.0"
	initData.copyright = "(c) 2019 Rodger"
'	initData.url = "https://resource.dopus.com/viewforum.php?f=35"
	initData.desc = "Restire Lister to previous size"
	initData.default_enable = true
	initData.min_version = "12.0"
End Function

' Called when an event takes place in the standalone viewer
Function OnViewerEvent(viewerEventData)
    if viewerEventData.event = "destroy" then
' viewer has been destroyed

set cmd = DOpus.Create.Command()
cmd.SetSourceTab(tab)
cmd.AddLine ("Set LISTERSIZE=2800,1786")
cmd.AddLine ("Set LISTERPOS=100,10")
cmd.Run
    end if
End Function

Still it does nothing.

Try this

Function OnViewerEvent(viewerEventData)
    Dim cmd
    if viewerEventData.event = "destroy" then
        set cmd = DOpus.Create.Command()
        cmd.SetSourceTab viewerEventData.viewer.parenttab
        cmd.AddLine "Set LISTERSIZE=2800,1786"
        cmd.AddLine "Set LISTERPOS=100,10"
        cmd.Run
    end if
End Function

@Ixp

That works a treat. Many thanks for your help. I will now study your code, the better to understand it.

The lesson to take away from this is you can't just invent objects out of the air and expect them to work :slight_smile:

An object lesson, indeed!

Thanks to all who helped. I have learned much. :slightly_smiling_face: