Skip to main content

Using displayIt instead of dialog

I'am trying to understand how to work with the function displayIt and the select case Action% and select case ControlId$. But i can't get it working on a simple script, what do i wrong? :
-----------------------------------------------------------------
Begin Dialog MainMenu 50,50,150,150,"NewDialog", .NewDialog
  CancelButton 93,109,40,15, "Cancel", .CancelButton1
  OKButton 9,110,40,14, "OK", .OKButton1
  PushButton 66,20,40,14, "Get File", .PushButton1
End Dialog
Option Explicit
 
Dim Exit_Script As Boolean
 
Sub Main
 
Call MainMenu1()
 
End Sub
 
Function MainMenu1()
 
Dim dlg As MainMenu
Dim button As Integer
button = Dialog(dlg)
 
End Function
 
Function displayIt(ControlID$, Action%, SuppValue%)
Dim Exit_Function_DisplayIt As Boolean
 
Select Case Action%
 
Case 1
 
Case 2
 
Select Case ControlId$
 
Case "CancelButton1"
MsgBox "Cancel"
 
Case "OKButton1"
MsgBox "Ok"
 
Case"PushButton1"
MsgBox "Select File"
 
End Select
 
End Select
 
If Exit_Function_DisplayIt Then
displayIt = 0
Else 
displayIt = 1
End If
 
End Function
 

Brian Element Tue, 08/21/2018 - 09:08

Hi Robert, from your code your dialog function is still called NewDialog and that is why it is not working.  In the dialog view click on your dialog and at the bottom you will see an Function option, change it to DisplayIt.  So what happens is that everytime you open that dialog or make any changes to it it will run the DisplayIt function which allows you to do different things depending on what is happening within the dialog.

Robert van den… Tue, 08/21/2018 - 11:05

But what is the advantage for using the displayit function with action or controlid cases versus the menu function with button cases?

Brian Element Tue, 08/21/2018 - 11:18

HI Robert, well there are quite a few pluses on using the function.  Probably the greatest is that you can make changes to your dialog without it closing.  I am assuming now you are not using the function so every time you hit a button the dialog closes and then it reopens, this is especially annoying if the user has moved the dialog to a different place and then it reopens it in the original place. 

You can also have multiple dialogs open at the same time.

You have access to the following functions - DlgEnable, DlgFocus, DlgListBoxArray, DlgSetPicture, DlgText, DlgVisible.

You can reference buttons by their actual name such as PushButton1 instead of what is returned from the dialog which is based on the order the buttons are added to the dialog, so PuchButton1, could be number 1, 2, 3, etc.

There are lots of benefits to doing it this way and all my dialogs now are done this way, my older ones didn't because at that time I didn't know how to use them and there is not much documentation on them. 

I am actually doing a session at the IDEA Users Conference in September on this topic (https://www.audimation.com/IDEA-Innovations-2018/session-descriptions#BE) and after I will create a video on the subject to share with everyone.

Brian

 

Robert van den… Thu, 08/23/2018 - 03:05

In reply to by Brian Element

when i run the script the first error i get it that function getDbname is not present when i add that i get an error at line 512 - subscript out of range. What does this error means?
 

Brian Element Thu, 08/23/2018 - 07:29

In reply to by Robert van den…

On line 512 change to the following and it should work:

For i = 0 To UBound(tempListBox2$)
    task.AddFieldToInc tempListBox2$(i)
   Next i

I hadn't tested the rest of the script only the dialog portion but I was able to run it with no errors.

The website encountered an unexpected error. Try again later.