Random Musings from the Intellectually Gifted. How's that for no ego? :pfft
I'm having a brain fart. Any help would be appreciated.

So, I'm working on my first "Skinnable" Widget/Gadget which uses the ImageMagick Com object
to create a reflective PNG. This came about after a request over at Aqua-soft.

My goal is to populate a portion of the right click menu with a list of the skins. At the moment
I'm using a Subfolder Collection to pull all of the Ini file's. Has anyone got an idea on how to
dynamically populate the right click menu with the names & calls?



Comments (Page 2)
3 Pages1 2 3 
on Jul 31, 2007

It could easily be setup to read the entire ini and all info at startup (or at a set interval in case of updates). Then read that into the menu.


Yeah, that's what I was doing. I just wondered if there were any benefits to retreiving the info on r-click instead. This is the r-click code I used for it:

Code: vbscript
  1. Function PopupMenu()
  2. Dim submenu
  3. Set mainmenu = nothing
  4. Set mainmenu = DesktopX.CreatePopupMenu '-- Create Main Menu
  5. Set submenu = DesktopX.CreatePopupMenu
  6. mainmenu.AppendMenu 0, 1, "Save Skin"
  7. mainmenu.AppendMenu &H00000010, submenu.MenuID, "Load Skin"
  8. mainmenu.AppendMenu &H00000800, 9998, ""
  9. mainmenu.AppendMenu 0, 2, "Minimize to Tray"
  10. mainmenu.AppendMenu 0, 3, "Close"
  11. mainmenu.AppendMenu &H00000800, 9999, ""
  12. mainmenu.AppendMenu 0, 4, "Preference"
  13. mainmenu.AppendMenu 0, 5, "About"
  14. 'Skins submenu
  15. For x = 0 To skincount
  16. submenu.AppendMenu 0, x+5, skinArr(x)
  17. Next
  18. '-- Save the results of mouse movements
  19. result = mainmenu.TrackPopupMenu(0, System.CursorX, System.CursorY)
  20. Select Case result
  21. Case 1
  22. savePrompt
  23. Case 2
  24. widget.Minimize
  25. Case 3
  26. widget.Close
  27. Case 4
  28. widget.OpenProperties
  29. Case 5
  30. msgbox "My about box"
  31. End Select
  32. If result > 5 Then
  33. selectskin = skinArr(result-6)
  34. Call loadSkin(2, selectskin)
  35. End If
  36. End Function


loadSkin is the sub that retrieves all the info (current skin, skin titles) on startup and when the user loads a skin.
on Jul 31, 2007
Actually, I did put it into a sub.

Not only is it easier you'll find it runs up the RAM if you put it into the right click since it calls the code every time you initiate the right click menu.

RomanDA, that's a great idea. It also is probably easier on resources & maybe less likely to break the code with repeated FSO calls?

I've created one little glitch. If you click the right click menu then don't click a menu item (ie. close the menu) for some reason it automatically calls/applies the first skin in the list. Haven't given much work into this but, I'm wondering if it's not related to the fact that I've made the For Next statement's zero based?
on Jul 31, 2007
sViz, your code always looks so clean.

I feel embarrassed to show mine.
on Jul 31, 2007
Thanks, SirS. I get all confused if I don't format my codes and comment the heck out of them.

I feel embarrassed to show mine.


But, but, if you don't, then who will I snag all these useful codes snippets from?! I always learn something new from studying your scripts.


If you click the right click menu then don't click a menu item (ie. close the menu) for some reason it automatically calls/applies the first skin in the list.


What about using Case Else? Like:

Case Else
object.state = object.state

I used that once when I was having trouble with closing the menu.



on Jul 31, 2007
Thanks sViz.
But, but, if you don't, then who will I snag all these useful codes snippets from?! I always learn something new from studying your scripts.


I find the same from your. Your Script Helper saves me a great deal of time.

on Jul 31, 2007
this looks good.. i was going to say the issue is a
CASE ELSE as well.
good one!
on Jul 31, 2007
Wouldn't that be essentially the same as an IF THEN ELSE statement? Because that didn't work...and apparently neither does the CASE ELSE.

I'm thinking it's most likely using the zero based array? Even though there's nothing specific in the DX documentation most likely zero is a default? So, I'll work on adjusting my arrays accordingly.
on Jul 31, 2007
That was it or a combination of it with the CASE ELSE.

So class the lesson for the day is, when dynamically creating a right click menu one can't use a zero based array!

Thanks a lot for all the help guys.
on Jul 31, 2007
So class the lesson for the day is, when dynamically creating a right click menu one can't use a zero based array!


   Glad to hear you worked it out. I'll certainly keep this in mind in future.
on Aug 03, 2007
YEAH!
on Aug 03, 2007
Okay, the gadget is up at deviantart iReflector.

on Aug 03, 2007
I'm having some probs.

"Drag'n'drop ImageMagickObject.dll onto RegSvr to register the com object"

I did and I got this error: LoadLibrary("C:\Documents")failed - The specified module could not be found

Then when I drag and drop a PNG image onto the first spot of the widget I get an error saying something went wrong and the widget only accepts images by drag and drop.


What do I do now?
on Aug 03, 2007
Try installing the com object from the right click menu. Or drag it onto the regsvr2.vbs file. Or drop it on the regsvr.exe file. If there isn't a right click menu option to install it then you need the newer version.

I'm going to check dA to see if they screwed up my last update.
on Aug 03, 2007
The r-click menu option worked, but I still get an error when I drop an image onto the widget.

Something went wrong. This will only accept images as drag and drop files. I'll try to continue through.
Detail: Object required.


on Aug 03, 2007
I just downloaded it from dA, removed all my versions of the com object & cleaned my temp directory and it installed without a hitch on XP Pro Sp2. All the right click does is call the regsvr (Using the DesktopX.ExecutableDirectory) passes the object to it and registers/unregisters it.
3 Pages1 2 3