Skip to content

Extending Control Features on Windows

Recently an issue with our Windows MoviePlayer was brought to my attention. Specifically, it was a problem with our Looping feature when using the native player. The bug was unfortunate, but luckily there was a workaround. However, it required a less often used feature of the MoviePlayer control, the MovieController.

When we design a control, whether it’s a PushButton or MoviePlayer, we try to anticipate the most often used features and add them into our product. However, we understand that there are occasions when a certain feature is needed that we may not have exposed. For this purpose we’ve added Handle properties on almost every control. You can use this Handle property, with the right Declare, to access additional features of that control. In some cases though, at least on Windows, a bare bones Handle wouldn’t be enough. In the Windows world our Handle refers to the HWND of the control. In most cases this would be enough, however, we do have a few controls which are ActiveX based. Currently, the native HTMLViewer and MoviePlayer are one of these few ActiveX based controls.

When we’re dealing with ActiveX controls, a simple Handle (i.e. HWND) only describes its container, and there’s very little you can do with that via Declares. To do anything useful with the ActiveX control you would need to tap into the right interfaces to control it. Thankfully you can via OLEObject automation, which is exposed as a property on the MoviePlayer control. Using OLEObjects is an entirely different topic, but think of this class as your interface into the ActiveX control. So for example, to enable the Looping property on the MoviePlayer control, one would add this line of code in the Open event:

MoviePlayer1.MovieController.Settings.SetMode("loop", 1)

All this may seem magical, so let’s look at this piece by piece. First, MoviePlayer1.MovieController returns an OLEObject. This OLEObject interfaces with the MoviePlayer ActiveX control. So how do you know what properties or methods you can access? This is a good question, if you look at our MoviePlayer.MovieController documentation page, you’ll find a link to what ActiveX control this refers to, along with its documented properties, and methods. For reference, here’s the link: https://msdn.microsoft.com/en-us/library/windows/desktop/dd563945(v=vs.85).aspx

If you look at that page, you’ll see a Settings object (click on it), and in the subsequent Settings Object page you’ll see a SetMode method. Clicking on SetMode then describes what parameters that method takes, and this is how the source line above was put together.

In conclusion, even though Xojo exposes the most common and useful elements of a control, it would not be feasible to expose every single feature. Our aim is to be as cross compatible as possible, but we also understand this may limit people, so we’ve exposed the necessary Handles, and in this particular case OLE objects, that we can for you to be able to extend the feature set, as necessary, for your application needs.

Xojo WIndows