Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing values within dialog from menu item
#1
Hi, I am using a menu item wihin a dialog to open a text file of numbers and save the data. I then want to be able to pass that to the macro.
The text file is simply
1
2
3
4

I can read and save the numbers to a variable fine, but how do I pass them to the another part of the dialog, so I can then pass them to the macro? I am getting an empty string when I try and pass to the macro.

Here is the dialog and I have attached an image to help explain

Function _15_4_HOT
Code:
Copy      Help
/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 148 279 "The Roulette Project"
;3 Button 0x54032000 0x0 52 224 30 22 "Start"
;4 Button 0x54032000 0x0 82 224 32 22 "Stop"
;8 Button 0x54012003 0x0 54 136 82 14 "Aggressive Algorithm"
;7 Static 0x54000000 0x0 54 48 78 10 "Balance"
;11 ComboBox 0x54230243 0x0 54 10 94 213 ""
;5 Static 0x54000000 0x0 56 2 78 8 "Choose Casino"
;6 Static 0x54000000 0x0 56 24 78 10 "Unit Size"
;12 ComboBox 0x54230243 0x0 54 34 50 213 ""
;13 Button 0x54012003 0x0 54 150 48 13 "Save Spins"
;14 Static 0x54000000 0x0 54 76 76 10 "Profit"
;15 Edit 0x54032000 0x200 58 86 38 18 ""
;16 Static 0x54000000 0x0 54 60 4 8 "$"
;17 Static 0x54000000 0x0 54 90 4 10 "$"
;18 RichEdit20A 0x54000045 0x0 0 0 18 246 ""
;19 RichEdit20A 0x54000045 0x0 14 0 20 246 ""
;20 RichEdit20A 0x54000045 0x0 34 0 18 246 ""
;21 Static 0x54000000 0x0 54 106 76 10 "Spin"
;22 Edit 0x54030080 0x200 60 116 36 18 ""
;10 Edit 0x54000004 0x20000 58 58 38 16 ""
;9 Static 0x54000000 0x0 54 120 6 8 "#"
;23 Edit 0x54200844 0x20000 0 246 150 32 ""
;24 Button 0x54012003 0x0 54 164 48 13 "Logging"
;2 Button 0x54030000 0x4 114 224 34 22 "Close"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "8 10 11 12 13 15 18 19 20 22 23 24"
str c8Agg e10 cb11 cb12 c13Sav e15 rea18 rea19 rea20 e22 e23 c24Log
cb11 = "Smartlive Live Roulette[]Smartlive Auto Roulette[]&Smartlive Low Auto Roulette"
cb12 = "$0.10[]&$0.50[]$1[]$5[]$25[]$50[]$100"
e10=""
e15="0"
c24Log="1"

,str toPlay
,int logging=0
,int prog=0
,int TotalBalance
,int saveFile=0
,str s fileTxt
,str alltext

if(!ShowDialog("_15_4_HOT" &_15_4_HOT &controls 0 0 0 0 0 0 0 "dialog.ico" "_15_4_HOT")) ret
ret
;messages
sel message
,case WM_INITDIALOG
,/GdiObject- brush=CreateSolidBrush(ColorFromRGB(0 176 255))
,/SetDlgItemText hDlg 6 ""
,
,EnableWindow id(4 hDlg) 0
,EnableWindow id(22 hDlg) 0
,EnableWindow id(15 hDlg) 0
,__Font-- f
,
,f.Create("Calibri" 10 1)
,f.SetDialogFont(hDlg "15 7 5 6 21 14")
,/f.SetDialogFontColor(hDlg 0x008000 "15")
,f.SetDialogFontColor(hDlg 0x000000 "10")
,
,int h(id(18 hDlg)) bcol(0x000000) tcol(0xff)
,
,SendMessage h EM_SETBKGNDCOLOR 0 bcol
,
,CHARFORMAT cf.cbSize=sizeof(CHARFORMAT)
,cf.dwMask=CFM_COLOR|CFM_BOLD|CFM_FACE|CFM_SIZE
,cf.crTextColor=tcol
,cf.dwEffects=CFE_BOLD
,lstrcpyn(&cf.szFaceName "Comic Sans MS" 22)
,cf.yHeight=200 ;;twips
,
,SendMessage h EM_SETCHARFORMAT SCF_ALL &cf
,
,int i(id(19 hDlg)) jcol(0x000000) kcol(0x00FF00)
,
,SendMessage i EM_SETBKGNDCOLOR 0 jcol
,
,CHARFORMAT df.cbSize=sizeof(CHARFORMAT)
,cf.dwMask=CFM_COLOR|CFM_BOLD|CFM_FACE|CFM_SIZE
,cf.crTextColor=kcol
,cf.dwEffects=CFE_BOLD
,lstrcpyn(&cf.szFaceName "Comic Sans MS" 22)
,cf.yHeight=200 ;;twips
,
,SendMessage i EM_SETCHARFORMAT SCF_ALL &cf
,
,int j(id(20 hDlg)) lcol(0x000000) mcol(0xFFFF)
,
,SendMessage j EM_SETBKGNDCOLOR 0 lcol
,
,CHARFORMAT ef.cbSize=sizeof(CHARFORMAT)
,cf.dwMask=CFM_COLOR|CFM_BOLD|CFM_FACE|CFM_SIZE
,cf.crTextColor=mcol
,cf.dwEffects=CFE_BOLD
,lstrcpyn(&cf.szFaceName "Comic Sans MS" 22)
,cf.yHeight=200 ;;twips
,
,SendMessage j EM_SETCHARFORMAT SCF_ALL &cf
,
,case WM_DESTROY
,
,/case WM_CTLCOLORDLG ret brush
,case WM_COMMAND goto messages2
,case WM_APP
,sel wParam
,,    case 10
,,    SetDlgItemText hDlg wParam F"{lParam%%i}"
,,,,case 22
,,,,SetDlgItemText hDlg wParam F"{lParam%%i}"
,,,,case 15
,,,,    if lParam<0
,,,,,        f.SetDialogFontColor(hDlg 0xff "15")
,,,,    else
,,,,,        f.SetDialogFontColor(hDlg 0x008000 "15")
,,,,    SetDlgItemText hDlg wParam F"{lParam%%i}"
,,    case else
,,    int hwndControl=id(wParam hDlg)
,,    SendMessage hwndControl EM_SETSEL 1000000000 1000000000
,,    SendMessage hwndControl EM_REPLACESEL 0 F"{lParam%%s}[]"

