DestroyControl (Form)

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

Moderators: Gurus, Addon Administrators

Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Re: DestroyControl (Form)

Post by Teknojnky »

MoDementia wrote:This only works if you use OnClickFunc for buttons Onclick Events produce errors
as there is no OnClickFunc for OnClose Form using the "X" produces errors :(

Back to Jiri :( :x :cry:
To get button onclick events to work, you must use

Code: Select all

    Script.RegisterEvent btnDoIt.Common, "OnClick", "DoIt"
Now I have another problem which I suspect has something to do with showmodal:


I am creating a form with some controls on it, with an OK and (hidden) cancel button.

When I click escape, the cancel event fires but does not close the form. When I use the X on the dialog to close, it fires the cancel event and closes the form.

pseudocode

Code: Select all

Sub Start()
  Set MainForm = SDB.UI.NewForm
    Script.RegisterEvent MainForm, "OnClose", "CloseMe"

  Dim btnClose
  Set btnClose = SDB.UI.NewButton(MainForm)
    btnClose.Cancel = True
    btnClose.Common.SetRect 0,0,0,0
    Script.RegisterEvent btnClose.Common, "OnClick", "CloseMe"

  MainForm.ShowModal
  SDB.Objects("SimpleAppend") = MainForm

End Sub

Sub CloseMe(obj)
  msgbox("Closing")
  Script.UnregisterAllEvents
  Set SDB.Objects("SimpleAppend") = Nothing
End Sub
Escape/cancel does fire the event, but the form remains visible.

If I change to

Code: Select all

  SDB.Objects("SimpleAppend") = MainForm
  SDB.Objects("SimpleAppend").Common.Visible = True
Then the form disappears with escape/cancel.

Is there a problem with form.showmodal or am I not doing something I should be?

edit:

I think I figured it out after studying bex's example more. But apparently you can not close a modal dialog by setting the object to nothing like you can with a normal form.
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: DestroyControl (Form)

Post by raybeau528 »

Modementia,

Would it help to just set those controls to visible/invisible as you need them rather than recreating new forms/controls ? Or you could have 1 form and multiple panels where each panel had the pre-configured controls, the panels could overlay each other, and just set the appropriate panel to visible and all others invisible. Just a thought.

Ray
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: DestroyControl (Form)

Post by Bex »

Teknojnky wrote:
I think I figured it out after studying bex's example more. But apparently you can not close a modal dialog by setting the object to nothing like you can with a normal form.
That's because X:ing down the form has the modalresult=2. For that reason only I recommend all to always use modalresults in all their forms and give the Cancel button the modalresult=2, then Cancel and X:ing always do the same thing.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: DestroyControl (Form)

Post by MoDementia »

raybeau528 wrote:Modementia,

Would it help to just set those controls to visible/invisible as you need them rather than recreating new forms/controls ? Or you could have 1 form and multiple panels where each panel had the pre-configured controls, the panels could overlay each other, and just set the appropriate panel to visible and all others invisible. Just a thought.

Ray
Hi,

I think the original script this relates to is a form that has the selected tracks listed with radio buttons next to them so the form was never the same so this sort of work around was never possible :(
I have used the vis/invis method in Custom Properties Panel it does work quite well
And I'm sure I have another script that calls either 1 or the other form based on criteria :)
Post Reply