Resizing elements when parent dockable panel is resized

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

m42i
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Resizing elements when parent dockable panel is resized

Post by m42i »

I've got a persistent dockable panel with some elements inside. When I resize the panel those elements won't resize with them.

Here is my sample code. When I resize the PanelX, the ActiveX control inside won't resize with it.

https://dl.dropbox.com/u/344000/Demo.mmip

Code: Select all

' Demo file for resizing a persistent dockable panel
Const BTN_MARGIN = 5 ' Defines the standard margin between buttons
Const BTN_HEIGHT = 25 ' Defines standard height of a button
Const BTN_WIDTH = 80 ' Defines standard width of a button
Const TIME_WIDTH = 50 ' Defines standard width of a time label

Dim PanelX

Sub OnStartUp
    Call CreateMainPanel
End Sub

Sub DoClick
    SDB.MessageBox "Hello!", mtInformation, Array(mbOk)
End Sub

Sub CreateMainPanel
    Set UI = SDB.UI
    Set PanelX = UI.NewDockablePersistentPanel("PanelX")
    If PanelX.IsNew Then
        PanelX.DockedTo = 4 
    End If
    PanelX.ShowCaption = True
    PanelX.Common.Visible = True

    Set ButtonA = UI.NewButton(PanelX)
    Set SDB.Objects("ButtonA") = ButtonA
    ButtonA.Common.Visible = True
    ButtonA.Common.ControlName = "ButtonA"
    ButtonA.Caption = SDB.Localize("Play")
    ButtonA.Common.SetRect BTN_MARGIN, BTN_MARGIN, BTN_WIDTH, BTN_HEIGHT
    Script.RegisterEvent ButtonA, "OnClick", "DoClick"

    Set WebPanel = UI.NewActiveX(PanelX, "Shell.Explorer")
    Set SDB.Objects("WebPanel") = WebPanel
    WebPanel.Common.Visible = True
    WebPanel.Common.ControlName = "WebPanel"
    WebPanel.Common.Align = 0
    WebPanel.Interf.Navigate "about:" ' A trick to make sure document exists, from Wiki
    WebPanel.Common.SetClientRect BTN_MARGIN, 2*BTN_MARGIN + BTN_HEIGHT, _
        PanelX.Common.Width - 3*BTN_MARGIN, _
        PanelX.Common.Height - 4*BTN_MARGIN - 2*BTN_HEIGHT
End Sub

Sub Uninstall
    PanelX.Common.Visible = False
    Set PanelX = Nothing
    Set SDB.Objects("PanelX") = Nothing
    Script.UnRegisterEvents SDB
End Sub
m42i
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Re: Resizing elements when parent dockable panel is resized

Post by m42i »

One possibility that occurred to me is, to make a new RedrawTimer, that will refresh the size of all elements every second or so. But I'd hope for a more elegant way to do this.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Resizing elements when parent dockable panel is resized

Post by trixmoto »

Take a look at my BatchArtFinder script, this has a similar layout. The ActiveX is set to align 5 and there's then a panel which is set to align 2 (although that's bottom and I think you want top) and then any buttons go on the panel.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
m42i
Posts: 9
Joined: Wed Apr 03, 2013 7:13 am

Re: Resizing elements when parent dockable panel is resized

Post by m42i »

Ok, I found my mistake. I thought the names in parenthesis in the wiki were constants. After defining them, it works fine. :)
Post Reply