Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Main Function and Dialog running simultaneously
#1
Main Function and Dialog, passing variables and running simultaneously

Hi Gintaras, hi all.

I would like to run a main function and a dialog/GUI, interacting with each other.
The following code is only an example, of course, my function and dialog have hundreds of lines.

I would need a more elegant solution, preferably without global variables.
Any idea, please?

Thanks in advance and happy new year of great code!
Regards

Function Fx
Code:
Copy      Help
type G_TEST
,int'Test
,int'Test_old
,int'Cancel
,str'sRandom

G_TEST+ t

t.Test=0
t.Test_old=0
t.Cancel=0
t.sRandom="Random"

mac "Fx_GUI"

out
rep
,if t.Cancel
,,break
,if t.Test<>t.Test_old
,,t.sRandom.RandomString(5 5 "a-z")
,,out F"{t.Test}: {t.sRandom}"
,,t.Test_old=t.Test
,0.2

Function Fx_GUI
Code:
Copy      Help
;\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 21 21 48 14 "Random + 0"
;4 Button 0x54032000 0x0 87 21 48 14 "+10"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040400 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,SetTimer hDlg 1 500 0
,case WM_TIMER
,,str s=F"{t.sRandom} + {t.Test}"
,,s.setwintext(id(3 hDlg))
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,,t.Test+1
,case 4
,,t.Test+10
,case IDOK
,,t.Cancel=1
,case IDCANCEL
,,t.Cancel=1
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)