Posts: 58
Threads: 19
Joined: Mar 2013
Hello, I am trying to use Sendmessage from macro to output a double amount (.50) to the dialog, but it keeps rounding it up to 1
What do I need to specify instead of i to have it output it correctly - I tried d but it did not work.
Function
_15_4_HOT
,case WM_COMMAND goto messages2
,case WM_APP
,sel wParam
,, case 10
,, SetDlgItemText hDlg wParam F"{lParam%%d}"
,,,,case 22
,,,,SetDlgItemText hDlg wParam F"{lParam%%i}"
Kind Regards
Matt
Posts: 1,337
Threads: 61
Joined: Jul 2006
%%.3G
read more in qm help or online
http://www.quickmacros.com/help/Language...TRING.html
Macro
Macro3
double d=3.1415926535897932384626433832795
out
out F"{d%%.3G}"
out F"{d%%.5G}"
out F"{d%%.10G}"
out F"{d%%.15G}"
d=113.1415926535897932384626433832795
out F"{d%%.3G}"
out F"{d%%.5G}"
out F"{d%%.10G}"
out F"{d%%.15G}"
;; G number will depend on numeric size and how mnay decimal places you will need
Posts: 12,090
Threads: 142
Joined: Dec 2002
double cannot be easily passed in lParam, because lParam is too small. Easiest is to store the value in a global variable.
double+ g_456
g_456=9.5
double+ g_456
SetDlgItemText hDlg wParam F"{g_456}"
Posts: 58
Threads: 19
Joined: Mar 2013
Thanks Kevin.
Not sure what I am doing wrong. The balance should be 999.50, but it is displaying as:
I used the example your provided for two decimal places.
Function
_15_4_HOT
case 10
,, SetDlgItemText hDlg wParam F"{lParam%%.3G}"
,,,,case 22
Kind Regards
Matt
Posts: 58
Threads: 19
Joined: Mar 2013
Gintaras Wrote:double cannot be easily passed in lParam, because lParam is too small. Easiest is to store the value in a global variable.
double+ g_456
g_456=9.5
double+ g_456
SetDlgItemText hDlg wParam F"{g_456}"
Got it! Thanks very much Kevin and Gintaras, that looks like it will work.
Kind Regards
Matt
Posts: 12,090
Threads: 142
Joined: Dec 2002
Then use SendMessage just to update dialog, and let lParam be 0 and not used.
Posts: 12,090
Threads: 142
Joined: Dec 2002
Or convert to string when sending message. Then don't need to change anything in dialog code.
double d=1.5
SendMessage ... ... ... F"{d}"
Posts: 58
Threads: 19
Joined: Mar 2013
Gintaras Wrote:Or convert to string when sending message. Then don't need to change anything in dialog code.
double d=1.5
SendMessage ... ... ... F"{d}"
Oh okay, I got it to work with your first example, but that looks cleaner.
Thankyou!