Morning,
I find how display a text variable ex :
TextBox 5,5, 220,12, .Message1
Where .Message1 is a variable text
And second question : How display the name of Dialog Box (in a same Begin Dialog) with a text variable ex:
#Rumba
Hi ,
not sure if fully understand what you are trying to achieve.
Can share a code snippet and explain your problem a bit more in detail ?
In Rumba Script you can use the Dialog Class. (Start the Script Editor, click Assist . Under Command Class select : Dialog)
The Assistant shows available commands and code samples.
I Want :
1) Display a message variable in Dialog Box : OK I found
2) Display the name of Dialog Box with variable text (cf printscreen). I don't use Class Dialog (DlgStart...) because impossible to position controls. I use Begin Dialog Dlg1 60 , 70 , 230 , 180, "Test", .DlgFonction. But i want replace "Test" by a text variable same it's possible with DlgTitle in DlgStart.
Ps : I use RUMBA 7.30 SP0 Correctif0 and i can't upgrade.
Thanks for your answer. But, if you add a GoupBox in Dialog this does not work anymore :
Begin Dialog myDialog 1 , 1 , 186 , 92 , HelloMsg, .MainDialogProc
GroupBox 12, 28, 62, 57, "Fichier"
OkButton 130, 6, 50, 14, .OkButton
CancelButton 130, 23, 50, 14, .CancelButton
End Dialog
Have you a solution ?
Salut Patrick,
indeed, that is a little strange and surprising. There appears to be an easy workaround and it is to put the button controls first when defining the Dialog.
e.g.
Sub Main
HelloMsg = "My Title String"
Begin Dialog myDialog 107,139,419,194, "My Window", .MainDialogProc
OKButton 28,68,40,14, .OkButton
CancelButton 120,68,40,14, .CancelButton
GroupBox 12,8,72,52,"GroupBox1"
GroupBox 100,8,72,52,"GroupBox2"
OptionGroup .OptionGroup1
OptionButton 16,24,54,8,"OptionButton",.OptionButton1
OptionButton 16,40,54,8,"OptionButton",.OptionButton2
CheckBox 108,24,45,8,"CheckBox",.CheckBox1
CheckBox 108,40,45,8,"CheckBox",.CheckBox2
End Dialog
Dim MyDlg as myDialog
RetC = Dialog(MyDlg)
End Sub
Function MainDialogProc(id$, action%, suppvalue&)
Dim hWnd As Long, x As Long, ForegroundSessionName As String
Select Case action%
Case 1 'Initialize dialog controls
'Return to main dialog
MainDialogProc = TRUE
Case 2 'One of the buttons or checkboxes was pressed
Select Case id$
Case "OptionButton1"
HelloMsg = "OptionButton1"
SetTitleString HelloMsg
Case "OptionButton2"
HelloMsg = "OptionButton2"
SetTitleString HelloMsg
Case "CheckBox1"
HelloMsg = "CheckBox1"
SetTitleString HelloMsg
Case "CheckBox2"
HelloMsg = "CheckBox2"
SetTitleString HelloMsg
Case "OkButton"
'Return to main dialog
MainDialogProc = TRUE
MsgBox "You pressed OK"
Case "CancelButton"
MainDialogProc = FALSE
MsgBox "You pressed Cancel"
Case Else
MainDialogProc = FALSE
End Select
Case 3 'Text or combo box changed
'Return to main dialog
MainDialogProc = TRUE
Case 4 'Control focus changed
SetTitleString HelloMsg
hWnd = GetForegroundWindow
If hWnd > 0 Then
x = SetWindowText(hwnd, HelloMsg)
End If
'Return to main dialog
MainDialogProc = TRUE
Case 5 'Idle - use this case to update from events on the host (if any)
'Return to main dialog
MainDialogProc = TRUE
End Select
End Function
Sub SetTitleString(HelloMsg as String)
hWnd = GetForegroundWindow
If hWnd > 0 Then
x = SetWindowText(hwnd, HelloMsg)
End If
End Sub
The above works for me.
You mentioned that you are using Rumba 7.3. Unfortunately that version is quite old and has not been supported for several years. It was never tested on any currently supported version of MS Windows and does not support secure connection (i.e. current revs of secure protocols, TLS1.2, SSH SHA-2 certificates etc.). You should really consider moving to a current version or at minimum testing the current version to ensure it does everything you need, just in case 7.3 stops working overnight or some regulatory mandate forces you to securely encrypt your datastream.
Tom
For the 'Case 4" it's useful if multi-use. But your first code without sub program, enought me.
Again geat thank for your help .
For other person below my code (anonymized) for my dailogue Box :
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Option explicit
Const ES_MULTILINE = &h0004&
Const ES_WANTRETURN = &h1000&
Const ES_READONLY = &h0800&
Const ES_CENTER = &h0001&
Global HelloMsg as String
Dim Message As String, Titre As String, Appli As String, Membre As String
Dim PremierMembre As Integer, Fichier As Integer, BibOrig As Integer, TypeFichier As Integer, Retour As Integer
Sub Main
Message = "Ici essai de message variable"
Titre = "Titre variable ici"
Membre = "ABCDEFGHIJK"
Appli = "Test final"
PremierMembre = 1
TypeFichier = 2
BibOrig = 2
Call DlgDébut(Titre, Message, TypeFichier, Membre, Appli, BibOrig, PremierMembre)
End Sub
Sub DlgDébut(Titre, Message, TypeFichier, Membre, Appli, BibOrig, PremierMembre)
Dim Fichier As Integer, Bib(6) As String
Bib(0) = "AAAAA"
Bib(1) = "SSSSS"
Bib(2) = "MMMMM"
Bib(3) = "GGGGGGG"
Bib(4) = "MMMM"
Bib(5) = "OOOOOOO"
Bib(6) = "CCCCCCCC"
Begin Dialog MyDialog 60, 70, 230, 180, Titre, .DlgFonction
Text 5,5, 220,12, "", .DlgMessage, ES_CENTER
CancelButton 65, 155, 40, 12
OKButton 120, 155, 40, 12
GroupBox 12, 28, 62, 57, "Fichier"
OptionGroup .DlgFichier
OptionButton 19, 38, 47, 12, "xxxx1"
OptionButton 19, 48, 47, 12, "xxxx2"
OptionButton 19, 58, 47, 12, "xxxx3"
OptionButton 19, 68, 47, 12, "xxxx4"
Text 113, 20, 55, 30,"Bib d'origine :"
ListBox 110, 30, 55, 60, Bib() , .DlgBibOrig
Text 12, 105, 35, 12,"Membre :"
TextBox 46, 104, 70, 12, .DlgMembre
CheckBox 120, 104, 10, 12, "", .DlgPremier
Text 130, 102, 95, 22,"Si coché : Prendre le 1er "
Text 12, 131, 35, 12,"Appli :"
TextBox 46, 130, 120, 12, .DlgAppli
End Dialog
Dim Dlg_Var As MyDialog
Dlg_Var.DlgFichier = TypeFichier
Dlg_Var.DlgPremier = PremierMembre
Dlg_Var.DlgBibOrig = BibOrig
Dlg_Var.DlgAppli = Appli
Dlg_Var.DlgMembre = Membre
Retour = Dialog(Dlg_Var)
If Retour = -1 Then
MsgBox "Membre : " & Dlg_Var.DlgMembre
MsgBox "Fichier : " & Dlg_Var.DlgFichier
MsgBox "Pemier : " & Dlg_Var.DlgPremier
MsgBox "BibOrig : " & Dlg_Var.DlgBibOrig
MsgBox "Appli : " & Dlg_Var.DlgAppli
End
End If
End Sub
Function DlgFonction(ControlID$, Action%, SuppValue&)
Dim hWnd As Long, x As Long', ForegroundSessionName As String
Select Case Action%
Case 1 'Initialise les controls de la boite de dialogue
DlgText "DlgMessage", Message
If PremierMembre = 1 Then
DlgEnable "DlgMembre" ,0
Else
DlgEnable "DlgMembre" ,1
End If
Case 2 'Un des boutons ou case à cocher ont été utilisés
Select Case ControlID$
Case "DlgPremier"
Select Case SuppValue
Case 1
DlgEnable "DlgMembre" ,0
Case Else
DlgEnable "DlgMembre" ,1
End Select
End Select
' MainDialogProc = TRUE
Case 3 'Text or combo box changed
Select Case ControlID$
Case "DlgMembre"
If Len(SuppValue) > 10 Then
MsgBox "NON"
End If
End Select
'Return to main dialog
'MainDialogProc = TRUE
Case 4 'Control focus changed
hWnd = GetForegroundWindow()
If hWnd > 0 Then
x = SetWindowText(hwnd, Titre)
End If
' MainDialogProc = TRUE
Case 5 'Idle - use this case to update from events on the host (if any)
'Return to main dialog
' MainDialogProc = TRUE
End Select
End Function
Not Work currently in Dev...
Yes but how make for retrieve the value (in fctn dialog) of a ChekBox (ex : DlgPremier) ?
I Try DlgText("DlgPremier") but not work.
TomFiz (or other) have you a solution ?
There is another thing that I not understand : In the fonction the Case 3 is executed before Case 1.
Thank Tom, I don't know why but, when I clic in checkBox (DlgPremier) I have a value 1 for Checked and nothing when uncheked It doesn't matter but it is necessary to know it. Therefore, when exit the DialogBox I have a value 0 if the checkbox is unchecked.
For "Case 3" here is my code :
Dim InitOK As Boolean Select Case Action% Case 1 'Initialise les controls de la boite de dialogue InitOK = True
...
Case 3 'Text or combo box changed Select Case ControlID$ Case "DlgMembre" 'Zone texte Membre modifiée If InitOK Then
Finally here is the code that works perfectly [:D]:
'Win32API DECLARATIONS
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
'HLLAPI FUNCTION DECLARATIONS
Private Declare Function WD_ConnectPS Lib "EhlApi32.dll" (ByVal hInstance As Integer, ByVal ShortName As String) As Integer
Private Declare Function WD_DisconnectPS Lib "EhlApi32.dll" (ByVal hInstance As Integer) As Integer
Private Declare Function WD_RunMacro Lib "EhlApi32.dll" (ByVal hInstance As Integer, ByVal Buffer As String) As Integer
Option explicit
Const ES_LEFT = &h0000&
Const ES_CENTER = &h0001&
Const ES_RIGHT = &h0002&
Const ES_MULTILINE = &h0004&
Const ES_UPPERCASE = &h0008&
Const ES_LOWERCASE = &h0010&
Const ES_PASSWORD = &h0020&
Const ES_AUTOVSCROLL = &h0040&
Const ES_AUTOHSCROLL = &h0080&
Const ES_NOHIDESEL = &h0100&
Const ES_OEMCONVERT = &h0400&
Const ES_READONLY = &h0800&
Const ES_WANTRETURN = &h1000&
Const ES_NUMBER = &h2000&
Dim MessageDlg As String, Titre As String, Appli As String, Membre As String
Dim PremierMembre As Integer, Fichier As Integer, BibOrig As Integer, Retour As Integer
Dim TypeFichier
Sub Main
MessageDlg = "Ici essai de message variable"
Titre = "Titre variable ici"
Membre = "ABCDEFGHIJK"
Appli = "12345678901234567890123456789012345678901234567890 "
PremierMembre = "1"
TypeFichier = 2
BibOrig = 2
Call DlgDébut(Titre, MessageDlg, TypeFichier, Membre, Appli, BibOrig, PremierMembre)
End Sub
Sub DlgDébut(Titre, Message, TypeFichier, Membre, Appli, BibOrig, PremierMembre)
Dim Fichier As Integer, Bib(6) As String
Bib(0) = "BBBBB"
Bib(1) = "Ssssss"
Bib(2) = "MMMMMMM"
Bib(3) = "Gggggg"
Bib(4) = "MMMMMMMM"
Bib(5) = "OOOOOO"
Bib(6) = "CCCCCCCCCC"
Begin Dialog MyDialog 60, 70, 230, 200, Titre, .DlgFonction
Text 5, 5, 220, 12, "", .DlgMessage, ES_CENTER
CancelButton 65, 180, 40, 12
OKButton 120, 180, 40, 12, .OK
GroupBox 12, 28, 62, 57, "Fichier"
OptionGroup .DlgFichier
OptionButton 19, 38, 47, 12, "111111"
OptionButton 19, 48, 47, 12, "2222222"
OptionButton 19, 58, 47, 12, "33333333"
OptionButton 19, 68, 47, 12, "8888888888"
Text 113, 20, 55, 30,"Bib d'origine :"
ListBox 110, 30, 55, 60, Bib() , .DlgBibOrig
Text 12, 105, 35, 12,"Membre :"
TextBox 46, 104, 70, 12, .DlgMembre, ES_LEFT
CheckBox 120, 104, 10, 12, "", .DlgPremier
Text 130, 102, 95, 22,"Si coché : Prendre le 1er membre de la liste"
Text 12, 121, 220,12, "", .DlgMsgMembre
Text 12, 145, 25, 12,"Appli :"
TextBox 46, 141, 165, 20, .DlgAppli, ES_MULTILINE
Text 12, 163, 200,12, "", .DlgMsgAppli
End Dialog
Dim Dlg_Var As MyDialog
Dlg_Var.DlgFichier = TypeFichier
Dlg_Var.DlgPremier = PremierMembre
Dlg_Var.DlgBibOrig = BibOrig
Dlg_Var.DlgAppli = Appli
Dlg_Var.DlgMembre = Membre
Retour = Dialog(Dlg_Var)
If Retour = -1 Then
MsgBox "Membre : " & Dlg_Var.DlgMembre
MsgBox "Fichier : " & Dlg_Var.DlgFichier
MsgBox "Pemier : " & Dlg_Var.DlgPremier
MsgBox "BibOrig : " & Dlg_Var.DlgBibOrig
MsgBox "Appli : " & Dlg_Var.DlgAppli
End
End If
End Sub
Function DlgFonction(ControlID$, Action%, SuppValue&)
Dim hWnd As Long, x As Long', ForegroundSessionName As String
Dim InitOK As Boolean
Select Case Action%
Case 1 'Initialise les controls de la boite de dialogue
InitOK = True
DlgText "DlgMessage", MessageDlg
If PremierMembre = 1 Then
DlgEnable "DlgMembre" ,0
DlgEnable "OK", 1
Else
DlgEnable "DlgMembre" ,1
End If
If Len(DlgText("DlgAppli")) > 50 Then
DlgText "DlgMsgAppli", "Appli 50 car. maxi. Actuellement : " & Len(DlgText("DlgAppli"))
DlgEnable "OK", 0
Else
DlgEnable "OK", 1
End If
Case 2 'Un des boutons ou case à cocher ont été utilisés
Select Case ControlID$
Case "DlgPremier" 'Case à coché "1er Membre utilisée"
Select Case SuppValue
Case 1 '"1er membre" coché donc Membre désactivé
DlgEnable "DlgMembre" ,0
DlgText "DlgMsgMembre", ""
If Len(DlgText("DlgAppli")) > 50 Then
DlgText "DlgMsgAppli", "Appli 50 car. maxi. Actuellement : " & Len(DlgText("DlgAppli"))
DlgEnable "OK", 0
Beep
Else
DlgEnable "OK", 1
End If
Case Else 'Premier membre décoché donc Membre activé
DlgEnable "DlgMembre" ,1
If Len(DlgText("DlgMembre")) > 10 Then
DlgText "DlgMsgMembre", " 10 car. maxi. Actuellement : " & Len(DlgText("DlgMembre"))
DlgEnable "OK", 0
Beep
Else
If Len(DlgText("DlgAppli")) > 50 Then
DlgText "DlgMsgAppli", "Appli 50 car. maxi. Actuellement : " & Len(DlgText("DlgAppli"))
DlgEnable "OK", 0
Beep
Else
DlgEnable "OK", 1
End If
End If
End Select
Case "OK"
If DlgText("DlgMembre") = "" And DlgValue("DlgPremier") <> 1 Then
Beep
DlgText "DlgMsgMembre", "Membre vide alors que ""Prendre 1er membre"" n'est pas cochée"
DlgEnable "OK", 0
DlgFonction = -1
End If
End Select
Case 3 'Text or combo box changed
Select Case ControlID$
Case = "DlgMembre" 'Zone texte Membre modifiée
If InitOK Then
If Len(DlgText("DlgMembre")) > 10 And DlgValue("DlgPremier") <> 1 Then
DlgText "DlgMsgMembre", "Appli 10 car. maxi. Actuellement : " & Len(DlgText("DlgMembre"))
DlgEnable "OK", 0
Else
DlgText "DlgMsgMembre", ""
If Len(DlgText("DlgAppli")) > 50 Then
DlgText "DlgMsgAppli", "Appli 50 car. maxi. Actuellement : " & Len(DlgText("DlgAppli"))
DlgEnable "OK", 0
Else
DlgText "DlgMsgAppli", ""
DlgEnable "OK", 1
End If
End If
End If
Case = "DlgAppli" 'Zone texte Appli modifiée
If Len(DlgText("DlgAppli")) > 50 Then
DlgText "DlgMsgAppli", "Appli 50 car. maxi. Actuellement : " & Len(DlgText("DlgAppli"))
DlgEnable "OK", 0
Else
DlgText "DlgMsgAppli", ""
If Len(DlgText("DlgMembre")) > 10 And DlgValue("DlgPremier") <> 1 Then
DlgText "DlgMsgMembre", "Appli 10 car. maxi. Actuellement : " & Len(DlgText("DlgMembre"))
DlgEnable "OK", 0
Else
DlgText "DlgMsgMembre", ""
DlgEnable "OK", 1
End If
End If
End Select
'Return to main dialog
'MainDialogProc = TRUE
Case 4 'Control focus changed
hWnd = GetForegroundWindow()
If hWnd > 0 Then
x = SetWindowText(hwnd, Titre)
End If
Case 5 'Idle - use this case to update from events on the host (if any)
print "Event from HOST"
'Return to main dialog
End Select
End Function
But the whole of my script is much longer.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.