Getting Integers from an Edit Control
Iím making a ďmap makerĒ type program and Iím having some trouble getting information from Dialog Box edit controls. I know how to use EM_GETLINE to get text from an edit control (which I previously used to also work with numbers by using an atoi() call and changing the chars in to integers). Unfortunately I ran in to problems when only entering one character in to the edit control but everything worked fine for anything >= 10. I figured I would never have a map as small as 9x9 so it didnít really matterÖ unfortunately now I need to be able to enter single digits for a different Dialog Box.
Iíve been searching for an EM_GETLINE type parameter to grab integers to but Iíve had no luck so I turned to where I usually turn when I hit a wall. I hope you guys can help.
Hereís my non-working code right now.
Thereís some stuff left over from when I was trying to convert character strings to integers and then remembered that it wouldnít work. Right now this compiles fine but of course it crashes when it reaches the last SendDlgItemMessage() because of my LPARAM being an integer.
LRESULT CALLBACK SelectMission(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
int mission = 0;
DisplayInfo* Info = (DisplayInfo*)(DWORD_PTR)GetWindowLongPtr(hDlg, DWLP_USER);
HRESULT hr = -1;
SetWindowLongPtr(hDlg, DWLP_USER, static_cast<long>(lParam));
sizeOfInput = (WORD) SendDlgItemMessage(hDlg,
if (sizeOfInput == 0)
"No characters entered for Mission.",
//// Put the number of characters into first word of buffer.
//*((LPWORD)mission) = sizeOfInput;
// Get the characters.
(WPARAM) 0, // line 0
//// Null-terminate the string.
//height[sizeOfInput] = 0;
Iíve been looking through MSDN for an EM_ something that would help my problem but I havenít found anything yet. Any help would be greatly appreciated.