--- np2/win9x/toolwin.cpp 2005/02/09 20:11:35 1.17 +++ np2/win9x/toolwin.cpp 2007/01/08 08:52:21 1.23 @@ -3,6 +3,7 @@ #include "resource.h" #include "np2.h" #include "winloc.h" +#include "oemtext.h" #include "dosio.h" #include "soundmng.h" #include "sysmng.h" @@ -88,10 +89,8 @@ typedef struct { SUBCLASSPROC subproc[IDC_MAXITEMS]; } TOOLWIN; -enum { - GTWL_FOCUS = NP2GWL_SIZE + 0, - GTWL_SIZE = NP2GWL_SIZE + 4 -}; +#define GTWLP_FOCUS (NP2GWLP_SIZE + (0 * sizeof(LONG_PTR))) +#define GTWLP_SIZE (NP2GWLP_SIZE + (1 * sizeof(LONG_PTR))) NP2TOOL np2tool; static TOOLSKIN toolskin; @@ -148,13 +147,19 @@ static HBITMAP skinload(const OEMCHAR *p milstr_ncpy(fname, path, NELEMENTS(fname)); file_cutname(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); if (ret != NULL) { return(ret); } } - return(LoadBitmap(hInst, OEMTEXT("NP2TOOL"))); + return(LoadBitmap(hInst, _T("NP2TOOL"))); } @@ -190,7 +195,11 @@ static void calctextsize(OEMCHAR *path, GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); pos = 0; 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); if (cur.cx + tail.cx >= width) { break; @@ -353,7 +362,13 @@ static LRESULT CALLBACK twsub(HWND hWnd, else if (msg == WM_DROPFILES) { files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); 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)); +#endif if (idc == IDC_TOOLFDD1LIST) { diskdrv_setfdd(0, fname, 0); toolwin_setfdd(0, fname); @@ -381,24 +396,23 @@ static LRESULT CALLBACK twsub(HWND hWnd, } } 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)); } static void toolwincreate(HWND hWnd) { - HDC hdc; -const SUBITEM *p; - UINT i; - HWND sub; -const OEMCHAR *cls; - DWORD style; - +#if defined(OSLANG_UTF8) + TCHAR fontface[64]; + oemtotchar(fontface, NELEMENTS(fontface), toolskin.font, -1); +#else + const TCHAR *fontface = toolskin.font; +#endif toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, FIXED_PITCH, toolskin.font); - hdc = GetDC(NULL); + DEFAULT_QUALITY, FIXED_PITCH, fontface); + HDC hdc = GetDC(NULL); toolwin.hdcfont = CreateCompatibleDC(hdc); ReleaseDC(NULL, hdc); SelectObject(toolwin.hdcfont, toolwin.hfont); @@ -406,10 +420,12 @@ const OEMCHAR *cls; toolwin.access[0] = CreateSolidBrush(0x000060); toolwin.access[1] = CreateSolidBrush(0x0000ff); - p = subitem; + const SUBITEM *p = subitem; + UINT i; for (i=0; itctl) { case TCTL_STATIC: cls = str_static; @@ -433,22 +449,29 @@ const OEMCHAR *cls; break; } 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, hWnd, (HMENU)(i + IDC_BASE), hInst, NULL); } toolwin.sub[i] = sub; toolwin.subproc[i] = NULL; if (sub) { - toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); - SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); + toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLongPtr(sub, + GWLP_WNDPROC); + SetWindowLongPtr(sub, GWLP_WNDPROC, (LONG_PTR)twsub); SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, MAKELPARAM(TRUE, 0)); } p++; } for (i=0; i