Cancel TaskDialog |
Post Reply |
Author | |
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
Posted: 11 June 2010 at 12:41pm |
How do you determine if the Cancel button was clicked in the TaskDialog?
I assume it has something to do with the ButtonClicked event, but I don't understand how to implement what is described in the Help. And I couldn't find anything in the samples.
|
|
Xtreme SuitePro 13.2.1
Win7 VB 6 - SP6 |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Do you mean the CommonButtons? If so, then the ID of the button in ButtonClicked event will be a value from the TaskDialogCommonButtons enum, in this case xtpTaskButtonCancel (8).
|
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
I don't understand how to access the buttonclicked event. Can you give me a VB 6 code example?
|
|
Xtreme SuitePro 13.2.1
Win7 VB 6 - SP6 |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Private Sub taskDialog_ButtonClicked(ByVal id As Long, CloseDialog As Variant)
On Error Resume Next Select Case id Case xtpTaskButtonCancel: Debug.Print "cancel button clicked" Case Else: CloseDialog = True End Select End Sub |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
Perhaps I was likely too vague. Allow me to elaborate. I use the TaskDialog for various purposes on a single form. Consequently, I can't have in-line code in the ButtonClicked event. But I need to access the result of which button was clicked. Therefore, I have the following type of code...start procedure that does stuff...
Dim vRC as variant ' Return result from task dialog
blah
blah
blah
' Get a needed value
vRC = task_vInputBox(Me, TaskDialog1, sTitle, sHeading, sDescription, "", "", "", sIconPath) ' Set properties and open (.ShowDialog)
' Deal with returned value
blah
blah
blah
end of procedure ' The result assigned to vRC obviously comes from .InputBoxText (which is currently part of the task_vInputBox function) - but what if the Cancel button was clicked?
Instead of retrieving the value from my function call, I tried assigning the result of the .InputBoxText (unless Cancel was clicked) by using a public variable in the ButtonClicked event, to see if that would address my problem. However, that didn't work because the ButtonClicked event wasn't firing. I don't know why.
|
|
Xtreme SuitePro 13.2.1
Win7 VB 6 - SP6 |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
Clarification... The ButtonClicked event DOES fire (sorry). However, it only fires once. If I don't receive an appropriate value, the code loops to re-open TaskDialog1 (I test vRC and, if needed, loop back to task_vInputBox). When it loops, the ButtonClicked event no longer fires. I have to exit the procedure to get it to fire again (which is impractical).
I tried using Reset after retrieving the result, but that didn't work. Is there some other way to essentially set the control to nothing - or whatever needs to be done so that it works correctly?
|
|
Xtreme SuitePro 13.2.1
Win7 VB 6 - SP6 |
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
Since I haven't had a reply about the recent issue, I'm guessing this is a bug. I'll rephrase it... When I call the TaskDialog more than once from within the same procedure*, the ButtonClicked event only fires the first time.
I've used reset, and set the Cancel to true after the call. It doesn't change anything.
* it's in a loop, waiting for a valid response
|
|
Xtreme SuitePro 13.2.1
Win7 VB 6 - SP6 |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
I not sure what exactly I need to do to reproduce it, but such code works for me - I see 2 Debug outputs:
Private Sub Command1_Click() TaskDialog1.AddButton "Test", 1 TaskDialog1.ShowDialog TaskDialog1.Reset TaskDialog1.AddButton "Test", 1 TaskDialog1.ShowDialog End Sub Private Sub TaskDialog1_ButtonClicked(ByVal Id As Long, CloseDialog As Variant) Debug.Print "TaskDialog1_ButtonClicked" End Sub |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |