Scripting Image Buttons

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

Moderators: Gurus, Addon Administrators

johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Scripting Image Buttons

Post by johnw3600 »

Hi again,

So, I've got going in creating a kind of Big Button interface when using MM with Magic Nodes as a Jukebox for playing our huge studio CD collection on a Carillon rackmount PC with an ELO Touchscreen! As soon as you start using a touchscreen you see the need for a big button affair, as fingers are too clumsy even at 800x600 res.

But how do I script buttons (or forms or panels or anything) to have an image surface?
Is this only by adding the images to several instances of some new button class in the Theme definition of a 'Skin', and instantiating this class from within my Auto Script?
This is starting to look complex! Are there any examples I can crib?

In short, can I not define and new button in my Auto Script and just give it an image property???

Regards,
John
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Re: Scripting Image Buttons

Post by rovingcowboy »

adding buttons to the player is done in the skinning theme engine.

just what buttons you talking about i'm not sure but the ones in the button container i think can be made larger by making the window header larger then making the container larger then make the buttons larger they are all coded in the theme engines right column code for each single object.

you dont really have to make a larger button image just an image that looks good when stretched. then you set both the border and the image codes to stretch the image. this will of course only work when you use the code in the ini file for the player. but i think it works automaticly with the buttons on the window's headers.

but as you can guess making the headers bigger will take up more of your screen space so this should only be done in skins that have been made for use only on huge screens.

is that of any help to you.
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Re: Scripting Image Buttons

Post by johnw3600 »

Thanks for the reply. It goes someway towards resolving my problem by confirming that I can only put an image on a button face by Skinning. So I presume there is no vbscript object whereby I can go...

Set obj = SDB.UI.NewObject(panel)
obj.Image.src = "C:\Program Files\MediaMonkey\Images\myimage.jpg"

(or anything similar!)
So I have to work on skins, right?

But I do not want all the required Buttons to have one generic face, instead I want to use buttons as if they were large Toolbar icons, but not on a menu or toolbar - and certainly without enlarging the existing menu bars or Tree text or toolbars.
Instead the plan is to have a dockable panel (actually more than one eventually) with several large buttons on the panel, each with its registered OnClick function.

Now, I'm working (or walking) my way through your 'Fast Newbie's Skinning Walkthrough' [thanks hugely] and I see how to edit images, such as the Face of a general button. I see that you can create new Objects within ThemeEditor, and I can see that some objects are referenced in the .ini files of the skin. But, I am puzzled, and left with questions...

1. Does simply creating an object in ThemeEditor, bundling that in the skin, and referencing it in the .ini, register the object in MM when that skin is applied, so that you can Instantiate that object type in an Auto Script?

2. Is so, how do you instantiate the new object?

3. Do you use ActiveBitmap objects for this?

4. Does this mean that there is no way of creating new buttons on the fly in an Auto Script, using a 'Buttons' table added to the MM.DB database that has the path & filename of the button image, so that more can be added?

5. Is the spelling of Transparent ('Tranperent') in the MM_Ultimate skin's .ini files significant, or just a mistake left un-noticed?

Regards,
John

