Print Page | Close Window

Cancel TaskDialog

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=16815
Printed Date: 23 November 2024 at 11:55am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Cancel TaskDialog
Posted By: corpcon
Subject: Cancel TaskDialog
Date 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



Replies:
Posted By: SuperMario
Date Posted: 11 June 2010 at 1:02pm
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).


Posted By: corpcon
Date Posted: 11 June 2010 at 1:09pm
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


Posted By: SuperMario
Date Posted: 11 June 2010 at 1:12pm
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


Posted By: corpcon
Date Posted: 11 June 2010 at 3:17pm

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


Posted By: corpcon
Date Posted: 11 June 2010 at 3:50pm

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


Posted By: corpcon
Date Posted: 16 June 2010 at 12:38am

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


Posted By: Oleg
Date Posted: 16 June 2010 at 8:50am
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net