Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 04:43:52 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Dialog box - which button pressed
Pages: 1   Go Down
Print
Author Topic: Dialog box - which button pressed  (Read 489 times)
0 Members and 1 Guest are viewing this topic.
tmead
Active Member

Offline Offline

Posts: 61


View Profile
« on: February 25, 2011, 12:11:14 PM »

I'm struggling a bit to try to get some code to update a userlabel. Seems there are a few ways of doing this. So far I've found:

Method 1
      Qty = GetUserLabel(61)
      Qty = Question("Enter Quantity of Line " & ThisPriority)
      SetUserLabel(61,Qty)

But there is no way to pick up the current value of the label to use as a default - means the user has to type new every time

Method 2
      Begin Dialog TextBoxSample 16,30,180,96,"Enter Required Quantity"
         OKButton 132,20,40,14
         CancelButton 132,44,40,14
         Text 8,8,32,8,"Text Box:"
         TextBox 8,20,100,12,.TextBox1
      End Dialog

           Dim Dlg1 As TextBoxSample
      Button = Dialog ( Dlg1 )
           
      SetUserLabel ( 61,Dlg1.TextBox1 )

Same problem - I can't figure a way to show the current value, and the user has to click into the field before entering data

Method 3
      Default = GetUserlabel(61)
      Answer = InputBox$("Enter data", "Title", Default, 200, 200)
      SetUserLabel(61,Answer)

Now this one I like - but i can't crack the last bit - how to not update anything when cancel is pressed ! At the moment the contents of the label are wiped if cancel is pressed, and I'd liek them to be left alone !

The Cypress Enable manual is full of detail about how to construct dialogs, but there is a level of assumed knowledge about what to do with the output that I simply don't have !

Tim
Logged
tmead
Active Member

Offline Offline

Posts: 61


View Profile
« Reply #1 on: February 27, 2011, 04:47:35 AM »

Blatant bump for the post !

Does anyone know how to determine which button was pressed in a dialog box ?

Tim
Logged
ger21
Global Moderator
*
Online Online

Posts: 2,619



View Profile WWW
« Reply #2 on: February 27, 2011, 08:35:39 AM »

Nt sure why the first one doesn't work, but what about this?

      Default = GetUserlabel(61)
      Answer = InputBox$("Enter data", "Title", Default, 200, 200)
      If Answer <> "" then SetUserLabel(61,Answer)
Logged

tmead
Active Member

Offline Offline

Posts: 61


View Profile
« Reply #3 on: February 27, 2011, 05:43:21 PM »

Thanks for that, I've just got to a similar result by discriminating between entered data and cancel by using len(answer)>0.

I can't helpfeeling there must be a way of checking which button was pressed, which may be more elegant. However, these ways work !

Help much appreciated.

Tim
Logged
stirling
Global Moderator
*
Offline Offline

Posts: 1,190

UK


View Profile WWW
« Reply #4 on: February 28, 2011, 04:33:08 AM »

Tim

Code:
     Begin Dialog TextBoxSample 16,30,180,96,"Enter Required Quantity"
         OKButton 132,20,40,14
         CancelButton 132,44,40,14
         Text 8,8,32,8,"Text Box:"
         TextBox 8,20,100,12,.TextBox1
      End Dialog

      Dim Dlg1 As TextBoxSample
      Dlg1.TextBox1="Hello world" 'default value
      Button = Dialog ( Dlg1 ) '-1 = ok, 0 = cancel

Ian
Logged
tmead
Active Member

Offline Offline

Posts: 61


View Profile
« Reply #5 on: February 28, 2011, 05:10:40 AM »

Ahh... thanks for that, I'd had a play with something similar, but did not get the syntax right.

I'm still in favour of the inputbox method, as I cannot get the DlgFocus command to allow direct entry into the box without having to click into it. The inputbox command does it for me !

Tim
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!