RJK
May 14th, 2010, 04:35 PM
Hey i need help, im still learning WinAPI, but i was wondering how do you set text and a variable to a textfield, so far ive got:
char cHours[5], cPay[5], cTotal[5];
float Hours, Pay, Total;
GetWindowText(GetDlgItem(hwnd, IDC_HOURS), cHours, MAX_PATH);
GetWindowText(GetDlgItem(hwnd, IDC_PAY), cPay, MAX_PATH);
Hours = atof(cHours);
Pay = atof(cPay);
Total = Hours * Pay;
sprintf(cTotal, "%.2f", Total);
SetWindowText(GetDlgItem(hwnd, IDC_TOTAL), cTotal);
It works, but i was wondering how do you set text, like i want it to say (when the user clickes the button) "Your Wage is:"
I was playing arounda little bit, trying of every solution i could think off, but to give you lot a better idea here is something (i know it doesnt work, kinda like pseudo code):
SetWindowText(GetDlgItem(hwnd, IDC_TOTAL), "You Wage is" + cTotal);
char cHours[5], cPay[5], cTotal[5];
float Hours, Pay, Total;
GetWindowText(GetDlgItem(hwnd, IDC_HOURS), cHours, MAX_PATH);
GetWindowText(GetDlgItem(hwnd, IDC_PAY), cPay, MAX_PATH);
Hours = atof(cHours);
Pay = atof(cPay);
Total = Hours * Pay;
sprintf(cTotal, "%.2f", Total);
SetWindowText(GetDlgItem(hwnd, IDC_TOTAL), cTotal);
It works, but i was wondering how do you set text, like i want it to say (when the user clickes the button) "Your Wage is:"
I was playing arounda little bit, trying of every solution i could think off, but to give you lot a better idea here is something (i know it doesnt work, kinda like pseudo code):
SetWindowText(GetDlgItem(hwnd, IDC_TOTAL), "You Wage is" + cTotal);