Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Returning values from function to different dialog controls
#1
I know this should be easy, but I just can't grasp the logic on how it is done.

So if I choose option button 1 the text goes in text 1 and if I choose option button 2 the text goes into text 2?

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


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 287 130 "Dialog2"
;3 Button 0x54032000 0x0 4 0 50 16 "Start"
;2 Button 0x54030000 0x4 6 20 48 14 "Cancel"
;5 Button 0x54032009 0x0 58 2 102 14 "Display in text box 1"
;6 Button 0x54002009 0x0 162 2 120 14 "Display in text box 2"
;4 Edit 0x54200844 0x20000 56 50 96 48 ""
;7 Edit 0x54200844 0x20000 168 50 96 48 ""
;8 Static 0x54000000 0x0 56 38 48 12 "Text Box 1"
;9 Static 0x54000000 0x0 168 38 48 12 "Text Box 2"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "5 6 4 7"
str o5Dis o6Dis e4 e7
o5Dis=1
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,
,case WM_COMMAND goto messages2
,case WM_APP
,SetDlgItemText hDlg 4 F"{lParam%%s}"
,/SetDlgItemText hDlg 7 F"{lParam%%s}"


ret
;messages2
sel wParam
,case 3
,str showText
,if but(id(5 hDlg))
,,showText="text1"
,else
,,showText="text2"
,mac "Displaytext" "" hDlg showText
,
,,case IDCANCEL
ret 1

Function Displaytext
Code:
Copy      Help
function hDlg ~showText

if showText="text1"
,SendMessage hDlg WM_APP 1 "text is in text box 1"
else
,SendMessage hDlg WM_APP 1 "text is in text box 2"

Kind Regards
Matt
#2
Let SendMessage send control id in wParam, and SetDlgItemText use wParam.

SendMessage hDlg WM_APP 4 "text is in text box 1"
SendMessage hDlg WM_APP 7 "text is in text box 2"

SetDlgItemText hDlg wParam F"{lParam%%s}"
#3
Gintaras Wrote:Let SendMessage send control id in wParam, and SetDlgItemText use wParam.

SendMessage hDlg WM_APP 4 "text is in text box 1"
SendMessage hDlg WM_APP 7 "text is in text box 2"

SetDlgItemText hDlg wParam F"{lParam%%s}"

As usual your support is fantastic - works great!

Thanks kindly
Matt
#4
Yes, support is great..

BTW, can you explain

Quote:SetDlgItemText hDlg wParam F"{lParam%%s}"

{lParam%%s} syntax (saw {lParam%s} once too with one % only - because two sendmessage previously?)
Thanks
#5
%%s is like %s with str.format. Without it would format a number, because type of lParam is int.
#6
A little stuck again Confusedhock:
I need to be able to return different values from macro to different dialog controls - this now works fine.

I am returning an integer to an edit box but I also need to be able to return a string to another edit box, but this must be able to scroll.

I can get either to work on their own, but not sure of the syntax needed to have them work together.

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


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 287 130 "The Roulette Project"
;3 Button 0x54032000 0x0 6 4 50 38 "Start"
;4 Button 0x54032000 0x0 6 46 50 38 "Stop"
;9 Edit 0x54200844 0x20000 58 30 224 96 ""
;5 Button 0x54032009 0x0 58 2 102 14 "Dublinbet Table 1 #1/#10"
;6 Button 0x54002009 0x0 162 2 120 14 "Smartlive Low Limit Auto Roulette"
;8 Button 0x54012003 0x0 58 16 104 14 "Aggressive Betting Algorithm"
;7 Static 0x54000000 0x0 208 18 32 12 "Balance $"
;10 Edit 0x54032000 0x200 240 16 42 14 ""
;2 Button 0x54030000 0x4 6 88 50 38 "Close"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "9 5 6 8 10"
str e9 o5Dub o6Sma c8Agg e10
o5Dub=1
e10="100"

