Using displayIt instead of dialog
Forums
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
HI Robert, well there are
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
Hi Robert, from your code
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.