editor: use Set/GetDlgItemInt
We previously rolled our own text <-> int conversion code for the dialogs. Use winapi's built-in one instead. While we're at it, fix some indentation and a return-code.
This commit is contained in:
parent
341bf3b449
commit
6d56c23e00
@ -73,26 +73,16 @@ static LRESULT CALLBACK setRowsDialogProc(HWND hDlg, UINT message, WPARAM wParam
|
|||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
int *rows = (int*)lParam;
|
size_t *rows = (size_t *)lParam;
|
||||||
assert(NULL != rows);
|
SetDlgItemInt(hDlg, IDC_SETROWS_EDIT, *rows, FALSE);
|
||||||
|
|
||||||
/* create row-string */
|
|
||||||
char temp[256];
|
|
||||||
snprintf(temp, 256, "%d", *rows);
|
|
||||||
|
|
||||||
/* set initial row count */
|
|
||||||
SetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK) {
|
||||||
{
|
|
||||||
/* get value */
|
/* get value */
|
||||||
char temp[256];
|
size_t result = GetDlgItemInt(hDlg, IDC_SETROWS_EDIT, NULL, FALSE);
|
||||||
GetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp, 256);
|
|
||||||
int result = atoi(temp);
|
|
||||||
|
|
||||||
/* update editor */
|
/* update editor */
|
||||||
SendMessage(GetParent(hDlg), WM_SETROWS, 0, result);
|
SendMessage(GetParent(hDlg), WM_SETROWS, 0, result);
|
||||||
@ -123,24 +113,15 @@ static LRESULT CALLBACK biasSelectionDialogProc(HWND hDlg, UINT message, WPARAM
|
|||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
int *intialBias = (int*)lParam;
|
int *intialBias = (int*)lParam;
|
||||||
assert(NULL != intialBias);
|
SetDlgItemInt(hDlg, IDC_BIASSELECTION_EDIT, *intialBias, TRUE);
|
||||||
|
return TRUE;
|
||||||
/* create bias-string */
|
|
||||||
char temp[256];
|
|
||||||
_snprintf(temp, 256, "%d", *intialBias);
|
|
||||||
|
|
||||||
/* set initial bias */
|
|
||||||
SetDlgItemText(hDlg, IDC_BIASSELECTION_EDIT, temp);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK) {
|
||||||
{
|
|
||||||
/* get value */
|
/* get value */
|
||||||
char temp[256];
|
int bias = GetDlgItemInt(hDlg, IDC_BIASSELECTION_EDIT, NULL, FALSE);
|
||||||
GetDlgItemText(hDlg, IDC_BIASSELECTION_EDIT, temp, 256);
|
|
||||||
int bias = atoi(temp);
|
|
||||||
|
|
||||||
/* update editor */
|
/* update editor */
|
||||||
SendMessage(GetParent(hDlg), WM_BIASSELECTION, 0, LPARAM(bias));
|
SendMessage(GetParent(hDlg), WM_BIASSELECTION, 0, LPARAM(bias));
|
||||||
@ -473,7 +454,7 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
case ID_EDIT_SETROWS:
|
case ID_EDIT_SETROWS:
|
||||||
{
|
{
|
||||||
int rows = int(trackView->getRows());
|
size_t rows = trackView->getRows();
|
||||||
INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
error("unable to create dialog box");
|
error("unable to create dialog box");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user