| version 1.9, 2003/10/30 18:09:06 | version 1.21, 2006/12/24 00:52:30 | 
| Line 2 | Line 2 | 
 | #include        "strres.h" | #include        "strres.h" | 
 | #include        "resource.h" | #include        "resource.h" | 
 | #include        "np2.h" | #include        "np2.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" | 
 | #include        "menu.h" | #include        "menu.h" | 
 | #include        "toolwin.h" | #include        "toolwin.h" | 
 | #include        "ini.h" | #include        "ini.h" | 
 |  | #include        "np2class.h" | 
 | #include        "dialog.h" | #include        "dialog.h" | 
 | #include        "dialogs.h" | #include        "dialogs.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 | #include        "diskdrv.h" | #include        "diskdrv.h" | 
 |  |  | 
 |  |  | 
 |  | extern WINLOCEX np2_winlocexallwin(HWND base); | 
 |  |  | 
 |  |  | 
 | enum { | enum { | 
 | IDC_TOOLHDDACC                  = 0, | IDC_TOOLHDDACC                  = 0, | 
 | IDC_TOOLFDD1ACC, | IDC_TOOLFDD1ACC, | 
| Line 30  enum { | Line 36  enum { | 
 |  |  | 
 | IDC_BASE                                = 3000, | IDC_BASE                                = 3000, | 
 |  |  | 
| IDC_SKINDEF                             = 3100, | IDM_SKINSEL                             = 3100, | 
| IDC_SKINSEL                             = 3101, | IDM_SKINDEF                             = 3101, | 
| IDC_TOOLCLOSE                   = 3102 | IDM_SKINMRU                             = 3102, | 
|  | IDM_TOOLCLOSE                   = IDM_SKINMRU + SKINMRU_MAX | 
 | }; | }; | 
 |  |  | 
 | enum { | enum { | 
| Line 42  enum { | Line 49  enum { | 
 | }; | }; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| char    main[MAX_PATH]; | OEMCHAR main[MAX_PATH]; | 
| char    font[64]; | OEMCHAR font[64]; | 
 | SINT32  fontsize; | SINT32  fontsize; | 
 | UINT32  color1; | UINT32  color1; | 
 | UINT32  color2; | UINT32  color2; | 
 | } TOOLSKIN; | } TOOLSKIN; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| UINT    tctl; | UINT            tctl; | 
| const char      *text; | const OEMCHAR   *text; | 
| short   posx; | short           posx; | 
| short   posy; | short           posy; | 
| short   width; | short           width; | 
| short   height; | short           height; | 
| short   extend; | short           extend; | 
| short   padding; | short           padding; | 
 | } SUBITEM; | } SUBITEM; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
 | HWND                    hwnd; | HWND                    hwnd; | 
 |  | WINLOCEX                wlex; | 
 | HBITMAP                 hbmp; | HBITMAP                 hbmp; | 
| BYTE                    fddaccess[2]; | UINT8                   fddaccess[2]; | 
| BYTE                    hddaccess; | UINT8                   hddaccess; | 
| BYTE                    _padding; | UINT8                   _padding; | 
 | int                             winflg; | int                             winflg; | 
 | int                             wingx; | int                             wingx; | 
 | int                             wingy; | int                             wingy; | 
| Line 82  typedef struct { | Line 90  typedef struct { | 
 | } TOOLWIN; | } TOOLWIN; | 
 |  |  | 
 | enum { | enum { | 
| GTWL_FOCUS              = 0, | GTWL_FOCUS              = NP2GWL_SIZE + 0, | 
| GTWL_SIZE               = 4 | GTWL_SIZE               = NP2GWL_SIZE + 4 | 
 | }; | }; | 
 |  |  | 
 | NP2TOOL         np2tool; | NP2TOOL         np2tool; | 
| Line 95  static TOOLWIN  toolwin; | Line 103  static TOOLWIN  toolwin; | 
 |  |  | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| WORD    idc; | UINT16  idc; | 
| BYTE    *counter; | UINT8   *counter; | 
 | } DISKACC; | } DISKACC; | 
 |  |  | 
