Input dialog

This commit is contained in:
kichikuou
2016-04-02 20:49:37 +09:00
parent c228af4b37
commit f51f224fe4
6 changed files with 84 additions and 89 deletions
-69
View File
@@ -4,16 +4,7 @@
[ NACT ]
*/
#if defined(_SYSTEM1)
#include "../res1/resource.h"
#elif defined(_SYSTEM2)
#include "../res2/resource.h"
#else
#include "../res3/resource.h"
#endif
#include <windows.h>
#include <windowsx.h>
#include "nact.h"
#include "ags.h"
#include "mako.h"
@@ -480,63 +471,3 @@ void NACT::output_console(char log[])
WriteConsole(hConsole, log, strlen(log), &dwWritten, NULL);
#endif
}
BOOL CALLBACK NACT::TextDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static NACT* nact;
char string[64];
int pnt, cnt;
switch(msg) {
case WM_CLOSE:
EndDialog(hDlg, IDCANCEL);
break;
case WM_INITDIALOG:
// get this pointer
nact = (NACT *)lParam;
// init dialog
sprintf_s(string, 64, "文字列を入力してください(最大%d文字)", nact->tvar_maxlen);
Edit_SetText(GetDlgItem(hDlg, IDC_TEXT), string);
Edit_SetText(GetDlgItem(hDlg, IDC_EDITBOX), nact->tvar[nact->tvar_index - 1]);
if(nact->tvar[nact->tvar_index - 1][0] == '\0') {
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
} else {
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_EDITBOX:
GetDlgItemText(hDlg, IDC_EDITBOX, string, 32);
pnt = cnt = 0;
while(string[pnt] != '\0') {
unsigned char dat = string[pnt];
if((0x81 <= dat && dat <= 0x9f) || 0xe0 <= dat) {
pnt++;
}
pnt++;
cnt++;
}
if(cnt == 0 || cnt > nact->tvar_maxlen) {
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
} else {
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
}
break;
case IDOK:
GetDlgItemText(hDlg, IDC_EDITBOX, string, 32);
strcpy_s(nact->tvar[nact->tvar_index - 1], 22, string);
EndDialog(hDlg, IDOK);
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}