Win32 Question

Started by
1 comment, last by hughiecoles 16 years ago
I'm currently doing some Win32 programming and didn't find anything about the feature I want. I've created 3 "edit" windows to write some values into it and I'd like a tips how to calculate the 3th value automaticaly when I click the "calculate" button. So, I've 3 edit boxex, writing 2 values and want the 3th edit box show me the results into the edit box and vis-versa. I've also thought about making a menu to calculate specific values, the got valuee from the edits and click to the corresponding menu to calculate the missing value to the edit box that needs it. What I wish the most is something that could refresh my windows so this is calculating automatically. But didn't find anything via MSDN, maybe some wrong key-search but.. ^^ I'd also make it so when I hit ENTER, the blank value missing in the edit just appear up too, just another idea. If you need more informations to get it clearly feel free to ask. Thanks for any comments or future help. Cordially, Mazh Edit: How to get string to my value that are into my edit boxes? I mean, when I enter a number into my edit box, how do I retrieve the information to use it to my own? Thanks. [Edited by - Mazh on April 20, 2008 10:49:29 PM]
Advertisement
In your WM_NOTIFY handler you can handle the EN_CHANGE notification. You can get the data from the edit controls using GetDlgItemInt() or GetDlgItemText().
well as for adding the values of 2 edit controls, and placing it into the 3rd, try something like


there's a function that grabs the contents of an Edit, which was mentioned about, GetDlgItemInt()

int NumberOne = GetDlgItemInt(hWnd1); // get values of both edit boxes
int NumberTwo = GetDlgItemInt(hwnd2);

int total = NumberOne + NumberTwo; //add

stringStreamObject << total; //pre-initialized string stream

SetWindowText(hWnd3,stringStreamObject.str().c_str());


that would do the job, as for the pressing enter, try using a button at first
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried

This topic is closed to new replies.

Advertisement