[Whoops! :oops: I've just found the wiki pages on ThemeEditor which again goes part-way to answering my questions, but I would still apreciate comments, as all five still need clarity. Cheers]
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Scripting Image Buttons

Post by ZvezdanD »

johnw3600 wrote:So I presume there is no vbscript object whereby I can go...

Set obj = SDB.UI.NewObject(panel)
obj.Image.src = "C:\Program Files\MediaMonkey\Images\myimage.jpg"
I asked MM developers so many times before for such thing, but without any response.

I think your only solution could be to use WebBrowser ActiveX. I have such thing with the Icon control in my RegExp Find and Replace script:

Code: Select all

Set wbIcon = SDB.UI.NewActiveX(frmDialog, "Shell.Explorer")
wbIcon.Interf.document.body.innerHTML = "<img src=""" & sIconFileName & """>"
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Re: Scripting Image Buttons

Post by rovingcowboy »

as i said i'm not sure if those were the buttons you wanted i was talking about.
it seems ZvezdanD has found your answer for you. as i see you mentioned auto scripts.
those are just scripts nothing to do with the skinning.
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Re: Scripting Image Buttons

Post by johnw3600 »

Thanks to both of you for replying, I guess it looks like ActiveX objects as ZvezdanD suggests, though I had not thought of considering webbrowser objects within the MM interface!

But, (regard me as a bit dense) are we saying that objects created in a skin cannot be referenced or used in a script??? Am I more confused still?


Regards.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Scripting Image Buttons

Post by trixmoto »

ZvezdanD wrote:I asked MM developers so many times before for such thing, but without any response.
Have you added this to Mantis? I know there are lots of new scripting features coming to MM4 (some of which I'm very excited about, cos I'm a geek!) but I don't know if this is one of them.
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.
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Scripting Image Buttons

Post by ZvezdanD »

Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Re: Scripting Image Buttons

Post by johnw3600 »

Sorry folks, but I still don't get it!

There is still something fundamental I can't get my head round!
Yes, I know understand that you can't create button objects (or the equivalent) and change their image source on the fly - unless you do something with ActiveX objects.

But surely, as I am now willing to settle for creating four new fixed button objects in ThemeEditor and fix a different image on each, I must then be able to get at them in Auto or Normal scripts from within MM. Otherwise how could you make a player interface that works???

Or are we saying that the only objects recognised in such scripts are those predefined in MM, not others defined in a skin??? If so what are the .ini files doing?

As for ActiveX I cannot make that work without a better tutorial or at least an Object Reference table. Is there more complete information anywhere??? All I have seen so far suggests that the ActiveX approach clunks!
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Scripting Image Buttons

Post by ZvezdanD »

johnw3600 wrote:Otherwise how could you make a player interface that works???

Or are we saying that the only objects recognised in such scripts are those predefined in MM
Forget about skinning, don't waste your time with it, that is the dead end. Buttons from the Player has nothing in common with the buttons from the scripts. MM API has just one button object that could be used in dockable panels: http://www.mediamonkey.com/wiki/index.php/SDBUIButton and that object doesn't support Image property.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Peke
Posts: 17457
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Scripting Image Buttons

Post by Peke »

Zvezdan you are right. No image Button.

I guess I was not sure how to understand http://www.ventismedia.com/mantis/view.php?id=6336 but now when you mentioned it along with http://www.mediamonkey.com/wiki/index.php/SDBUIButton looks more clear.

Can you write me a PM so that we can see how to make framework for it as Delphi itself do not have Picture button object that can be used but BitButton without caption and Icon can be possibly used to represent button.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Re: Scripting Image Buttons

Post by johnw3600 »

Thanks Zvezdan,

I simply had not grasped the import of a statement like:
Whether and how these skin objects are used totally depends on the implementation of the MediaMonkey Theme Engine
in the wiki under Theme Editor!

And Peke now I know you're coming from Delphi, I can see why buttons don't have an accessible Image property; at least TBitBtn objects have an accessible Glyph as well as Caption (either of which are then optional).

Ho Hum, It is ActiveX for now then!

John
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Scripting Image Buttons

Post by ZvezdanD »

Peke wrote:I guess I was not sure how to understand http://www.ventismedia.com/mantis/view.php?id=6336 but now when you mentioned it along with http://www.mediamonkey.com/wiki/index.php/SDBUIButton looks more clear.

Can you write me a PM so that we can see how to make framework for it as Delphi itself do not have Picture button object that can be used but BitButton without caption and Icon can be possibly used to represent button.
You are joking about Delphi lack of buttons with pictures, aren't you? I could send you my Delphi sources with a bunch of buttons with pictures. MediaMonkey itself has buttons with pictures in many places, e.g. up, down and delete buttons beneath of Options > Library > Filters & View or several buttons in the Track Properties dialog box. We don't need anything more then that, we need just same buttons as MediMonkey has.

By the way, here is a part of my old related message: Very serious problems with some scripting functions by ZvezdanD on Sun Dec 28, 2008 1:43 pm
"Listbox and Dropdown controls could have a property to assign icon/picture to every item in the list (something like Owner Draw Combo and List box controls in some languages). Buttons also could have a property to assign a icon/picture to them, with a possibility to decide if it should be displayed together with the caption or without it, and with the property to specify a relative position to caption - e.g. left to caption or above the caption."
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
johnw3600
Posts: 13
Joined: Thu Jul 22, 2010 2:44 pm

Re: Scripting Image Buttons

Post by johnw3600 »

Woh-hay!!!! :D :D :D

I now have my line of four lovely bright shiny image buttons, courtesy of ActiveX. Thanks Zvezdan, for forcing me to go there! These buttons aren't 'button objects' at all, they are just 4 HTML 'images' with OnClick events registered to each, all sitting in an ActiveX web browser object, which itself is in an oridinary vb panel.

They work beautifully, calling back to the vbscript on click.
I'm particularly pleased with...

Code: Select all

 html = ""
  for i = 1 to 4
  	style = "style='border:1px;width:48px;height:36px'"
  	html = html & "<img id='" & cap(i) & "' src='" & path & src(i) & "' " & style & " alt='" & cap(i) & "'>"
  next
  ax1.Interf.document.body.innerHTML = html
  for i = 1 to 4
    click = "ClickHandler_" & cap(i) 
    Script.RegisterEvent ax1.Interf.document.getElementByID(cap(i)), "OnClick", click
  next
[/color]
[Obviously the 'cap' and 'src' arrays and the ax1 object were defined higher up]

Later I will space the objects as I wish, with a table I expect so they float better if the dockable panel is stretched.

But I still have one question (aside from agreeing that you can do what the heck you like in Delphi so long as you accept that objects like TButton are a bit plain out-of-the-box)...

Q: How do I indentify the Sender of an OnClick event?
All four ClickHandler routines could be one, so long as I know the 'id' of the image object.

Thanks. John
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Scripting Image Buttons

Post by ZvezdanD »

johnw3600 wrote:Q: How do I indentify the Sender of an OnClick event?
All four ClickHandler routines could be one, so long as I know the 'id' of the image object.
I suppose that you need something like this:

Code: Select all

Select Case ax1.Interf.document.activeElement.ID
Case cap(1)
...
Case cap(2)
...
End Select
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Post Reply