if(!ShowDialog("Hot_Dialog" &Hot_Dialog &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,/GdiObject- brush=CreateSolidBrush(ColorFromRGB(0 176 255))
,/SetDlgItemText hDlg 6 ""
,
,EnableWindow id(4 hDlg) 0
,case WM_DESTROY
,
,/case WM_CTLCOLORDLG ret brush
,case WM_COMMAND goto messages2
,case WM_APP
,SetDlgItemText hDlg wParam F"{lParam%%s}"
,SendMessage hDlg EM_SETSEL 1000000000 1000000000
,SendMessage hDlg EM_REPLACESEL 9 F"{lParam%%i}[]"
,
,
,//int c=id(9 hDlg)
,//SendMessage c EM_SETSEL 1000000000 1000000000
,//SendMessage c EM_REPLACESEL 0 F"{lParam%%i}[]"


ret
;messages2
sel wParam
,case 3
,SetDlgItemText hDlg 9 ""
,str toPlay
,int prog=0
,int TotalBalance
,
,if but(id(5 hDlg))
,,toPlay="Dub"
,else
,,toPlay="SL"
,if but(id(8 hDlg))
,,prog=1
,SetDlgItemText hDlg 3 "Running"
,EnableWindow id(3 hDlg) 0; EnableWindow id(4 hDlg) 1
,mac "Hot" "" hDlg toPlay prog _s.getwintext(id(10 hDlg))

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

Macro Hot
Code:
Copy      Help
function hDlg ~toPlay #prog #TotalBalance;;pass variable from dialog that determines which casino we are playing ;;set to 0 by default (i.e. no progression)

//double TotalBalance ;;game balance
//if(!inp(TotalBalance "Enter starting Balance" "Enter Your Balance" "0")) ret ;;prompt for starting balance to be entered
TotalBalance=TotalBalance+100
SendMessage hDlg WM_APP 9 "This is the first line"
SendMessage hDlg WM_APP 9 "This should appear below the first line"
SendMessage hDlg WM_APP 10 F"{TotalBalance}"

When I run this, the balance updates fine, but I am only seeing the second line in the other edit box, I need to have it scroll and show both.

Please can you assist?

Kind Regards
Matt
#7
Code:
Copy      Help
,case WM_APP
,int hwndControl=id(wParam hDlg)
,SendMessage hwndControl EM_SETSEL 1000000000 1000000000
,SendMessage hwndControl EM_REPLACESEL 0 F"{lParam%%i}[]"
#8
Hi Gintaras, thank you kindly, that works, sort of. The text is now being appended and scrolling nicely Smile however it now appends the balance instead of replacing it- it is showing 100200(instead of just 200). Can we have it so the text box replaces the text but the edit box scrolls the text?

Have played around with it, but can't seem to work it out - please can you assist?

Function Hot_Dialog
Code:
Copy      Help
,case WM_APP
,int hwndControl=id(wParam hDlg)
,/SetDlgItemText hDlg wParam F"{lParam%%s}"
,SendMessage hwndControl EM_SETSEL 1000000000 1000000000
,SendMessage hwndControl EM_REPLACESEL 0 F"{lParam%%s}[]"

Macro Hot
Code:
Copy      Help
function hDlg ~toPlay #prog #TotalBalance;;pass variable from dialog that determines which casino we are playing ;;set to 0 by default (i.e. no progression)

//double TotalBalance ;;game balance
//if(!inp(TotalBalance "Enter starting Balance" "Enter Your Balance" "0")) ret ;;prompt for starting balance to be entered
TotalBalance=TotalBalance+100
SendMessage hDlg WM_APP 10 F"{TotalBalance}"
SendMessage hDlg WM_APP 9 "This is the first line"
SendMessage hDlg WM_APP 9 "This should appear below the first line"


Attached Files Image(s)
   
#9
try this
Function Hot_Dialog
Code:
Copy      Help
,case WM_APP
,sel wParam
,,case 10
,,SetDlgItemText hDlg wParam F"{lParam%%s}"
,,case 9
,,int hwndControl=id(wParam hDlg)
,,SendMessage hwndControl EM_SETSEL 1000000000 1000000000
,,SendMessage hwndControl EM_REPLACESEL 0 F"{lParam%%i}[]"
#10
Kevin Wrote:try this
Function Hot_Dialog
Code:
Copy      Help
,case WM_APP
,sel wParam
,,case 10
,,SetDlgItemText hDlg wParam F"{lParam%%s}"
,,case 9
,,int hwndControl=id(wParam hDlg)
,,SendMessage hwndControl EM_SETSEL 1000000000 1000000000
,,SendMessage hwndControl EM_REPLACESEL 0 F"{lParam%%i}[]"

Works perfectly!

Thank you kindly Kevin.

Matt


Forum Jump:


Users browsing this thread: 1 Guest(s)