Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output double to dialog edit control
#1
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
Code:
Copy      Help
,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
#2
%%.3G
read more in qm help or online
http://www.quickmacros.com/help/Language...TRING.html



Macro Macro3
Code:
Copy      Help
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
#3
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}"
#4
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
Code:
Copy      Help
case 10
,,    SetDlgItemText hDlg wParam F"{lParam%%.3G}"
,,,,case 22

Kind Regards
Matt
#5
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
#6
Then use SendMessage just to update dialog, and let lParam be 0 and not used.
#7
Or convert to string when sending message. Then don't need to change anything in dialog code.

double d=1.5
SendMessage ... ... ... F"{d}"
#8
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!


Forum Jump:


Users browsing this thread: 3 Guest(s)