ret
;messages2
sel wParam
,;menu items:
,case 101 ;; Menu File>>Open
,,OpenSaveDialog(0 s "Text files[]*.txt[]Image files[]*.bmp;*.gif[]All Files[]*.*[]")
,,fileTxt.getfile(s)
,,out fileTxt
,,,
,case CBN_SELENDOK<<16|11
,_i=CB_SelectedItem(lParam); if(_i<0) ret
,sel _i
,,case 0 _s="&$1[]$5[]$10[]$25[]$50[]$100[]$500"
,,case 1 _s="&$1[]$5[]$10[]$25[]$50[]$100[]$500"
,,case 2 _s="$0.10[]&$0.50[]$1[]$5[]$25[]$50[]$100"
,TO_CBFill id(12 hDlg) _s
,;CB_SelectItem id(4 hDlg) 0
,case 3
,SetDlgItemText hDlg 23 ""
,,int selected = CB_SelectedItem(id(11 hDlg))
,sel selected
,,case 0 toPlay="SL_Live"
,,case 1 toPlay="SL_Auto"
,,case 2 toPlay="SL_Auto_Low"
,if but(id(8 hDlg))
,,prog=1
,if but(id(13 hDlg))
,,saveFile=1
,if but(id(24 hDlg))
,,logging=1
,SetDlgItemText hDlg 3 "Running"
,EnableWindow id(3 hDlg) 0; EnableWindow id(4 hDlg) 1; EnableWindow id(12 hDlg) 0; EnableWindow id(11 hDlg) 0; EnableWindow id(15 hDlg) 1; EnableWindow id(10 hDlg) 0
,mes fileTxt
,mac "Hot_1" "" hDlg toPlay prog saveFile logging fileTxt _s.getwintext(id(10 hDlg))

,
,case 4
,SetDlgItemText hDlg 3 "Start"
,shutdown -6 0 "Hot_1"
,EnableWindow id(3 hDlg) 1; EnableWindow id(4 hDlg) 0; EnableWindow id(12 hDlg) 1; EnableWindow id(11 hDlg) 1; EnableWindow id(10 hDlg) 1
,SetDlgItemText hDlg 10 ""
,case IDCANCEL
ret 1

;BEGIN MENU
;>&File
,;&Run Cache : 101 0 0

;END MENU

   

Thanks kindly
Matt
#2
needs to be a thread variable

Function _15_4_HOT
Code:
Copy      Help
,str-- fileTxt;;or str- fileTxt
  • - var is thread variable, visible in all functions of current thread.
  • -- var is thread variable, visible only in current function.
#3
Kevin Wrote:needs to be a thread variable

Perfect, thanks so much Kevin, I was sure it was something simple!

Matt
#4
To make code shorter and clear arranged can use 1 button to start-stop.

Function Dialog2
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5 6 7"
str c3Sta e4 e5 e6 e7
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 215 138 "Dialog"
;3 Button 0x54033003 0x0 156 114 48 14 "Start"
;4 Edit 0x54030080 0x200 8 18 96 14 ""
;5 Edit 0x54030080 0x200 8 40 96 14 ""
;6 Edit 0x5C030080 0x200 8 62 96 14 ""
;7 Edit 0x5C030080 0x200 10 82 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030501 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3 ;; start-stop button must have BS_PUSHLIKE and BS_AUTOCHECKBOX style
,if(but(lParam))
,,;mac "MyMacro"
,,out "Started"
,,TO_EnableSelected hDlg "4 5" 0 "6 7"
,else
,,;shutdown -6 0 "MyMacro"
,,out "Stopped"
,,TO_EnableSelected hDlg "6 7" 0 "4 5"

,SetDlgItemText hDlg wParam iif(but(lParam) "Stop" "Start")
,case IDOK
,case IDCANCEL
ret 1



Could also do the enabling in 1 line. Thought maybe hard to read.

,case 3 ;; start-stop button must have BS_PUSHLIKE and BS_AUTOCHECKBOX style
,if(but(lParam))
,,;mac "MyMacro"
,,out "Started"
,else
,,;shutdown -6 0 "MyMacro"
,,out "Stopped"
,TO_EnableSelected hDlg iif(but(lParam) "4 5 -6 -7" "-4 -5 6 7") 0 ""
,SetDlgItemText hDlg wParam iif(but(lParam) "Stop" "Start")
#5
MAGNET Wrote:To make code shorter and clear arranged can use 1 button to start-stop.

Great suggestion to improve the code - thankyou!!

Kind Regards
Matt


Forum Jump:


Users browsing this thread: 1 Guest(s)