|
|
| version 1.17, 2005/02/09 20:11:35 | version 1.23, 2007/01/08 08:52:21 |
|---|---|
| Line 3 | Line 3 |
| #include "resource.h" | #include "resource.h" |
| #include "np2.h" | #include "np2.h" |
| #include "winloc.h" | #include "winloc.h" |
| #include "oemtext.h" | |
| #include "dosio.h" | #include "dosio.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "sysmng.h" | #include "sysmng.h" |
| Line 88 typedef struct { | Line 89 typedef struct { |
| SUBCLASSPROC subproc[IDC_MAXITEMS]; | SUBCLASSPROC subproc[IDC_MAXITEMS]; |
| } TOOLWIN; | } TOOLWIN; |
| enum { | #define GTWLP_FOCUS (NP2GWLP_SIZE + (0 * sizeof(LONG_PTR))) |
| GTWL_FOCUS = NP2GWL_SIZE + 0, | #define GTWLP_SIZE (NP2GWLP_SIZE + (1 * sizeof(LONG_PTR))) |
| GTWL_SIZE = NP2GWL_SIZE + 4 | |
| }; | |
| NP2TOOL np2tool; | NP2TOOL np2tool; |
| static TOOLSKIN toolskin; | static TOOLSKIN toolskin; |
| Line 148 static HBITMAP skinload(const OEMCHAR *p | Line 147 static HBITMAP skinload(const OEMCHAR *p |
| milstr_ncpy(fname, path, NELEMENTS(fname)); | milstr_ncpy(fname, path, NELEMENTS(fname)); |
| file_cutname(fname); | file_cutname(fname); |
| file_catname(fname, toolskin.main, NELEMENTS(fname)); | file_catname(fname, toolskin.main, NELEMENTS(fname)); |
| ret = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | #if defined(OSLANG_UTF8) |
| TCHAR tchr[MAX_PATH]; | |
| oemtotchar(tchr, NELEMENTS(tchr), fname, -1); | |
| #else | |
| const TCHAR *tchr = fname; | |
| #endif | |
| ret = (HBITMAP)LoadImage(hInst, tchr, IMAGE_BITMAP, | |
| 0, 0, LR_LOADFROMFILE); | 0, 0, LR_LOADFROMFILE); |
| if (ret != NULL) { | if (ret != NULL) { |
| return(ret); | return(ret); |
| } | } |
| } | } |
| return(LoadBitmap(hInst, OEMTEXT("NP2TOOL"))); | return(LoadBitmap(hInst, _T("NP2TOOL"))); |
| } | } |
| Line 190 static void calctextsize(OEMCHAR *path, | Line 195 static void calctextsize(OEMCHAR *path, |
| GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); | GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); |
| pos = 0; | pos = 0; |
| while(pos < l) { | while(pos < l) { |
| step = ((((p[pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)?2:1; | #if defined(_UNICODE) |
| step = 1; | |
| #else | |
| step = (IsDBCSLeadByte((BYTE)p[pos]))?2:1; | |
| #endif | |
| GetTextExtentPoint32(hdc, p, pos + step, &cur); | GetTextExtentPoint32(hdc, p, pos + step, &cur); |
| if (cur.cx + tail.cx >= width) { | if (cur.cx + tail.cx >= width) { |
| break; | break; |
| Line 353 static LRESULT CALLBACK twsub(HWND hWnd, | Line 362 static LRESULT CALLBACK twsub(HWND hWnd, |
| else if (msg == WM_DROPFILES) { | else if (msg == WM_DROPFILES) { |
| files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); | files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); |
| if (files == 1) { | if (files == 1) { |
| #if defined(OSLANG_UTF8) | |
| TCHAR tchr[MAX_PATH]; | |
| DragQueryFile((HDROP)wp, 0, tchr, NELEMENTS(tchr)); | |
| tchartooem(fname, NELEMENTS(fname), tchr, -1); | |
| #else | |
| DragQueryFile((HDROP)wp, 0, fname, NELEMENTS(fname)); | DragQueryFile((HDROP)wp, 0, fname, NELEMENTS(fname)); |
| #endif | |
| if (idc == IDC_TOOLFDD1LIST) { | if (idc == IDC_TOOLFDD1LIST) { |
| diskdrv_setfdd(0, fname, 0); | diskdrv_setfdd(0, fname, 0); |
| toolwin_setfdd(0, fname); | toolwin_setfdd(0, fname); |
| Line 381 static LRESULT CALLBACK twsub(HWND hWnd, | Line 396 static LRESULT CALLBACK twsub(HWND hWnd, |
| } | } |
| } | } |
| else if (msg == WM_SETFOCUS) { | else if (msg == WM_SETFOCUS) { |
| SetWindowLong(GetParent(hWnd), GTWL_FOCUS, idc); | SetWindowLongPtr(GetParent(hWnd), GTWLP_FOCUS, idc); |
| } | } |
| return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); | return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); |
| } | } |
| static void toolwincreate(HWND hWnd) { | static void toolwincreate(HWND hWnd) { |
| HDC hdc; | #if defined(OSLANG_UTF8) |
| const SUBITEM *p; | TCHAR fontface[64]; |
| UINT i; | oemtotchar(fontface, NELEMENTS(fontface), toolskin.font, -1); |
| HWND sub; | #else |
| const OEMCHAR *cls; | const TCHAR *fontface = toolskin.font; |
| DWORD style; | #endif |
| toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, | toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, |
| SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, | SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, |
| DEFAULT_QUALITY, FIXED_PITCH, toolskin.font); | DEFAULT_QUALITY, FIXED_PITCH, fontface); |
| hdc = GetDC(NULL); | HDC hdc = GetDC(NULL); |
| toolwin.hdcfont = CreateCompatibleDC(hdc); | toolwin.hdcfont = CreateCompatibleDC(hdc); |
| ReleaseDC(NULL, hdc); | ReleaseDC(NULL, hdc); |
| SelectObject(toolwin.hdcfont, toolwin.hfont); | SelectObject(toolwin.hdcfont, toolwin.hfont); |
| Line 406 const OEMCHAR *cls; | Line 420 const OEMCHAR *cls; |
| toolwin.access[0] = CreateSolidBrush(0x000060); | toolwin.access[0] = CreateSolidBrush(0x000060); |
| toolwin.access[1] = CreateSolidBrush(0x0000ff); | toolwin.access[1] = CreateSolidBrush(0x0000ff); |
| p = subitem; | const SUBITEM *p = subitem; |
| UINT i; | |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| sub = NULL; | HWND sub = NULL; |
| cls = NULL; | const TCHAR *cls = NULL; |
| DWORD style; | |
| switch(p->tctl) { | switch(p->tctl) { |
| case TCTL_STATIC: | case TCTL_STATIC: |
| cls = str_static; | cls = str_static; |
| Line 433 const OEMCHAR *cls; | Line 449 const OEMCHAR *cls; |
| break; | break; |
| } | } |
| if ((cls) && (p->width > 0) && (p->height > 0)) { | if ((cls) && (p->width > 0) && (p->height > 0)) { |
| sub = CreateWindow(cls, p->text, WS_CHILD | WS_VISIBLE | style, | #if defined(OSLANG_UTF8) |
| TCHAR ptext[64]; | |
| oemtotchar(ptext, NELEMENTS(ptext), p->text, -1); | |
| #else | |
| const TCHAR *ptext = p->text; | |
| #endif | |
| sub = CreateWindow(cls, ptext, WS_CHILD | WS_VISIBLE | style, | |
| p->posx, p->posy, p->width, p->height, | p->posx, p->posy, p->width, p->height, |
| hWnd, (HMENU)(i + IDC_BASE), hInst, NULL); | hWnd, (HMENU)(i + IDC_BASE), hInst, NULL); |
| } | } |
| toolwin.sub[i] = sub; | toolwin.sub[i] = sub; |
| toolwin.subproc[i] = NULL; | toolwin.subproc[i] = NULL; |
| if (sub) { | if (sub) { |
| toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); | toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLongPtr(sub, |
| SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); | GWLP_WNDPROC); |
| SetWindowLongPtr(sub, GWLP_WNDPROC, (LONG_PTR)twsub); | |
| SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, | SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, |
| MAKELPARAM(TRUE, 0)); | MAKELPARAM(TRUE, 0)); |
| } | } |
| p++; | p++; |
| } | } |
| for (i=0; i<FDDLIST_DRV; i++) { | for (i=0; i<FDDLIST_DRV; i++) { |
| sub = toolwin.sub[fddlist[i]]; | HWND sub = toolwin.sub[fddlist[i]]; |
| if (sub) { | if (sub) { |
| DragAcceptFiles(sub, TRUE); | DragAcceptFiles(sub, TRUE); |
| remakefddlist(sub, np2tool.fdd + i); | remakefddlist(sub, np2tool.fdd + i); |
| Line 459 const OEMCHAR *cls; | Line 482 const OEMCHAR *cls; |
| break; | break; |
| } | } |
| } | } |
| SetWindowLong(hWnd, GTWL_FOCUS, i); | SetWindowLongPtr(hWnd, GTWLP_FOCUS, i); |
| } | } |
| static void toolwindestroy(void) { | static void toolwindestroy(void) { |
| Line 578 const OEMCHAR *file[SKINMRU_MAX]; | Line 601 const OEMCHAR *file[SKINMRU_MAX]; |
| for (i=0; i<cnt; i++) { | for (i=0; i<cnt; i++) { |
| j = id[i]; | j = id[i]; |
| flag = (!file_cmpname(base, np2tool.skinmru[j]))?MF_CHECKED:0; | flag = (!file_cmpname(base, np2tool.skinmru[j]))?MF_CHECKED:0; |
| AppendMenu(ret, MF_STRING + flag, IDM_SKINMRU + j, file[j]); | #if defined(OSLANG_UTF8) |
| TCHAR path[MAX_PATH]; | |
| oemtotchar(path, NELEMENTS(path), file[j], -1); | |
| #else | |
| const TCHAR *path = file[j]; | |
| #endif | |
| AppendMenu(ret, MF_STRING + flag, IDM_SKINMRU + j, path); | |
| } | } |
| return(ret); | return(ret); |
| } | } |
| Line 776 static LRESULT CALLBACK twproc(HWND hWnd | Line 805 static LRESULT CALLBACK twproc(HWND hWnd |
| case WM_KEYDOWN: // TABを押した時に復帰 | case WM_KEYDOWN: // TABを押した時に復帰 |
| if ((short)wp == VK_TAB) { | if ((short)wp == VK_TAB) { |
| idc = GetWindowLong(hWnd, GTWL_FOCUS); | idc = (UINT)GetWindowLongPtr(hWnd, GTWLP_FOCUS); |
| if (idc < IDC_MAXITEMS) { | if (idc < IDC_MAXITEMS) { |
| SetFocus(toolwin.sub[idc]); | SetFocus(toolwin.sub[idc]); |
| } | } |
| Line 795 static LRESULT CALLBACK twproc(HWND hWnd | Line 824 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case WM_DRAWITEM: | case WM_DRAWITEM: |
| tooldrawbutton(hWnd, wp, (LPDRAWITEMSTRUCT)lp); | tooldrawbutton(hWnd, (UINT)wp, (LPDRAWITEMSTRUCT)lp); |
| break; | break; |
| case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: |
| Line 878 BOOL toolwin_initapp(HINSTANCE hInstance | Line 907 BOOL toolwin_initapp(HINSTANCE hInstance |
| wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; |
| wc.lpfnWndProc = twproc; | wc.lpfnWndProc = twproc; |
| wc.cbClsExtra = 0; | wc.cbClsExtra = 0; |
| wc.cbWndExtra = GTWL_SIZE; | wc.cbWndExtra = GTWLP_SIZE; |
| wc.hInstance = hInstance; | wc.hInstance = hInstance; |
| wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); |
| wc.hCursor = LoadCursor(NULL, IDC_ARROW); | wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
| Line 1054 const DISKACC *accterm; | Line 1083 const DISKACC *accterm; |
| static const OEMCHAR ini_title[] = OEMTEXT("NP2 tool"); | static const OEMCHAR ini_title[] = OEMTEXT("NP2 tool"); |
| static const INITBL iniitem[] = { | static const PFTBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | PFVAL("WindposX", PFTYPE_SINT32, &np2tool.posx), |
| {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, | PFVAL("WindposY", PFTYPE_SINT32, &np2tool.posy), |
| {"WindType", INITYPE_BOOL, &np2tool.type, 0}, | PFVAL("WindType", PFTYPE_BOOL, &np2tool.type), |
| {"SkinFile", INITYPE_STR, np2tool.skin, MAX_PATH}, | PFSTR("SkinFile", PFTYPE_STR, np2tool.skin), |
| {"SkinMRU0", INITYPE_STR, np2tool.skinmru[0], MAX_PATH}, | PFSTR("SkinMRU0", PFTYPE_STR, np2tool.skinmru[0]), |
| {"SkinMRU1", INITYPE_STR, np2tool.skinmru[1], MAX_PATH}, | PFSTR("SkinMRU1", PFTYPE_STR, np2tool.skinmru[1]), |
| {"SkinMRU2", INITYPE_STR, np2tool.skinmru[2], MAX_PATH}, | PFSTR("SkinMRU2", PFTYPE_STR, np2tool.skinmru[2]), |
| {"SkinMRU3", INITYPE_STR, np2tool.skinmru[3], MAX_PATH}, | PFSTR("SkinMRU3", PFTYPE_STR, np2tool.skinmru[3]), |
| {"FD1NAME0", INITYPE_STR, np2tool.fdd[0].name[0], MAX_PATH}, | PFSTR("FD1NAME0", PFTYPE_STR, np2tool.fdd[0].name[0]), |
| {"FD1NAME1", INITYPE_STR, np2tool.fdd[0].name[1], MAX_PATH}, | PFSTR("FD1NAME1", PFTYPE_STR, np2tool.fdd[0].name[1]), |
| {"FD1NAME2", INITYPE_STR, np2tool.fdd[0].name[2], MAX_PATH}, | PFSTR("FD1NAME2", PFTYPE_STR, np2tool.fdd[0].name[2]), |
| {"FD1NAME3", INITYPE_STR, np2tool.fdd[0].name[3], MAX_PATH}, | PFSTR("FD1NAME3", PFTYPE_STR, np2tool.fdd[0].name[3]), |
| {"FD1NAME4", INITYPE_STR, np2tool.fdd[0].name[4], MAX_PATH}, | PFSTR("FD1NAME4", PFTYPE_STR, np2tool.fdd[0].name[4]), |
| {"FD1NAME5", INITYPE_STR, np2tool.fdd[0].name[5], MAX_PATH}, | PFSTR("FD1NAME5", PFTYPE_STR, np2tool.fdd[0].name[5]), |
| {"FD1NAME6", INITYPE_STR, np2tool.fdd[0].name[6], MAX_PATH}, | PFSTR("FD1NAME6", PFTYPE_STR, np2tool.fdd[0].name[6]), |
| {"FD1NAME7", INITYPE_STR, np2tool.fdd[0].name[7], MAX_PATH}, | PFSTR("FD1NAME7", PFTYPE_STR, np2tool.fdd[0].name[7]), |
| {"FD2NAME0", INITYPE_STR, np2tool.fdd[1].name[0], MAX_PATH}, | PFSTR("FD2NAME0", PFTYPE_STR, np2tool.fdd[1].name[0]), |
| {"FD2NAME1", INITYPE_STR, np2tool.fdd[1].name[1], MAX_PATH}, | PFSTR("FD2NAME1", PFTYPE_STR, np2tool.fdd[1].name[1]), |
| {"FD2NAME2", INITYPE_STR, np2tool.fdd[1].name[2], MAX_PATH}, | PFSTR("FD2NAME2", PFTYPE_STR, np2tool.fdd[1].name[2]), |
| {"FD2NAME3", INITYPE_STR, np2tool.fdd[1].name[3], MAX_PATH}, | PFSTR("FD2NAME3", PFTYPE_STR, np2tool.fdd[1].name[3]), |
| {"FD2NAME4", INITYPE_STR, np2tool.fdd[1].name[4], MAX_PATH}, | PFSTR("FD2NAME4", PFTYPE_STR, np2tool.fdd[1].name[4]), |
| {"FD2NAME5", INITYPE_STR, np2tool.fdd[1].name[5], MAX_PATH}, | PFSTR("FD2NAME5", PFTYPE_STR, np2tool.fdd[1].name[5]), |
| {"FD2NAME6", INITYPE_STR, np2tool.fdd[1].name[6], MAX_PATH}, | PFSTR("FD2NAME6", PFTYPE_STR, np2tool.fdd[1].name[6]), |
| {"FD2NAME7", INITYPE_STR, np2tool.fdd[1].name[7], MAX_PATH}}; | PFSTR("FD2NAME7", PFTYPE_STR, np2tool.fdd[1].name[7])}; |
| void toolwin_readini(void) { | void toolwin_readini(void) { |