Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Cancel TaskDialog
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Cancel TaskDialog

 Post Reply Post Reply
Author
Message
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post Topic: Cancel TaskDialog
    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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.