--- np2/win9x/dialog/d_serial.cpp 2005/02/09 20:11:36 1.13 +++ np2/win9x/dialog/d_serial.cpp 2007/11/11 07:11:28 1.18 @@ -15,25 +15,49 @@ #include "dipswbmp.h" -static const OEMCHAR str_none[] = OEMTEXT("NONE"); -static const OEMCHAR str_com1[] = OEMTEXT("COM1"); -static const OEMCHAR str_com2[] = OEMTEXT("COM2"); -static const OEMCHAR str_com3[] = OEMTEXT("COM3"); -static const OEMCHAR str_com4[] = OEMTEXT("COM4"); -static const OEMCHAR str_midi[] = OEMTEXT("MIDI"); -static const OEMCHAR str_odd[] = OEMTEXT("ODD"); -static const OEMCHAR str_even[] = OEMTEXT("EVEN"); -static const OEMCHAR str_one[] = OEMTEXT("1"); -static const OEMCHAR str_onehalf[] = OEMTEXT("1.5"); -static const OEMCHAR str_two[] = OEMTEXT("2"); +static const CBPARAM cpPort[] = +{ + {MAKEINTRESOURCE(IDS_NONCONNECT), COMPORT_NONE}, + {MAKEINTRESOURCE(IDS_COM1), COMPORT_COM1}, + {MAKEINTRESOURCE(IDS_COM2), COMPORT_COM2}, + {MAKEINTRESOURCE(IDS_COM3), COMPORT_COM3}, + {MAKEINTRESOURCE(IDS_COM4), COMPORT_COM4}, + {MAKEINTRESOURCE(IDS_MIDI), COMPORT_MIDI}, +}; + +static const CBPARAM cpParity[] = +{ + {MAKEINTRESOURCE(IDS_PARITY_NONE), 0x00}, + {MAKEINTRESOURCE(IDS_PARITY_ODD), 0x20}, + {MAKEINTRESOURCE(IDS_PARITY_EVEN), 0x30}, +}; + +static const CBPARAM cpBits[] = +{ + {MAKEINTRESOURCE(IDS_1), 0x40}, + {MAKEINTRESOURCE(IDS_1HALF), 0x80}, + {MAKEINTRESOURCE(IDS_2), 0xc0}, +}; + +static const TCHAR str_none[] = _T("NONE"); +static const TCHAR str_com1[] = _T("COM1"); +static const TCHAR str_com2[] = _T("COM2"); +static const TCHAR str_com3[] = _T("COM3"); +static const TCHAR str_com4[] = _T("COM4"); +static const TCHAR str_midi[] = _T("MIDI"); +static const TCHAR str_odd[] = _T("ODD"); +static const TCHAR str_even[] = _T("EVEN"); +static const TCHAR str_one[] = _T("1"); +static const TCHAR str_onehalf[] = _T("1.5"); +static const TCHAR str_two[] = _T("2"); -static const OEMCHAR *rsport[] = {str_none, str_com1, str_com2, str_com3, +static const TCHAR *rsport[] = {str_none, str_com1, str_com2, str_com3, str_com4, str_midi}; static const UINT32 rscharsize[] = {5, 6, 7, 8}; -static const OEMCHAR *rsparity[] = {str_none, str_odd, str_even}; -static const OEMCHAR *rsstopbit[] = {str_one, str_onehalf, str_two}; +static const TCHAR *rsparity[] = {str_none, str_odd, str_even}; +static const TCHAR *rsstopbit[] = {str_one, str_onehalf, str_two}; -static const OEMCHAR str_seropt[] = OEMTEXT("Serial option"); +static const TCHAR str_seropt[] = _T("Serial option"); #ifdef __cplusplus @@ -49,10 +73,12 @@ extern COMMNG cm_pc9861ch2; enum { ID_PORT = 0, + ID_SPEED, ID_CHARS, ID_PARITY, ID_SBIT, + ID_MMAP, ID_MMDL, ID_DEFE, @@ -159,7 +185,7 @@ static LRESULT CALLBACK dlgitem_proc(HWN switch (msg) { case WM_INITDIALOG: cfg = m->cfg; - SETLISTSTR(hWnd, m->idc[ID_PORT], rsport); + dlgs_setcbitem(hWnd, m->idc[ID_PORT], cpPort, NELEMENTS(cpPort)); SETLISTUINT32(hWnd, m->idc[ID_SPEED], cmserial_speed); SETLISTUINT32(hWnd, m->idc[ID_CHARS], rscharsize); SETLISTSTR(hWnd, m->idc[ID_PARITY], rsparity); @@ -198,43 +224,37 @@ static LRESULT CALLBACK dlgitem_proc(HWN SetDlgItemText(hWnd, m->idc[ID_DEFF], cfg->def); d = cfg->port; - if (d >= NELEMENTS(rsport)) { + if (d >= NELEMENTS(cpPort)) + { d = 0; } - SendDlgItemMessage(hWnd, m->idc[ID_PORT], - CB_SETCURSEL, (WPARAM)d, (LPARAM)0); - + dlgs_setcbcur(hWnd, m->idc[ID_PORT], d); dlgcom_items(hWnd, m, d); return(TRUE); case WM_COMMAND: - if (LOWORD(wp) == m->idc[ID_PORT]) { - r = SendDlgItemMessage(hWnd, m->idc[ID_PORT], - CB_GETCURSEL, (WPARAM)0, (LPARAM)0); - if (r != CB_ERR) { - dlgcom_items(hWnd, m, (UINT)r); - } + if (LOWORD(wp) == m->idc[ID_PORT]) + { + dlgcom_items(hWnd, m, + dlgs_getcbcur(hWnd, m->idc[ID_PORT], COMPORT_NONE)); } - else if (LOWORD(wp) == m->idc[ID_DEFB]) { + else if (LOWORD(wp) == m->idc[ID_DEFB]) + { dlgs_browsemimpidef(hWnd, m->idc[ID_DEFF]); } break; case WM_NOTIFY: - if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { + if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) + { cfg = m->cfg; update = 0; - r = SendDlgItemMessage(hWnd, m->idc[ID_PORT], - CB_GETCURSEL, (WPARAM)0, (LPARAM)0); - if (r != CB_ERR) { - if ((UINT)r >= NELEMENTS(rsport)) { - r = 0; - } - if (cfg->port != (UINT8)r) { - cfg->port = (UINT8)r; - update |= SYS_UPDATEOSCFG; - update |= m->update; - } + r = dlgs_getcbcur(hWnd, m->idc[ID_PORT], COMPORT_NONE); + if (cfg->port != (UINT8)r) + { + cfg->port = (UINT8)r; + update |= SYS_UPDATEOSCFG; + update |= m->update; } r = SendDlgItemMessage(hWnd, m->idc[ID_SPEED], CB_GETCURSEL, (WPARAM)0, (LPARAM)0); @@ -289,7 +309,7 @@ static LRESULT CALLBACK dlgitem_proc(HWN update |= m->update; } - cfg->def_en = GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); + cfg->def_en = (UINT8)GetDlgItemCheck(hWnd, m->idc[ID_DEFE]); cm = *m->cm; if (cm) { cm->msg(cm, COMMSG_MIMPIDEFEN, cfg->def_en); @@ -370,11 +390,11 @@ enum { static const UINT32 pc9861kint1[] = {0, 1, 2, 3}; static const UINT32 pc9861kint2[] = {0, 4, 5, 6}; -static const OEMCHAR sync0[] = OEMTEXT("Start-Stop"); -static const OEMCHAR sync1[] = OEMTEXT("ST1"); -static const OEMCHAR sync2[] = OEMTEXT("ST2"); -static const OEMCHAR sync3[] = OEMTEXT("RD-Sync"); -static const OEMCHAR *pc9861sync[] = {sync0, sync1, sync2, sync3}; +static const TCHAR sync0[] = _T("Start-Stop"); +static const TCHAR sync1[] = _T("ST1"); +static const TCHAR sync2[] = _T("ST2"); +static const TCHAR sync3[] = _T("RD-Sync"); +static const TCHAR *pc9861sync[] = {sync0, sync1, sync2, sync3}; static const UINT pc9861d2sync[] = {1, 2, 3, 0}; static const UINT pc9861d2int[] = {0, 2, 1, 3}; @@ -388,7 +408,7 @@ static void pc9861getspeed(HWND hWnd, co mode = *(m->dip_mode); r = SendDlgItemMessage(hWnd, m->idc_speed, CB_GETCURSEL, 0, 0); if (r != CB_ERR) { - UINT speed = r; + UINT speed = (UINT)r; if (speed > (NELEMENTS(pc9861k_speed) - 1)) { speed = NELEMENTS(pc9861k_speed) - 1; } @@ -636,17 +656,17 @@ static LRESULT CALLBACK pc9861mainProc(H void dialog_serial(HWND hWnd) { - HINSTANCE hinst; + HINSTANCE hInstance; PROPSHEETPAGE psp; PROPSHEETHEADER psh; HPROPSHEETPAGE hpsp[4]; - hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); + hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); ZeroMemory(&psp, sizeof(psp)); psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT; - psp.hInstance = hinst; + psp.hInstance = hInstance; psp.pszTemplate = MAKEINTRESOURCE(IDD_SERIAL1); psp.pfnDlgProc = (DLGPROC)Com1Proc; @@ -668,8 +688,8 @@ void dialog_serial(HWND hWnd) { psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; psh.hwndParent = hWnd; - psh.hInstance = hinst; - psh.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2)); + psh.hInstance = hInstance; + psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); psh.nPages = 4; psh.phpage = hpsp; psh.pszCaption = str_seropt;