I am trying to grab the rgb values from 3 editboxes so that I can change the color of a window during run time. The following code is not giving me the numeric values that I need.
const int bufferSize = 1024;
char fade1Buffer[bufferSize] = "";
char fade2Buffer[bufferSize] = "";
char fade3Buffer[bufferSize] = "";
HWND Editbox1 = GetDlgItem(hWnd,IDC_MAINFADE1_EDIT);
SendMessage(Editbox1, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)fade1Buffer);
HWND Editbox2 = GetDlgItem(hWnd,IDC_MAINFADE2_EDIT);
SendMessage(Editbox2, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)fade2Buffer);
HWND Editbox3 = GetDlgItem(hWnd,IDC_MAINFADE3_EDIT);
SendMessage(Editbox3, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)fade3Buffer);
//fill our main window background
FadeVert(hWnd, RGB(fade1Buffer, fade2Buffer,fade3Buffer), RGB(255, 255, 255), (int) Client_Rect.top,
(int) Client_Rect.left, (int) Client_Rect.right, (int) Client_Rect.bottom);
The atoi() function converts char* into int. It is under
<cstdlib>In this case,
See also, strtol() as @Keith Thompson and @Chris mentioned. It is a little harder to use, but it handles errors better.
If you convert it to a C++ style std:: string, you can use several other functions as well
Reference: http://en.cppreference.com/w/cpp/string/basic_string/stol