| static const BYTE fddlist[FDDLIST_DRV] = { | static const UINT8 fddlist[FDDLIST_DRV] = { | 
 | IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | 
 |  |  | 
 | static const DISKACC diskacc[3] = { | static const DISKACC diskacc[3] = { | 
| Line 110  static const DISKACC diskacc[3] = { | Line 118  static const DISKACC diskacc[3] = { | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static HBITMAP skinload(const char *path) { | static HBITMAP skinload(const OEMCHAR *path) { | 
 |  |  | 
| char    fname[MAX_PATH]; | OEMCHAR fname[MAX_PATH]; | 
|  | UINT    i; | 
 | HBITMAP ret; | HBITMAP ret; | 
 |  |  | 
 | ZeroMemory(&toolskin, sizeof(toolskin)); | ZeroMemory(&toolskin, sizeof(toolskin)); | 
 | toolskin.fontsize = 12; | toolskin.fontsize = 12; | 
| milstr_ncpy(toolskin.font, str_deffont, sizeof(toolskin.font)); | milstr_ncpy(toolskin.font, str_deffont, NELEMENTS(toolskin.font)); | 
 | toolskin.color1 = 0x600000; | toolskin.color1 = 0x600000; | 
 | toolskin.color2 = 0xff0000; | toolskin.color2 = 0xff0000; | 
 | CopyMemory(subitem, defsubitem, sizeof(defsubitem)); |  | 
 |  |  | 
 | if (path) { | if (path) { | 
| ini_read(path, skintitle, skinini, sizeof(skinini)/sizeof(INITBL)); | ini_read(path, skintitle, skinini1, NELEMENTS(skinini1)); | 
|  | } | 
|  | if (toolskin.main[0]) { | 
|  | ZeroMemory(subitem, sizeof(defsubitem)); | 
|  | for (i=0; i<IDC_MAXITEMS; i++) { | 
|  | subitem[i].tctl = defsubitem[i].tctl; | 
|  | subitem[i].text = defsubitem[i].text; | 
|  | } | 
 | } | } | 
| if ((path) && (toolskin.main[0])) { | else { | 
| milstr_ncpy(fname, path, sizeof(fname)); | CopyMemory(subitem, defsubitem, sizeof(defsubitem)); | 
|  | } | 
|  | if (path) { | 
|  | ini_read(path, skintitle, skinini2, NELEMENTS(skinini2)); | 
|  | } | 
|  | if (toolskin.main[0]) { | 
|  | milstr_ncpy(fname, path, NELEMENTS(fname)); | 
 | file_cutname(fname); | file_cutname(fname); | 
| file_catname(fname, toolskin.main, sizeof(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, "NP2TOOL")); | return(LoadBitmap(hInst, _T("NP2TOOL"))); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static void calctextsize(char *path, int leng, const char *p, int width) { | static void calctextsize(OEMCHAR *path, int leng, const OEMCHAR *p, int width) { | 
 |  |  | 
 | HDC             hdc; | HDC             hdc; | 
 | SIZE    cur; | SIZE    cur; | 
| char    work[MAX_PATH]; | OEMCHAR work[MAX_PATH]; | 
 | int             l; | int             l; | 
 | SIZE    tail; | SIZE    tail; | 
 | int             pos; | int             pos; | 
| Line 153  static void calctextsize(char *path, int | Line 179  static void calctextsize(char *path, int | 
 |  |  | 
 | milstr_ncpy(path, p, leng); | milstr_ncpy(path, p, leng); | 
 | hdc = toolwin.hdcfont; | hdc = toolwin.hdcfont; | 
| GetTextExtentPoint32(hdc, p, strlen(p), &cur); | GetTextExtentPoint32(hdc, p, OEMSTRLEN(p), &cur); | 
 | if (cur.cx < width) { | if (cur.cx < width) { | 
 | return; | return; | 
 | } | } | 
| Line 161  static void calctextsize(char *path, int | Line 187  static void calctextsize(char *path, int | 
 | file_cutname(path); | file_cutname(path); | 
 | file_cutseparator(path); | file_cutseparator(path); | 
 | file_cutname(path); | file_cutname(path); | 
| l = strlen(path); | file_cutseparator(path); | 
| if (l > 1) { | l = OEMSTRLEN(path); | 
| l -= 1; | work[0] = '\0'; | 
| if (milstr_kanji2nd(p, l - 1)) { | if (l) { | 
| l--; | milstr_ncpy(work, str_browse, NELEMENTS(work)); | 
| } |  | 
| } |  | 
| else { |  | 
| l = 0; |  | 
 | } | } | 
| milstr_ncpy(work, str_browse, sizeof(work)); | milstr_ncat(work, p + l, NELEMENTS(work)); | 
| milstr_ncat(work, p + l, sizeof(work)); | GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); | 
| GetTextExtentPoint32(hdc, work, strlen(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 191  static void calctextsize(char *path, int | Line 216  static void calctextsize(char *path, int | 
 |  |  | 
 | static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { | static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { | 
 |  |  | 
| RECT    rc; | RECT            rc; | 
| int             width; | int                     width; | 
| char    basedir[MAX_PATH]; | OEMCHAR         basedir[MAX_PATH]; | 
| UINT    i; | UINT            i; | 
| const char      *p; | const OEMCHAR   *p; | 
| char    dir[MAX_PATH]; | OEMCHAR         dir[MAX_PATH]; | 
| const char      *q; | const OEMCHAR   *q; | 
 |  |  | 
 | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); | 
 | GetClientRect(hwnd, &rc); | GetClientRect(hwnd, &rc); | 
 | width = rc.right - rc.left - 6;                 // border size? | width = rc.right - rc.left - 6;                 // border size? | 
 | basedir[0] = '\0'; | basedir[0] = '\0'; | 
 | if (sel < fdd->cnt) { | if (sel < fdd->cnt) { | 
| milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], sizeof(basedir)); | milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], NELEMENTS(basedir)); | 
 | file_cutname(basedir); | file_cutname(basedir); | 
 | } | } | 
 | for (i=0; i<fdd->cnt; i++) { | for (i=0; i<fdd->cnt; i++) { | 
 | p = fdd->name[fdd->pos[i]]; | p = fdd->name[fdd->pos[i]]; | 
| milstr_ncpy(dir, p, sizeof(dir)); | milstr_ncpy(dir, p, NELEMENTS(dir)); | 
 | file_cutname(dir); | file_cutname(dir); | 
 | if (!file_cmpname(basedir, dir)) { | if (!file_cmpname(basedir, dir)) { | 
| q = file_getname((char *)p); | q = file_getname(p); | 
 | } | } | 
 | else { | else { | 
| calctextsize(dir, sizeof(dir), p, width); | calctextsize(dir, NELEMENTS(dir), p, width); | 
 | q = dir; | q = dir; | 
 | } | } | 
 | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | 
| p += sizeof(fdd->name[0]); | p += NELEMENTS(fdd->name[0]); | 
 | } | } | 
 | if (sel < fdd->cnt) { | if (sel < fdd->cnt) { | 
 | SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); | SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); | 
| Line 247  static void sellist(UINT drv) { | Line 272  static void sellist(UINT drv) { | 
 |  |  | 
 | static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { | static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { | 
 |  |  | 
| char    *p; | OEMCHAR *p; | 
 | UINT    cnt; | UINT    cnt; | 
| char    *q; | OEMCHAR *q; | 
| char    *fname[FDDLIST_MAX]; | OEMCHAR *fname[FDDLIST_MAX]; | 
 | UINT    i; | UINT    i; | 
 | UINT    j; | UINT    j; | 
 | UINT    sel; | UINT    sel; | 
| Line 271  static void remakefddlist(HWND hwnd, TOO | Line 296  static void remakefddlist(HWND hwnd, TOO | 
 | fdd->pos[j] = fdd->pos[j-1]; | fdd->pos[j] = fdd->pos[j-1]; | 
 | } | } | 
 | fdd->pos[i] = cnt; | fdd->pos[i] = cnt; | 
| p += sizeof(fdd->name[0]); | p += NELEMENTS(fdd->name[0]); | 
 | } | } | 
 | fdd->cnt = cnt; | fdd->cnt = cnt; | 
 | sel = (UINT)-1; | sel = (UINT)-1; | 
| Line 286  static void remakefddlist(HWND hwnd, TOO | Line 311  static void remakefddlist(HWND hwnd, TOO | 
 | setlist(hwnd, fdd, sel); | setlist(hwnd, fdd, sel); | 
 | } | } | 
 |  |  | 
| static void accdraw(HWND hWnd, BYTE count) { | static void accdraw(HWND hWnd, UINT8 count) { | 
 |  |  | 
 | HDC                     hdc; | HDC                     hdc; | 
 | PAINTSTRUCT     ps; | PAINTSTRUCT     ps; | 
| Line 307  static LRESULT CALLBACK twsub(HWND hWnd, | Line 332  static LRESULT CALLBACK twsub(HWND hWnd, | 
 | int             dir; | int             dir; | 
 | UINT    newidc; | UINT    newidc; | 
 | int             files; | int             files; | 
| char    fname[MAX_PATH]; | OEMCHAR fname[MAX_PATH]; | 
 |  |  | 
 | idc = GetWindowLong(hWnd, GWL_ID) - IDC_BASE; | idc = GetWindowLong(hWnd, GWL_ID) - IDC_BASE; | 
 | if (idc >= IDC_MAXITEMS) { | if (idc >= IDC_MAXITEMS) { | 
 | return(0); | return(0); | 
 | } | } | 
 | if (msg == WM_KEYDOWN) { | if (msg == WM_KEYDOWN) { | 
| if ((TCHAR)wp == VK_TAB) { | if ((short)wp == VK_TAB) { | 
 | dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; | dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; | 
 | newidc = idc; | newidc = idc; | 
 | do { | do { | 
| Line 329  static LRESULT CALLBACK twsub(HWND hWnd, | Line 354  static LRESULT CALLBACK twsub(HWND hWnd, | 
 | } | } | 
 | } while(idc != newidc); | } while(idc != newidc); | 
 | } | } | 
| else if ((TCHAR)wp == VK_RETURN) { | else if ((short)wp == VK_RETURN) { | 
 | if (subitem[idc].tctl == TCTL_BUTTON) { | if (subitem[idc].tctl == TCTL_BUTTON) { | 
 | return(CallWindowProc(toolwin.subproc[idc], | return(CallWindowProc(toolwin.subproc[idc], | 
 | hWnd, WM_KEYDOWN, VK_SPACE, 0)); | hWnd, WM_KEYDOWN, VK_SPACE, 0)); | 
| Line 339  static LRESULT CALLBACK twsub(HWND hWnd, | Line 364  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) { | 
| DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); | #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) { | if (idc == IDC_TOOLFDD1LIST) { | 
 | diskdrv_setfdd(0, fname, 0); | diskdrv_setfdd(0, fname, 0); | 
 | toolwin_setfdd(0, fname); | toolwin_setfdd(0, fname); | 
| Line 374  static LRESULT CALLBACK twsub(HWND hWnd, | Line 405  static LRESULT CALLBACK twsub(HWND hWnd, | 
 |  |  | 
 | 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 char              *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 392  const char  *cls; | Line 422  const char  *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 419  const char  *cls; | Line 451  const char  *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] = GetWindowProc(sub); | 
| SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); | SetWindowProc(sub, 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 487  static void toolwinpaint(HWND hWnd) { | Line 525  static void toolwinpaint(HWND hWnd) { | 
 | EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); | 
 | } | } | 
 |  |  | 
| static void tooldrawbutton(HWND hWnd, HDC hdc, UINT idc) { | static void tooldrawbutton(HWND hWnd, UINT idc, LPDRAWITEMSTRUCT lpdis) { | 
 |  |  | 
 | POINT   pt; | POINT   pt; | 
 | HWND    sub; | HWND    sub; | 
 | RECT    rect; | RECT    rect; | 
 |  | HDC             hdc; | 
 | HDC             hmdc; | HDC             hmdc; | 
 | RECT    btn; | RECT    btn; | 
 |  |  | 
| Line 508  static void tooldrawbutton(HWND hWnd, HD | Line 547  static void tooldrawbutton(HWND hWnd, HD | 
 | btn.top = 0; | btn.top = 0; | 
 | btn.right = rect.right - rect.left; | btn.right = rect.right - rect.left; | 
 | btn.bottom = rect.bottom - rect.top; | btn.bottom = rect.bottom - rect.top; | 
 |  | hdc = lpdis->hDC; | 
 | if (toolwin.hbmp) { | if (toolwin.hbmp) { | 
 | hmdc = CreateCompatibleDC(hdc); | hmdc = CreateCompatibleDC(hdc); | 
 | SelectObject(hmdc, toolwin.hbmp); | SelectObject(hmdc, toolwin.hbmp); | 
 | BitBlt(hdc, 0, 0, btn.right, btn.bottom, | BitBlt(hdc, 0, 0, btn.right, btn.bottom, | 
 | hmdc, rect.left - pt.x, rect.top - pt.y, SRCCOPY); | hmdc, rect.left - pt.x, rect.top - pt.y, SRCCOPY); | 
 | DeleteDC(hmdc); | DeleteDC(hmdc); | 
 | if (GetFocus() == sub) { |  | 
 | DrawFocusRect(hdc, &btn); |  | 
 | } |  | 
 | } | } | 
| } | if (lpdis->itemState & ODS_FOCUS) { | 
|  | DrawFocusRect(hdc, &btn); | 
| static void changeskin(HWND hWnd) { |  | 
|  |  | 
| HBITMAP hbmp; |  | 
| BITMAP  bmp; |  | 
|  |  | 
| toolwin_movingstart(); |  | 
| toolwindestroy(); |  | 
| hbmp = skinload(np2tool.skin); |  | 
| if (hbmp == NULL) { |  | 
| SendMessage(hWnd, WM_CLOSE, 0, 0); |  | 
| return; |  | 
 | } | } | 
 | GetObject(hbmp, sizeof(BITMAP), &bmp); |  | 
 | toolwin.hbmp = hbmp; |  | 
 | MoveWindow(hWnd, np2tool.posx, np2tool.posy, |  | 
 | bmp.bmWidth, bmp.bmHeight, TRUE); |  | 
 | toolwincreate(hWnd); |  | 
 | toolwin_movingend(); |  | 
 | } | } | 
 |  |  | 
 |  |  | 
| // ---- moving | // ---- | 
|  |  | 
| enum { |  | 
| SNAPDOTPULL             = 12, |  | 
| SNAPDOTREL              = 16 |  | 
| }; |  | 
|  |  | 
| static void movingstart(void) { |  | 
|  |  | 
| toolwin.winflg = 0; |  | 
| toolwin.wingx = 0; |  | 
| toolwin.wingy = 0; |  | 
| } |  | 
|  |  | 
| static void movingproc(RECT *rect) { |  | 
|  |  | 
| RECT    workrc; |  | 
| RECT    mainrc; |  | 
| int             winlx; |  | 
| int             winly; |  | 
| BOOL    changes; |  | 
| BOOL    connectx; |  | 
| BOOL    connecty; |  | 
| int             d; |  | 
|  |  | 
| SystemParametersInfo(SPI_GETWORKAREA, 0, &workrc, 0); |  | 
| GetWindowRect(hWndMain, &mainrc); |  | 
| winlx = rect->right - rect->left; |  | 
| winly = rect->bottom - rect->top; |  | 
 |  |  | 
| if ((winlx > (workrc.right - workrc.left)) || | static HMENU createskinmenu(void) { | 
| (winly > (workrc.bottom - workrc.top))) { |  | 
| return; |  | 
| } |  | 
 |  |  | 
| if (toolwin.winflg & 0x03) { | HMENU           ret; | 
| toolwin.wingx += rect->left - toolwin.wintx; | UINT            cnt; | 
| rect->left = toolwin.wintx; | const OEMCHAR   *base; | 
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | UINT            flag; | 
| toolwin.winflg &= ~0x03; | OEMCHAR         *p; | 
| rect->left += toolwin.wingx; | UINT            i; | 
| toolwin.wingx = 0; | UINT            j; | 
| } | UINT            id[SKINMRU_MAX]; | 
| rect->right = rect->left + winlx; | const OEMCHAR   *file[SKINMRU_MAX]; | 
| } |  | 
| if (toolwin.winflg & 0x0c) { | ret = CreatePopupMenu(); | 
| toolwin.wingy += rect->top - toolwin.winty; | AppendMenu(ret, MF_STRING, IDM_SKINSEL, str_skinsel); | 
| rect->top = toolwin.winty; | AppendMenu(ret, MF_SEPARATOR, 0, NULL); | 
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { |  | 
| toolwin.winflg &= ~0x0c; | base = np2tool.skin; | 
| rect->top += toolwin.wingy; | flag = (base[0] == '\0')?MF_CHECKED:0; | 
| toolwin.wingy = 0; | AppendMenu(ret, MF_STRING + flag, IDM_SKINDEF, str_skindef); | 
| } | for (cnt=0; cnt<SKINMRU_MAX; cnt++) { | 
| rect->bottom = rect->top + winly; | p = np2tool.skinmru[cnt]; | 
| } | if (p[0] == '\0') { | 
|  | break; | 
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); |  | 
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); |  | 
| if ((!connectx) || (!connecty)) { |  | 
| if (toolwin.winflg & 0x01) { |  | 
| toolwin.winflg &= ~0x01; |  | 
| rect->left += toolwin.wingx; |  | 
| rect->right = rect->left + winlx; |  | 
| toolwin.wingx = 0; |  | 
| } |  | 
| if (toolwin.winflg & 0x04) { |  | 
| toolwin.winflg &= ~0x04; |  | 
| rect->top += toolwin.wingy; |  | 
| rect->bottom = rect->top + winly; |  | 
| toolwin.wingy = 0; |  | 
 | } | } | 
| } | p = file_getname(p); | 
|  | for (i=0; i<cnt; i++) { | 
| do { | if (file_cmpname(p, file[id[i]]) < 0) { | 
| changes = FALSE; | break; | 
| if ((!(toolwin.winflg & 0x01)) && |  | 
| (rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)) { |  | 
| do { |  | 
| d = rect->left - mainrc.right; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| d = rect->right - mainrc.left; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| if ((rect->bottom == mainrc.top) || |  | 
| (rect->top == mainrc.bottom)) { |  | 
| d = rect->left - mainrc.left; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| d = rect->right - mainrc.right; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } |  | 
| } while(0); |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| toolwin.winflg |= 0x01; |  | 
| rect->left -= d; |  | 
| rect->right = rect->left + winlx; |  | 
| toolwin.wingx = d; |  | 
| toolwin.wintx = rect->left; |  | 
| changes = TRUE; |  | 
 | } | } | 
 | } | } | 
| if (!(toolwin.winflg & 0x03)) { | for (j=cnt; j>i; j--) { | 
| do { | id[j] = id[j-1]; | 
| d = rect->left - workrc.left; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| d = rect->right - workrc.right; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } while(0); |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| toolwin.winflg |= 0x02; |  | 
| rect->left -= d; |  | 
| rect->right = rect->left + winlx; |  | 
| toolwin.wingx = d; |  | 
| toolwin.wintx = rect->left; |  | 
| changes = TRUE; |  | 
| } |  | 
 | } | } | 
 |  | id[i] = cnt; | 
 |  | file[cnt] = p; | 
 |  | } | 
 |  | for (i=0; i<cnt; i++) { | 
 |  | j = id[i]; | 
 |  | flag = (!file_cmpname(base, np2tool.skinmru[j]))?MF_CHECKED:0; | 
 |  | #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); | 
 |  | } | 
 |  |  | 
| if ((!(toolwin.winflg & 0x04)) && | static void skinchange(HWND hWnd) { | 
| (rect->right >= mainrc.left) && (rect->left <= mainrc.right)) { |  | 
| do { | const OEMCHAR   *p; | 
| d = rect->top - mainrc.bottom; | UINT            i; | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | HBITMAP         hbmp; | 
| break; | BITMAP          bmp; | 
| } | WINLOCEX        wlex; | 
| d = rect->bottom - mainrc.top; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | p = np2tool.skin; | 
| break; | if (p[0]) { | 
| } | for (i=0; i<(SKINMRU_MAX - 1); i++) { | 
| if ((rect->right == mainrc.left) || | if (!file_cmpname(p, np2tool.skinmru[i])) { | 
| (rect->left == mainrc.right)) { | break; | 
| d = rect->top - mainrc.top; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| d = rect->bottom - mainrc.bottom; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } |  | 
| } while(0); |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| toolwin.winflg |= 0x04; |  | 
| rect->top -= d; |  | 
| rect->bottom = rect->top + winly; |  | 
| toolwin.wingy = d; |  | 
| toolwin.winty = rect->top; |  | 
| changes = TRUE; |  | 
 | } | } | 
 | } | } | 
| if (!(toolwin.winflg & 0x0c)) { | while(i > 0) { | 
| do { | CopyMemory(np2tool.skinmru[i], np2tool.skinmru[i-1], | 
| d = rect->top - workrc.top; | sizeof(np2tool.skinmru[0])); | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | i--; | 
| break; |  | 
| } |  | 
| d = rect->bottom - workrc.bottom; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } while(0); |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| toolwin.winflg |= 0x08; |  | 
| rect->top -= d; |  | 
| rect->bottom = rect->top + winly; |  | 
| toolwin.wingy = d; |  | 
| toolwin.winty = rect->top; |  | 
| changes = TRUE; |  | 
| } |  | 
 | } | } | 
| } while(changes); | file_cpyname(np2tool.skinmru[0], p, NELEMENTS(np2tool.skinmru[0])); | 
|  | } | 
|  | ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | 
|  | (UINT)createskinmenu(), str_toolskin); | 
|  | ModifyMenu(GetSystemMenu(hWnd, FALSE), 0, MF_BYPOSITION | MF_POPUP, | 
|  | (UINT)createskinmenu(), str_toolskin); | 
|  | DrawMenuBar(hWnd); | 
|  | sysmng_update(SYS_UPDATEOSCFG); | 
|  |  | 
|  | wlex = np2_winlocexallwin(hWndMain); | 
|  | winlocex_setholdwnd(wlex, hWnd); | 
|  | toolwindestroy(); | 
|  | hbmp = skinload(np2tool.skin); | 
|  | if (hbmp == NULL) { | 
|  | SendMessage(hWnd, WM_CLOSE, 0, 0); | 
|  | return; | 
|  | } | 
|  | GetObject(hbmp, sizeof(BITMAP), &bmp); | 
|  | toolwin.hbmp = hbmp; | 
|  | winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); | 
|  | toolwincreate(hWnd); | 
|  | winlocex_move(wlex); | 
|  | winlocex_destroy(wlex); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static void open_popup(HWND hWnd, LPARAM lp) { | static void openpopup(HWND hWnd, LPARAM lp) { | 
 |  |  | 
| HMENU           hMenu; | HMENU   hMenu; | 
| POINT           pt; | HMENU   mainmenu; | 
|  | POINT   pt; | 
 |  |  | 
 | hMenu = CreatePopupMenu(); | hMenu = CreatePopupMenu(); | 
| AppendMenu(hMenu, MF_STRING, IDC_SKINDEF, str_skindef); | if (!winui_en) { | 
| AppendMenu(hMenu, MF_STRING, IDC_SKINSEL, str_skinsel); | mainmenu = np2class_gethmenu(hWndMain); | 
|  | menu_addmenubar(hMenu, mainmenu); | 
|  | } | 
|  | AppendMenu(hMenu, MF_POPUP, (UINT)createskinmenu(), str_toolskin); | 
 | AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); | AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); | 
| AppendMenu(hMenu, MF_STRING, IDC_TOOLCLOSE, str_toolclose); | AppendMenu(hMenu, MF_STRING, IDM_TOOLCLOSE, str_toolclose); | 
 | pt.x = LOWORD(lp); | pt.x = LOWORD(lp); | 
 | pt.y = HIWORD(lp); | pt.y = HIWORD(lp); | 
 | ClientToScreen(hWnd, &pt); | ClientToScreen(hWnd, &pt); | 
| Line 746  static void open_popup(HWND hWnd, LPARAM | Line 684  static void open_popup(HWND hWnd, LPARAM | 
 |  |  | 
 | static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | 
 |  |  | 
| BOOL    r; | HMENU           hMenu; | 
| UINT    idc; | BOOL            r; | 
|  | UINT            idc; | 
|  | WINLOCEX        wlex; | 
 |  |  | 
 | switch(msg) { | switch(msg) { | 
 | case WM_CREATE: | case WM_CREATE: | 
| SetWindowLong(hWnd, GWL_STYLE, | np2class_wmcreate(hWnd); | 
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | 
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | (UINT)createskinmenu(), str_toolskin); | 
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | hMenu = GetSystemMenu(hWnd, FALSE); | 
|  | InsertMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, | 
|  | (UINT)createskinmenu(), str_toolskin); | 
|  | InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | 
|  |  | 
|  | np2class_windowtype(hWnd, (np2tool.type & 1) << 1); | 
 | toolwincreate(hWnd); | toolwincreate(hWnd); | 
 | break; | break; | 
 |  |  | 
 | case WM_SYSCOMMAND: | case WM_SYSCOMMAND: | 
 | switch(wp) { | switch(wp) { | 
| case IDC_SKINDEF: | case IDM_SKINSEL: | 
| np2tool.skin[0] = '\0'; | case IDM_SKINDEF: | 
| changeskin(hWnd); | case IDM_SKINMRU + 0: | 
| sysmng_update(SYS_UPDATEOSCFG); | case IDM_SKINMRU + 1: | 
| break; | case IDM_SKINMRU + 2: | 
|  | case IDM_SKINMRU + 3: | 
| case IDC_SKINSEL: | return(SendMessage(hWnd, WM_COMMAND, wp, lp)); | 
| soundmng_disable(SNDPROC_TOOL); |  | 
| r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, |  | 
| sizeof(np2tool.skin), NULL); |  | 
| soundmng_enable(SNDPROC_TOOL); |  | 
| if (r) { |  | 
| changeskin(hWnd); |  | 
| sysmng_update(SYS_UPDATEOSCFG); |  | 
| } |  | 
| break; |  | 
 |  |  | 
 | default: | default: | 
 | return(DefWindowProc(hWnd, msg, wp, lp)); | return(DefWindowProc(hWnd, msg, wp, lp)); | 
| Line 791  static LRESULT CALLBACK twproc(HWND hWnd | Line 727  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD1BROWSE: | case IDC_BASE + IDC_TOOLFDD1BROWSE: | 
| soundmng_disable(SNDPROC_TOOL); | if (!winui_en) { | 
| dialog_changefdd(hWnd, 0); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD1OPEN, 0); | 
| soundmng_enable(SNDPROC_TOOL); | } | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: | 
| Line 808  static LRESULT CALLBACK twproc(HWND hWnd | Line 744  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD2BROWSE: | case IDC_BASE + IDC_TOOLFDD2BROWSE: | 
| soundmng_disable(SNDPROC_TOOL); | if (!winui_en) { | 
| dialog_changefdd(hWnd, 1); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD2OPEN, 0); | 
| soundmng_enable(SNDPROC_TOOL); | } | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD2EJECT: | case IDC_BASE + IDC_TOOLFDD2EJECT: | 
| Line 819  static LRESULT CALLBACK twproc(HWND hWnd | Line 755  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLRESET: | case IDC_BASE + IDC_TOOLRESET: | 
| SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); | if (!winui_en) { | 
| SetForegroundWindow(hWndMain); | SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); | 
|  | SetForegroundWindow(hWndMain); | 
|  | } | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLPOWER: | case IDC_BASE + IDC_TOOLPOWER: | 
| SendMessage(hWndMain, WM_CLOSE, 0, 0L); | if (!winui_en) { | 
|  | SendMessage(hWndMain, WM_CLOSE, 0, 0L); | 
|  | } | 
|  | break; | 
|  |  | 
|  | case IDM_SKINSEL: | 
|  | soundmng_disable(SNDPROC_TOOL); | 
|  | r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, | 
|  | NELEMENTS(np2tool.skin), NULL); | 
|  | soundmng_enable(SNDPROC_TOOL); | 
|  | if (r) { | 
|  | skinchange(hWnd); | 
|  | } | 
 | break; | break; | 
 |  |  | 
| case IDC_SKINDEF: | case IDM_SKINDEF: | 
| case IDC_SKINSEL: | np2tool.skin[0] = '\0'; | 
| SendMessage(hWnd, WM_SYSCOMMAND, wp, lp); | skinchange(hWnd); | 
|  | break; | 
|  |  | 
|  | case IDM_SKINMRU + 0: | 
|  | case IDM_SKINMRU + 1: | 
|  | case IDM_SKINMRU + 2: | 
|  | case IDM_SKINMRU + 3: | 
|  | file_cpyname(np2tool.skin, | 
|  | np2tool.skinmru[LOWORD(wp) - IDM_SKINMRU], | 
|  | NELEMENTS(np2tool.skin)); | 
|  | skinchange(hWnd); | 
 | break; | break; | 
 |  |  | 
| case IDC_TOOLCLOSE: | case IDM_TOOLCLOSE: | 
 | SendMessage(hWnd, WM_CLOSE, 0, 0); | SendMessage(hWnd, WM_CLOSE, 0, 0); | 
 | break; | break; | 
 |  |  | 
 |  | default: | 
 |  | if (!winui_en) { | 
 |  | return(SendMessage(hWndMain, msg, wp, lp)); | 
 |  | } | 
 |  | break; | 
 | } | } | 
 | break; | break; | 
 |  |  | 
 | case WM_KEYDOWN:                                                // TAB¤ò²¡¤·¤¿»þ¤ËÉüµ¢ | case WM_KEYDOWN:                                                // TAB¤ò²¡¤·¤¿»þ¤ËÉüµ¢ | 
| if ((TCHAR)wp == VK_TAB) { | if ((short)wp == VK_TAB) { | 
 | idc = GetWindowLong(hWnd, GTWL_FOCUS); | idc = GetWindowLong(hWnd, GTWL_FOCUS); | 
 | if (idc < IDC_MAXITEMS) { | if (idc < IDC_MAXITEMS) { | 
 | SetFocus(toolwin.sub[idc]); | SetFocus(toolwin.sub[idc]); | 
 | } | } | 
 | return(0); | return(0); | 
 | } | } | 
| else if ((TCHAR)wp == VK_ESCAPE) { | return(SendMessage(hWndMain, msg, wp, lp)); | 
|  |  | 
|  | case WM_KEYUP: | 
|  | if ((short)wp == VK_TAB) { | 
 | return(0); | return(0); | 
 | } | } | 
| break; | return(SendMessage(hWndMain, msg, wp, lp)); | 
 |  |  | 
 | case WM_PAINT: | case WM_PAINT: | 
 | toolwinpaint(hWnd); | toolwinpaint(hWnd); | 
 | break; | break; | 
 |  |  | 
 | case WM_DRAWITEM: | case WM_DRAWITEM: | 
| tooldrawbutton(hWnd, ((LPDRAWITEMSTRUCT)lp)->hDC, wp); | tooldrawbutton(hWnd, wp, (LPDRAWITEMSTRUCT)lp); | 
 | break; | break; | 
 |  |  | 
 | case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: | 
| Line 870  static LRESULT CALLBACK twproc(HWND hWnd | Line 838  static LRESULT CALLBACK twproc(HWND hWnd | 
 |  |  | 
 | case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: | 
 | soundmng_disable(SNDPROC_TOOL); | soundmng_disable(SNDPROC_TOOL); | 
| movingstart(); | winlocex_destroy(toolwin.wlex); | 
|  | toolwin.wlex = np2_winlocexallwin(hWnd); | 
 | break; | break; | 
 |  |  | 
| case WM_EXITSIZEMOVE: | case WM_MOVING: | 
| soundmng_enable(SNDPROC_TOOL); | winlocex_moving(toolwin.wlex, (RECT *)lp); | 
 | break; | break; | 
 |  |  | 
| case WM_MOVING: | case WM_EXITSIZEMOVE: | 
| movingproc((RECT *)lp); | winlocex_destroy(toolwin.wlex); | 
|  | toolwin.wlex = NULL; | 
|  | soundmng_enable(SNDPROC_TOOL); | 
 | break; | break; | 
 |  |  | 
 | case WM_MOVE: | case WM_MOVE: | 
| Line 893  static LRESULT CALLBACK twproc(HWND hWnd | Line 864  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case WM_CLOSE: | case WM_CLOSE: | 
| xmenu_settoolwin(0); | sysmenu_settoolwin(0); | 
 | sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); | 
 | DestroyWindow(hWnd); | DestroyWindow(hWnd); | 
 | break; | break; | 
 |  |  | 
 | case WM_DESTROY: | case WM_DESTROY: | 
 |  | np2class_wmdestroy(hWnd); | 
 | toolwindestroy(); | toolwindestroy(); | 
 | toolwin.hwnd = NULL; | toolwin.hwnd = NULL; | 
 | break; | break; | 
 |  |  | 
 | case WM_LBUTTONDOWN: | case WM_LBUTTONDOWN: | 
| SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L); | if (np2tool.type & 1) { | 
|  | return(SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L)); | 
|  | } | 
 | break; | break; | 
 |  |  | 
 | case WM_RBUTTONDOWN: | case WM_RBUTTONDOWN: | 
| open_popup(hWnd, lp); | openpopup(hWnd, lp); | 
|  | break; | 
|  |  | 
|  | case WM_LBUTTONDBLCLK: | 
|  | np2tool.type ^= 1; | 
|  | wlex = np2_winlocexallwin(hWndMain); | 
|  | winlocex_setholdwnd(wlex, hWnd); | 
|  | np2class_windowtype(hWnd, (np2tool.type & 1) << 1); | 
|  | winlocex_move(wlex); | 
|  | winlocex_destroy(wlex); | 
|  | sysmng_update(SYS_UPDATEOSCFG); | 
 | break; | break; | 
 |  |  | 
 | default: | default: | 
| Line 921  BOOL toolwin_initapp(HINSTANCE hInstance | Line 905  BOOL toolwin_initapp(HINSTANCE hInstance | 
 |  |  | 
 | WNDCLASS wc; | WNDCLASS wc; | 
 |  |  | 
| wc.style = CS_HREDRAW | CS_VREDRAW; | 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 = GTWL_SIZE; | 
| Line 929  BOOL toolwin_initapp(HINSTANCE hInstance | Line 913  BOOL toolwin_initapp(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); | 
 | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | 
| wc.lpszMenuName = NULL; | wc.lpszMenuName = MAKEINTRESOURCE(IDR_TOOLWIN); | 
 | wc.lpszClassName = np2toolclass; | wc.lpszClassName = np2toolclass; | 
 | return(RegisterClass(&wc)); | return(RegisterClass(&wc)); | 
 | } | } | 
 |  |  | 
| void toolwin_open(void) { | void toolwin_create(void) { | 
 |  |  | 
 | HBITMAP hbmp; | HBITMAP hbmp; | 
 | BITMAP  bmp; | BITMAP  bmp; | 
 | HWND    hWnd; | HWND    hWnd; | 
 | HMENU   hMenu; |  | 
 |  |  | 
 | if (toolwin.hwnd) { | if (toolwin.hwnd) { | 
 | return; | return; | 
| Line 951  void toolwin_open(void) { | Line 934  void toolwin_open(void) { | 
 | } | } | 
 | GetObject(hbmp, sizeof(BITMAP), &bmp); | GetObject(hbmp, sizeof(BITMAP), &bmp); | 
 | toolwin.hbmp = hbmp; | toolwin.hbmp = hbmp; | 
| hWnd = CreateWindow(np2toolclass, np2tooltitle, WS_SYSMENU, | hWnd = CreateWindow(np2toolclass, np2tooltitle, | 
|  | WS_SYSMENU | WS_MINIMIZEBOX, | 
 | np2tool.posx, np2tool.posy, | np2tool.posx, np2tool.posy, | 
 | bmp.bmWidth, bmp.bmHeight, | bmp.bmWidth, bmp.bmHeight, | 
 | NULL, NULL, hInst, NULL); | NULL, NULL, hInst, NULL); | 
 |  | winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); | 
 | toolwin.hwnd = hWnd; | toolwin.hwnd = hWnd; | 
 | if (hWnd == NULL) { | if (hWnd == NULL) { | 
 | goto twope_err2; | goto twope_err2; | 
 | } | } | 
 | UpdateWindow(hWnd); | UpdateWindow(hWnd); | 
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOWNOACTIVATE); | 
|  |  | 
| hMenu = GetSystemMenu(hWnd, FALSE); |  | 
| InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, IDC_SKINDEF, str_skindef); |  | 
| InsertMenu(hMenu, 1, MF_BYPOSITION | MF_STRING, IDC_SKINSEL, str_skinsel); |  | 
| InsertMenu(hMenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); |  | 
 | SetForegroundWindow(hWndMain); | SetForegroundWindow(hWndMain); | 
 | return; | return; | 
 |  |  | 
| Line 973  twope_err2: | Line 953  twope_err2: | 
 | DeleteObject(hbmp); | DeleteObject(hbmp); | 
 |  |  | 
 | twope_err1: | twope_err1: | 
| xmenu_settoolwin(0); | sysmenu_settoolwin(0); | 
 | sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); | 
 | return; | return; | 
 | } | } | 
 |  |  | 
| void toolwin_close(void) { | void toolwin_destroy(void) { | 
 |  |  | 
 | if (toolwin.hwnd) { | if (toolwin.hwnd) { | 
 | DestroyWindow(toolwin.hwnd); | DestroyWindow(toolwin.hwnd); | 
 | } | } | 
 | } | } | 
 |  |  | 
| void toolwin_movingstart(void) { | HWND toolwin_gethwnd(void) { | 
|  |  | 
| RECT    mainrc; |  | 
| RECT    toolrc; |  | 
| UINT    connect; |  | 
 |  |  | 
| if (toolwin.hwnd == NULL) { | return(toolwin.hwnd); | 
| return; |  | 
| } |  | 
| GetWindowRect(hWndMain, &mainrc); |  | 
| GetWindowRect(toolwin.hwnd, &toolrc); |  | 
| connect = 0; |  | 
| if ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom)) { |  | 
| if (toolrc.right == mainrc.left) { |  | 
| connect += 0x01; |  | 
| } |  | 
| else if (toolrc.left == mainrc.right) { |  | 
| connect += 0x02; |  | 
| } |  | 
| else if (toolrc.left == mainrc.left) { |  | 
| connect += 0x03; |  | 
| } |  | 
| else if (toolrc.right == mainrc.right) { |  | 
| connect += 0x04; |  | 
| } |  | 
| } |  | 
| if ((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right)) { |  | 
| if (toolrc.bottom == mainrc.top) { |  | 
| connect += 1 << 4; |  | 
| } |  | 
| else if (toolrc.top == mainrc.bottom) { |  | 
| connect += 2 << 4; |  | 
| } |  | 
| else if (toolrc.top == mainrc.top) { |  | 
| connect += 3 << 4; |  | 
| } |  | 
| else if (toolrc.bottom == mainrc.bottom) { |  | 
| connect += 4 << 4; |  | 
| } |  | 
| } |  | 
| toolwin.parentcn = connect; |  | 
| toolwin.parentx = mainrc.left; |  | 
| toolwin.parenty = mainrc.top; |  | 
 | } | } | 
 |  |  | 
| void toolwin_movingend(void) { | void toolwin_setfdd(UINT8 drv, const OEMCHAR *name) { | 
|  |  | 
| UINT    connect; |  | 
| RECT    mainrc; |  | 
| RECT    toolrc; |  | 
| int             cx; |  | 
| int             cy; |  | 
|  |  | 
| connect = toolwin.parentcn; |  | 
| toolwin.parentcn = 0; |  | 
| if ((toolwin.hwnd == NULL) || (!connect)) { |  | 
| return; |  | 
| } |  | 
| GetWindowRect(hWndMain, &mainrc); |  | 
| GetWindowRect(toolwin.hwnd, &toolrc); |  | 
| cx = toolrc.right - toolrc.left; |  | 
| cy = toolrc.bottom - toolrc.top; |  | 
| toolrc.left += mainrc.left - toolwin.parentx; |  | 
| toolrc.top += mainrc.top - toolwin.parenty; |  | 
| switch(connect & 0x0f) { |  | 
| case 1: |  | 
| toolrc.left = mainrc.left - cx; |  | 
| break; |  | 
|  |  | 
| case 2: |  | 
| toolrc.left = mainrc.right; |  | 
| break; |  | 
|  |  | 
| case 3: |  | 
| toolrc.left = mainrc.left; |  | 
| break; |  | 
|  |  | 
| case 4: |  | 
| toolrc.left = mainrc.right - cx; |  | 
| break; |  | 
| } |  | 
| switch((connect >> 4) & 0x0f) { |  | 
| case 1: |  | 
| toolrc.top = mainrc.top - cy; |  | 
| break; |  | 
|  |  | 
| case 2: |  | 
| toolrc.top = mainrc.bottom; |  | 
| break; |  | 
|  |  | 
| case 3: |  | 
| toolrc.top = mainrc.top; |  | 
| break; |  | 
|  |  | 
| case 4: |  | 
| toolrc.top = mainrc.bottom - cy; |  | 
| break; |  | 
| } |  | 
| MoveWindow(toolwin.hwnd, toolrc.left, toolrc.top, cx, cy, TRUE); |  | 
| } |  | 
|  |  | 
| void toolwin_setfdd(BYTE drv, const char *name) { |  | 
 |  |  | 
 | TOOLFDD *fdd; | TOOLFDD *fdd; | 
| char    *q; | OEMCHAR *q; | 
| char    *p; | OEMCHAR *p; | 
 | UINT    i; | UINT    i; | 
 | HWND    sub; | HWND    sub; | 
 |  |  | 
| Line 1105  void toolwin_setfdd(BYTE drv, const char | Line 989  void toolwin_setfdd(BYTE drv, const char | 
 | fdd->insert = 1; | fdd->insert = 1; | 
 | q = fdd->name[0]; | q = fdd->name[0]; | 
 | for (i=0; i<(FDDLIST_MAX - 1); i++) { | for (i=0; i<(FDDLIST_MAX - 1); i++) { | 
| if (!milstr_cmp(q, name)) { | if (!file_cmpname(q, name)) { | 
 | break; | break; | 
 | } | } | 
| q += sizeof(fdd->name[0]); | q += NELEMENTS(fdd->name[0]); | 
 | } | } | 
| p = q - sizeof(fdd->name[0]); | p = q - NELEMENTS(fdd->name[0]); | 
 | while(i > 0) { | while(i > 0) { | 
 | i--; | i--; | 
 | CopyMemory(q, p, sizeof(fdd->name[0])); | CopyMemory(q, p, sizeof(fdd->name[0])); | 
| p -= sizeof(fdd->name[0]); | p -= NELEMENTS(fdd->name[0]); | 
| q -= sizeof(fdd->name[0]); | q -= NELEMENTS(fdd->name[0]); | 
 | } | } | 
| milstr_ncpy(fdd->name[0], name, sizeof(fdd->name[0])); | file_cpyname(fdd->name[0], name, NELEMENTS(fdd->name[0])); | 
 | } | } | 
 | sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); | 
 | if (toolwin.hwnd != NULL) { | if (toolwin.hwnd != NULL) { | 
| Line 1129  void toolwin_setfdd(BYTE drv, const char | Line 1013  void toolwin_setfdd(BYTE drv, const char | 
 | } | } | 
 | } | } | 
 |  |  | 
| static void setdiskacc(UINT num, BYTE count) { | static void setdiskacc(UINT num, UINT8 count) { | 
 |  |  | 
 | const DISKACC   *acc; | const DISKACC   *acc; | 
 | HWND            sub; | HWND            sub; | 
| Line 1137  const DISKACC *acc; | Line 1021  const DISKACC *acc; | 
 | if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { | 
 | return; | return; | 
 | } | } | 
| if (num < (sizeof(diskacc)/sizeof(DISKACC))) { | if (num < NELEMENTS(diskacc)) { | 
 | acc = diskacc + num; | acc = diskacc + num; | 
 | sub = NULL; | sub = NULL; | 
 | if (*(acc->counter) == 0) { | if (*(acc->counter) == 0) { | 
| Line 1150  const DISKACC *acc; | Line 1034  const DISKACC *acc; | 
 | } | } | 
 | } | } | 
 |  |  | 
| void toolwin_fddaccess(BYTE drv) { | void toolwin_fddaccess(UINT8 drv) { | 
 |  |  | 
 | if (drv < 2) { | if (drv < 2) { | 
 | setdiskacc(drv, 20); | setdiskacc(drv, 20); | 
 | } | } | 
 | } | } | 
 |  |  | 
| void toolwin_hddaccess(BYTE drv) { | void toolwin_hddaccess(UINT8 drv) { | 
 |  |  | 
 | setdiskacc(2, 10); | setdiskacc(2, 10); | 
 | } | } | 
 |  |  | 
| void toolwin_draw(BYTE frame) { | void toolwin_draw(UINT8 frame) { | 
 |  |  | 
 | const DISKACC   *acc; | const DISKACC   *acc; | 
 | const DISKACC   *accterm; | const DISKACC   *accterm; | 
| BYTE            counter; | UINT8           counter; | 
 | HWND            sub; | HWND            sub; | 
 |  |  | 
 | if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { | 
| Line 1176  const DISKACC *accterm; | Line 1060  const DISKACC *accterm; | 
 | frame = 1; | frame = 1; | 
 | } | } | 
 | acc = diskacc; | acc = diskacc; | 
| accterm = acc + (sizeof(diskacc)/sizeof(DISKACC)); | accterm = acc + NELEMENTS(diskacc); | 
 | while(acc < accterm) { | while(acc < accterm) { | 
 | counter = *acc->counter; | counter = *acc->counter; | 
 | if (counter) { | if (counter) { | 
| Line 1198  const DISKACC *accterm; | Line 1082  const DISKACC *accterm; | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static const char np2toolini[] = "np2tool.ini"; | static const OEMCHAR ini_title[] = OEMTEXT("NP2 tool"); | 
| static const char ini_title[] = "NP2 tool"; |  | 
|  |  | 
| static const INITBL iniitem[] = { |  | 
| {"WindposX", INITYPE_SINT32,    &np2tool.posx,                  0}, |  | 
| {"WindposY", INITYPE_SINT32,    &np2tool.posy,                  0}, |  | 
| {"SkinFile", INITYPE_STR,               np2tool.skin,                   MAX_PATH}, |  | 
| {"FD1NAME0", INITYPE_STR,               np2tool.fdd[0].name[0], MAX_PATH}, |  | 
| {"FD1NAME1", INITYPE_STR,               np2tool.fdd[0].name[1], MAX_PATH}, |  | 
| {"FD1NAME2", INITYPE_STR,               np2tool.fdd[0].name[2], MAX_PATH}, |  | 
| {"FD1NAME3", INITYPE_STR,               np2tool.fdd[0].name[3], MAX_PATH}, |  | 
| {"FD1NAME4", INITYPE_STR,               np2tool.fdd[0].name[4], MAX_PATH}, |  | 
| {"FD1NAME5", INITYPE_STR,               np2tool.fdd[0].name[5], MAX_PATH}, |  | 
| {"FD1NAME6", INITYPE_STR,               np2tool.fdd[0].name[6], MAX_PATH}, |  | 
| {"FD1NAME7", INITYPE_STR,               np2tool.fdd[0].name[7], MAX_PATH}, |  | 
| {"FD2NAME0", INITYPE_STR,               np2tool.fdd[1].name[0], MAX_PATH}, |  | 
| {"FD2NAME1", INITYPE_STR,               np2tool.fdd[1].name[1], MAX_PATH}, |  | 
| {"FD2NAME2", INITYPE_STR,               np2tool.fdd[1].name[2], MAX_PATH}, |  | 
| {"FD2NAME3", INITYPE_STR,               np2tool.fdd[1].name[3], MAX_PATH}, |  | 
| {"FD2NAME4", INITYPE_STR,               np2tool.fdd[1].name[4], MAX_PATH}, |  | 
| {"FD2NAME5", INITYPE_STR,               np2tool.fdd[1].name[5], MAX_PATH}, |  | 
| {"FD2NAME6", INITYPE_STR,               np2tool.fdd[1].name[6], MAX_PATH}, |  | 
| {"FD2NAME7", INITYPE_STR,               np2tool.fdd[1].name[7], MAX_PATH}}; |  | 
 |  |  | 
| static void getinifile(char *path, int leng) { | static const PFTBL iniitem[] = { | 
|  | PFVAL("WindposX", PFTYPE_SINT32,        &np2tool.posx), | 
| milstr_ncpy(path, modulefile, leng); | PFVAL("WindposY", PFTYPE_SINT32,        &np2tool.posy), | 
| file_cutname(path); | PFVAL("WindType", PFTYPE_BOOL,          &np2tool.type), | 
| file_catname(path, np2toolini, leng); | PFSTR("SkinFile", PFTYPE_STR,           np2tool.skin), | 
| } | PFSTR("SkinMRU0", PFTYPE_STR,           np2tool.skinmru[0]), | 
|  | PFSTR("SkinMRU1", PFTYPE_STR,           np2tool.skinmru[1]), | 
|  | PFSTR("SkinMRU2", PFTYPE_STR,           np2tool.skinmru[2]), | 
|  | PFSTR("SkinMRU3", PFTYPE_STR,           np2tool.skinmru[3]), | 
|  | PFSTR("FD1NAME0", PFTYPE_STR,           np2tool.fdd[0].name[0]), | 
|  | PFSTR("FD1NAME1", PFTYPE_STR,           np2tool.fdd[0].name[1]), | 
|  | PFSTR("FD1NAME2", PFTYPE_STR,           np2tool.fdd[0].name[2]), | 
|  | PFSTR("FD1NAME3", PFTYPE_STR,           np2tool.fdd[0].name[3]), | 
|  | PFSTR("FD1NAME4", PFTYPE_STR,           np2tool.fdd[0].name[4]), | 
|  | PFSTR("FD1NAME5", PFTYPE_STR,           np2tool.fdd[0].name[5]), | 
|  | PFSTR("FD1NAME6", PFTYPE_STR,           np2tool.fdd[0].name[6]), | 
|  | PFSTR("FD1NAME7", PFTYPE_STR,           np2tool.fdd[0].name[7]), | 
|  | PFSTR("FD2NAME0", PFTYPE_STR,           np2tool.fdd[1].name[0]), | 
|  | PFSTR("FD2NAME1", PFTYPE_STR,           np2tool.fdd[1].name[1]), | 
|  | PFSTR("FD2NAME2", PFTYPE_STR,           np2tool.fdd[1].name[2]), | 
|  | PFSTR("FD2NAME3", PFTYPE_STR,           np2tool.fdd[1].name[3]), | 
|  | PFSTR("FD2NAME4", PFTYPE_STR,           np2tool.fdd[1].name[4]), | 
|  | PFSTR("FD2NAME5", PFTYPE_STR,           np2tool.fdd[1].name[5]), | 
|  | PFSTR("FD2NAME6", PFTYPE_STR,           np2tool.fdd[1].name[6]), | 
|  | PFSTR("FD2NAME7", PFTYPE_STR,           np2tool.fdd[1].name[7])}; | 
 |  |  | 
 | void toolwin_readini(void) { | void toolwin_readini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
 | ZeroMemory(&np2tool, sizeof(np2tool)); | ZeroMemory(&np2tool, sizeof(np2tool)); | 
 | np2tool.posx = CW_USEDEFAULT; | np2tool.posx = CW_USEDEFAULT; | 
 | np2tool.posy = CW_USEDEFAULT; | np2tool.posy = CW_USEDEFAULT; | 
| getinifile(path, sizeof(path)); | np2tool.type = 1; | 
| ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | initgetfile(path, NELEMENTS(path)); | 
|  | ini_read(path, ini_title, iniitem, NELEMENTS(iniitem)); | 
 | } | } | 
 |  |  | 
 | void toolwin_writeini(void) { | void toolwin_writeini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
| getinifile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); | 
| ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | ini_write(path, ini_title, iniitem, NELEMENTS(iniitem)); | 
 | } | } | 
 |  |  |