| version 1.4, 2003/10/29 14:02:35 | version 1.15, 2003/11/11 14:50:52 | 
| 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        "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        "pccore.h" | #include        "pccore.h" | 
 | #include        "diskdrv.h" | #include        "diskdrv.h" | 
 |  |  | 
 |  |  | 
| #ifdef STRICT | extern WINLOCEX np2_winlocexallwin(HWND base); | 
| #define SCPROC  WNDPROC |  | 
| #else |  | 
| #define SCPROC  FARPROC |  | 
| #endif |  | 
 |  |  | 
 |  |  | 
 | enum { | enum { | 
| Line 30  enum { | Line 29  enum { | 
 | IDC_TOOLFDD2LIST, | IDC_TOOLFDD2LIST, | 
 | IDC_TOOLFDD2BROWSE, | IDC_TOOLFDD2BROWSE, | 
 | IDC_TOOLFDD2EJECT, | IDC_TOOLFDD2EJECT, | 
 |  | IDC_TOOLRESET, | 
 |  | IDC_TOOLPOWER, | 
 | IDC_MAXITEMS, | IDC_MAXITEMS, | 
 |  |  | 
| IDC_BASE                                = 3000 | IDC_BASE                                = 3000, | 
|  |  | 
|  | IDM_SKINSEL                             = 3100, | 
|  | IDM_SKINDEF                             = 3101, | 
|  | IDM_SKINMRU                             = 3102, | 
|  | IDM_TOOLCLOSE                   = IDM_SKINMRU + SKINMRU_MAX | 
|  | }; | 
|  |  | 
|  | enum { | 
|  | TCTL_STATIC                             = 0, | 
|  | TCTL_BUTTON                             = 1, | 
|  | TCTL_DDLIST                             = 2 | 
 | }; | }; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| Line 44  typedef struct { | Line 56  typedef struct { | 
 | } TOOLSKIN; | } TOOLSKIN; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| const char      *cname; | UINT    tctl; | 
 | const char      *text; | const char      *text; | 
 | DWORD   style; |  | 
 | short   posx; | short   posx; | 
 | short   posy; | short   posy; | 
 | short   width; | short   width; | 
 | short   height; | short   height; | 
| BOOL    tabstop; | short   extend; | 
|  | short   padding; | 
 | } SUBITEM; | } SUBITEM; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
| HWND    hwnd; | HWND                    hwnd; | 
| HBITMAP hbmp; | WINLOCEX                wlex; | 
| BYTE    fddaccess[2]; | HBITMAP                 hbmp; | 
| BYTE    hddaccess; | BYTE                    fddaccess[2]; | 
| BYTE    _padding; | BYTE                    hddaccess; | 
| int             winflg; | BYTE                    _padding; | 
| int             wingx; | int                             winflg; | 
| int             wingy; | int                             wingx; | 
| int             wintx; | int                             wingy; | 
| int             winty; | int                             wintx; | 
| int             parentcn; | int                             winty; | 
| int             parentx; | UINT                    parentcn; | 
| int             parenty; | int                             parentx; | 
| HFONT   hfont; | int                             parenty; | 
| HDC             hdcfont; | HFONT                   hfont; | 
| HBRUSH  access[2]; | HDC                             hdcfont; | 
| HWND    sub[IDC_MAXITEMS]; | HBRUSH                  access[2]; | 
| SCPROC  subproc[IDC_MAXITEMS]; | HWND                    sub[IDC_MAXITEMS]; | 
|  | SUBCLASSPROC    subproc[IDC_MAXITEMS]; | 
 | } TOOLWIN; | } TOOLWIN; | 
 |  |  | 
 |  | enum { | 
 |  | GTWL_FOCUS              = NP2GWL_SIZE + 0, | 
 |  | GTWL_SIZE               = NP2GWL_SIZE + 4 | 
 |  | }; | 
 |  |  | 
 | NP2TOOL         np2tool; | NP2TOOL         np2tool; | 
 | static  TOOLSKIN        toolskin; | static  TOOLSKIN        toolskin; | 
| Line 100  static const DISKACC diskacc[3] = { | Line 117  static const DISKACC diskacc[3] = { | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| static void skinsetdef(void) { | static HBITMAP skinload(const char *path) { | 
|  |  | 
|  | char    fname[MAX_PATH]; | 
|  | UINT    i; | 
|  | 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, sizeof(toolskin.font)); | 
 | toolskin.color1 = 0x600000; | toolskin.color1 = 0x600000; | 
 | toolskin.color2 = 0xff0000; | toolskin.color2 = 0xff0000; | 
 | CopyMemory(subitem, defsubitem, sizeof(defsubitem)); |  | 
 | } |  | 
 |  |  | 
 | static HBITMAP skinload(const char *path) { |  | 
 |  |  | 
 | char    fname[MAX_PATH]; |  | 
 |  |  | 
 | if (path) { | if (path) { | 
| ini_read(path, skintitle, skinini, sizeof(skinini)/sizeof(INITBL)); | ini_read(path, skintitle, skinini1, sizeof(skinini1)/sizeof(INITBL)); | 
|  | } | 
|  | 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; | 
|  | } | 
|  | } | 
|  | else { | 
|  | CopyMemory(subitem, defsubitem, sizeof(defsubitem)); | 
|  | } | 
|  | if (path) { | 
|  | ini_read(path, skintitle, skinini2, sizeof(skinini2)/sizeof(INITBL)); | 
 | } | } | 
| if ((path) && (toolskin.main[0])) { | if (toolskin.main[0]) { | 
 | milstr_ncpy(fname, path, sizeof(fname)); | milstr_ncpy(fname, path, sizeof(fname)); | 
 | file_cutname(fname); | file_cutname(fname); | 
 | file_catname(fname, toolskin.main, sizeof(fname)); | file_catname(fname, toolskin.main, sizeof(fname)); | 
| return((HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | ret = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | 
| 0, 0, LR_LOADFROMFILE)); | 0, 0, LR_LOADFROMFILE); | 
| } | if (ret != NULL) { | 
| else { | return(ret); | 
| return(LoadBitmap(hInst, "NP2TOOL")); | } | 
 | } | } | 
 |  | return(LoadBitmap(hInst, "NP2TOOL")); | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 152  static void calctextsize(char *path, int | Line 180  static void calctextsize(char *path, int | 
 | file_cutname(path); | file_cutname(path); | 
 | file_cutseparator(path); | file_cutseparator(path); | 
 | file_cutname(path); | file_cutname(path); | 
 |  | file_cutseparator(path); | 
 | l = strlen(path); | l = strlen(path); | 
| if (l > 1) { | work[0] = '\0'; | 
| l -= 1; | if (l) { | 
| if (milstr_kanji2nd(p, l - 1)) { | milstr_ncpy(work, str_browse, sizeof(work)); | 
| l--; |  | 
| } |  | 
 | } | } | 
 | else { |  | 
 | l = 0; |  | 
 | } |  | 
 | milstr_ncpy(work, str_browse, sizeof(work)); |  | 
 | milstr_ncat(work, p + l, sizeof(work)); | milstr_ncat(work, p + l, sizeof(work)); | 
 | GetTextExtentPoint32(hdc, work, strlen(work), &tail); | GetTextExtentPoint32(hdc, work, strlen(work), &tail); | 
 | pos = 0; | pos = 0; | 
| Line 180  static void calctextsize(char *path, int | Line 203  static void calctextsize(char *path, int | 
 | milstr_ncat(path, work, leng); | milstr_ncat(path, work, leng); | 
 | } | } | 
 |  |  | 
| static void setlist(UINT drv) { | static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { | 
 |  |  | 
 | HWND    hwnd; |  | 
 | RECT    rc; | RECT    rc; | 
 | int             width; | int             width; | 
 | TOOLFDD *fdd; |  | 
 | char    *p; |  | 
 | UINT    i; |  | 
 | char    basedir[MAX_PATH]; | char    basedir[MAX_PATH]; | 
 |  | UINT    i; | 
 |  | const char      *p; | 
 | char    dir[MAX_PATH]; | char    dir[MAX_PATH]; | 
| char    *q; | const char      *q; | 
 |  |  | 
| if (drv >= FDDLIST_DRV) { | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); | 
| return; |  | 
| } |  | 
| hwnd = toolwin.sub[fddlist[drv]]; |  | 
 | GetClientRect(hwnd, &rc); | GetClientRect(hwnd, &rc); | 
 | width = rc.right - rc.left - 6;                 // border size? | width = rc.right - rc.left - 6;                 // border size? | 
 | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); |  | 
 | fdd = np2tool.fdd + drv; |  | 
 | p = fdd->name[0]; |  | 
 | basedir[0] = '\0'; | basedir[0] = '\0'; | 
| if (fdd->insert) { | if (sel < fdd->cnt) { | 
| milstr_ncpy(basedir, p, sizeof(basedir)); | milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], sizeof(basedir)); | 
 | file_cutname(basedir); | file_cutname(basedir); | 
 | } | } | 
| for (i=0; i<FDDLIST_MAX; i++) { | for (i=0; i<fdd->cnt; i++) { | 
| if (p[0] == '\0') { | p = fdd->name[fdd->pos[i]]; | 
| break; |  | 
| } |  | 
 | milstr_ncpy(dir, p, sizeof(dir)); | milstr_ncpy(dir, p, sizeof(dir)); | 
 | file_cutname(dir); | file_cutname(dir); | 
 | if (!file_cmpname(basedir, dir)) { | if (!file_cmpname(basedir, dir)) { | 
| q = file_getname(p); | q = file_getname((char *)p); | 
 | } | } | 
 | else { | else { | 
 | calctextsize(dir, sizeof(dir), p, width); | calctextsize(dir, sizeof(dir), p, width); | 
| Line 222  static void setlist(UINT drv) { | Line 235  static void setlist(UINT drv) { | 
 | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | 
 | p += sizeof(fdd->name[0]); | p += sizeof(fdd->name[0]); | 
 | } | } | 
| if (fdd->insert) { | if (sel < fdd->cnt) { | 
| SendMessage(hwnd, CB_SETCURSEL, (WPARAM)0, (LPARAM)0); | SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); | 
 | } | } | 
 | } | } | 
 |  |  | 
 | static void sellist(UINT drv) { | static void sellist(UINT drv) { | 
 |  |  | 
 | HWND    hwnd; | HWND    hwnd; | 
 |  | TOOLFDD *fdd; | 
 | UINT    sel; | UINT    sel; | 
 | char    path[MAX_PATH]; |  | 
 |  |  | 
 | if (drv >= FDDLIST_DRV) { | if (drv >= FDDLIST_DRV) { | 
 | return; | return; | 
 | } | } | 
 | hwnd = toolwin.sub[fddlist[drv]]; | hwnd = toolwin.sub[fddlist[drv]]; | 
 |  | fdd = np2tool.fdd + drv; | 
 | sel = (UINT)SendMessage(hwnd, CB_GETCURSEL, 0, 0); | sel = (UINT)SendMessage(hwnd, CB_GETCURSEL, 0, 0); | 
| if (sel < FDDLIST_MAX) { | if (sel < fdd->cnt) { | 
| milstr_ncpy(path, np2tool.fdd[drv].name[sel], sizeof(path)); | diskdrv_setfdd(drv, fdd->name[fdd->pos[sel]], 0); | 
| diskdrv_setfdd(drv, path, 0); | fdd->insert = 1; | 
| toolwin_setfdd(drv, path); | setlist(hwnd, fdd, sel); | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  | static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { | 
 |  |  | 
 |  | char    *p; | 
 |  | UINT    cnt; | 
 |  | char    *q; | 
 |  | char    *fname[FDDLIST_MAX]; | 
 |  | UINT    i; | 
 |  | UINT    j; | 
 |  | UINT    sel; | 
 |  |  | 
 |  | p = fdd->name[0]; | 
 |  | for (cnt=0; cnt<FDDLIST_MAX; cnt++) { | 
 |  | if (p[0] == '\0') { | 
 |  | break; | 
 |  | } | 
 |  | q = file_getname(p); | 
 |  | fname[cnt] = q; | 
 |  | for (i=0; i<cnt; i++) { | 
 |  | if (file_cmpname(q, fname[fdd->pos[i]]) < 0) { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | for (j=cnt; j>i; j--) { | 
 |  | fdd->pos[j] = fdd->pos[j-1]; | 
 |  | } | 
 |  | fdd->pos[i] = cnt; | 
 |  | p += sizeof(fdd->name[0]); | 
 |  | } | 
 |  | fdd->cnt = cnt; | 
 |  | sel = (UINT)-1; | 
 |  | if (fdd->insert) { | 
 |  | for (i=0; i<cnt; i++) { | 
 |  | if (fdd->pos[i] == 0) { | 
 |  | sel = i; | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | } | 
 |  | setlist(hwnd, fdd, sel); | 
 |  | } | 
 |  |  | 
 | static void accdraw(HWND hWnd, BYTE count) { | static void accdraw(HWND hWnd, BYTE count) { | 
 |  |  | 
 | HDC                     hdc; | HDC                     hdc; | 
| Line 268  static LRESULT CALLBACK twsub(HWND hWnd, | Line 323  static LRESULT CALLBACK twsub(HWND hWnd, | 
 | int             files; | int             files; | 
 | char    fname[MAX_PATH]; | char    fname[MAX_PATH]; | 
 |  |  | 
| for (idc=0; idc<IDC_MAXITEMS; idc++) { | idc = GetWindowLong(hWnd, GWL_ID) - IDC_BASE; | 
| if (toolwin.sub[idc] == hWnd) { |  | 
| break; |  | 
| } |  | 
| } |  | 
 | 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 285  static LRESULT CALLBACK twsub(HWND hWnd, | Line 336  static LRESULT CALLBACK twsub(HWND hWnd, | 
 | if (newidc >= IDC_MAXITEMS) { | if (newidc >= IDC_MAXITEMS) { | 
 | newidc = (dir >= 0)?0:(IDC_MAXITEMS - 1); | newidc = (dir >= 0)?0:(IDC_MAXITEMS - 1); | 
 | } | } | 
| if (subitem[newidc].tabstop) { | if ((toolwin.sub[newidc] != NULL) && | 
|  | (subitem[newidc].tctl != TCTL_STATIC)) { | 
 | SetFocus(toolwin.sub[newidc]); | SetFocus(toolwin.sub[newidc]); | 
 | break; | break; | 
 | } | } | 
 | } while(idc != newidc); | } while(idc != newidc); | 
 | } | } | 
| else if ((TCHAR)wp == VK_RETURN) { | else if ((short)wp == VK_RETURN) { | 
| if (subitem[idc].cname == str_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 328  static LRESULT CALLBACK twsub(HWND hWnd, | Line 380  static LRESULT CALLBACK twsub(HWND hWnd, | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 | } | } | 
 |  | else if (msg == WM_SETFOCUS) { | 
 |  | SetWindowLong(GetParent(hWnd), GTWL_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, LPARAM lp) { | static void toolwincreate(HWND hWnd) { | 
 |  |  | 
 | HDC                     hdc; | HDC                     hdc; | 
 | HINSTANCE       hinstance; |  | 
 | const SUBITEM   *p; | const SUBITEM   *p; | 
 | UINT            i; | UINT            i; | 
 | HWND            sub; | HWND            sub; | 
 |  | const char              *cls; | 
 |  | DWORD           style; | 
 |  |  | 
 | 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, | 
| Line 350  const SUBITEM *p; | Line 406  const SUBITEM *p; | 
 | toolwin.access[0] = CreateSolidBrush(0x000060); | toolwin.access[0] = CreateSolidBrush(0x000060); | 
 | toolwin.access[1] = CreateSolidBrush(0x0000ff); | toolwin.access[1] = CreateSolidBrush(0x0000ff); | 
 |  |  | 
 | hinstance = ((LPCREATESTRUCT)lp)->hInstance; |  | 
 | p = subitem; | p = subitem; | 
 | for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { | 
| sub = CreateWindow(p->cname, p->text, | sub = NULL; | 
| WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, | cls = NULL; | 
| hWnd, (HMENU)(i + IDC_BASE), hinstance, NULL); | switch(p->tctl) { | 
|  | case TCTL_STATIC: | 
|  | cls = str_static; | 
|  | style = 0; | 
|  | break; | 
|  |  | 
|  | case TCTL_BUTTON: | 
|  | if (p->extend == 0) { | 
|  | cls = str_button; | 
|  | style = BS_PUSHBUTTON; | 
|  | } | 
|  | else if (p->extend == 1) { | 
|  | cls = str_button; | 
|  | style = BS_OWNERDRAW; | 
|  | } | 
|  | break; | 
|  |  | 
|  | case TCTL_DDLIST: | 
|  | cls = str_combobox; | 
|  | style = CBS_DROPDOWNLIST | WS_VSCROLL; | 
|  | break; | 
|  | } | 
|  | if ((cls) && (p->width > 0) && (p->height > 0)) { | 
|  | sub = CreateWindow(cls, p->text, 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.sub[i] = sub; | 
| toolwin.subproc[i] = (SCPROC)GetWindowLong(sub, GWL_WNDPROC); | toolwin.subproc[i] = NULL; | 
| SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); | if (sub) { | 
| SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, | toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); | 
|  | SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); | 
|  | 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++) { | 
| DragAcceptFiles(toolwin.sub[fddlist[i]], TRUE); | sub = toolwin.sub[fddlist[i]]; | 
| setlist((BYTE)i); | if (sub) { | 
|  | DragAcceptFiles(sub, TRUE); | 
|  | remakefddlist(sub, np2tool.fdd + i); | 
|  | } | 
 | } | } | 
 |  | for (i=0; i<IDC_MAXITEMS; i++) { | 
 |  | if ((toolwin.sub[i]) && (subitem[i].tctl != TCTL_STATIC)) { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | SetWindowLong(hWnd, GTWL_FOCUS, i); | 
 | } | } | 
 |  |  | 
 | static void toolwindestroy(void) { | static void toolwindestroy(void) { | 
 |  |  | 
 | UINT    i; | UINT    i; | 
 |  | HWND    sub; | 
 |  |  | 
| for (i=0; i<IDC_MAXITEMS; i++) { | if (toolwin.hbmp) { | 
| DestroyWindow(toolwin.sub[i]); | for (i=0; i<IDC_MAXITEMS; i++) { | 
|  | sub = toolwin.sub[i]; | 
|  | if (sub) { | 
|  | DestroyWindow(sub); | 
|  | } | 
|  | } | 
|  | DeleteObject(toolwin.access[0]); | 
|  | DeleteObject(toolwin.access[1]); | 
|  | DeleteObject(toolwin.hdcfont); | 
|  | DeleteObject(toolwin.hfont); | 
|  | DeleteObject(toolwin.hbmp); | 
|  | toolwin.hbmp = NULL; | 
 | } | } | 
 | DeleteObject(toolwin.access[0]); |  | 
 | DeleteObject(toolwin.access[1]); |  | 
 | DeleteObject(toolwin.hdcfont); |  | 
 | DeleteObject(toolwin.hfont); |  | 
 | DeleteObject(toolwin.hbmp); |  | 
 | } | } | 
 |  |  | 
 | static void toolwinpaint(HWND hWnd) { | static void toolwinpaint(HWND hWnd) { | 
 |  |  | 
 | HDC                     hdc; | HDC                     hdc; | 
 | PAINTSTRUCT     ps; | PAINTSTRUCT     ps; | 
 | HINSTANCE       hinst; |  | 
 | BITMAP          bmp; | BITMAP          bmp; | 
 | HDC                     hmdc; | HDC                     hmdc; | 
 |  |  | 
 | hdc = BeginPaint(hWnd, &ps); | hdc = BeginPaint(hWnd, &ps); | 
| hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | if (toolwin.hbmp) { | 
| GetObject(toolwin.hbmp, sizeof(BITMAP), &bmp); | GetObject(toolwin.hbmp, sizeof(BITMAP), &bmp); | 
| hmdc = CreateCompatibleDC(hdc); | hmdc = CreateCompatibleDC(hdc); | 
| SelectObject(hmdc, toolwin.hbmp); | SelectObject(hmdc, toolwin.hbmp); | 
| BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); | BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); | 
| DeleteDC(hmdc); | DeleteDC(hmdc); | 
|  | } | 
 | EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); | 
 | } | } | 
 |  |  | 
 |  | static void tooldrawbutton(HWND hWnd, UINT idc, LPDRAWITEMSTRUCT lpdis) { | 
 |  |  | 
| // ---- moving | POINT   pt; | 
|  | HWND    sub; | 
|  | RECT    rect; | 
|  | HDC             hdc; | 
|  | HDC             hmdc; | 
|  | RECT    btn; | 
 |  |  | 
| enum { | idc -= IDC_BASE; | 
| SNAPDOTPULL             = 12, | if (idc >= IDC_MAXITEMS) { | 
| SNAPDOTREL              = 16 | return; | 
| }; | } | 
|  | pt.x = 0; | 
|  | pt.y = 0; | 
|  | ClientToScreen(hWnd, &pt); | 
|  | sub = toolwin.sub[idc]; | 
|  | GetWindowRect(sub, &rect); | 
|  | btn.left = 0; | 
|  | btn.top = 0; | 
|  | btn.right = rect.right - rect.left; | 
|  | btn.bottom = rect.bottom - rect.top; | 
|  | hdc = lpdis->hDC; | 
|  | if (toolwin.hbmp) { | 
|  | hmdc = CreateCompatibleDC(hdc); | 
|  | SelectObject(hmdc, toolwin.hbmp); | 
|  | BitBlt(hdc, 0, 0, btn.right, btn.bottom, | 
|  | hmdc, rect.left - pt.x, rect.top - pt.y, SRCCOPY); | 
|  | DeleteDC(hmdc); | 
|  | } | 
|  | if (lpdis->itemState & ODS_FOCUS) { | 
|  | DrawFocusRect(hdc, &btn); | 
|  | } | 
|  | } | 
 |  |  | 
 | 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; |  | 
| } |  | 
 |  |  | 
| changes = FALSE; | HMENU   ret; | 
| do { | UINT    cnt; | 
| if (toolwin.winflg & 1) { | const char      *base; | 
| toolwin.wingx += rect->left - toolwin.wintx; | UINT    flag; | 
| rect->left = toolwin.wintx; | char    *p; | 
|  | UINT    i; | 
|  | UINT    j; | 
|  | UINT    id[SKINMRU_MAX]; | 
|  | const char      *file[SKINMRU_MAX]; | 
|  |  | 
|  | ret = CreatePopupMenu(); | 
|  | AppendMenu(ret, MF_STRING, IDM_SKINSEL, str_skinsel); | 
|  | AppendMenu(ret, MF_SEPARATOR, 0, NULL); | 
|  |  | 
|  | base = np2tool.skin; | 
|  | flag = (base[0] == '\0')?MF_CHECKED:0; | 
|  | AppendMenu(ret, MF_STRING + flag, IDM_SKINDEF, str_skindef); | 
|  | for (cnt=0; cnt<SKINMRU_MAX; cnt++) { | 
|  | p = np2tool.skinmru[cnt]; | 
|  | if (p[0] == '\0') { | 
|  | break; | 
 | } | } | 
| else { | p = file_getname(p); | 
| d = SNAPDOTPULL; | for (i=0; i<cnt; i++) { | 
| do { | if (file_cmpname(p, file[id[i]]) < 0) { | 
| connecty = ((rect->bottom >= mainrc.top) && | break; | 
| (rect->top <= mainrc.bottom)); |  | 
| if (connecty) { |  | 
| 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; |  | 
| } |  | 
| } |  | 
| } |  | 
| 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 |= 1; |  | 
| rect->left -= d; |  | 
| toolwin.wingx = d; |  | 
| toolwin.wintx = rect->left; |  | 
 | } | } | 
 | } | } | 
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | for (j=cnt; j>i; j--) { | 
| toolwin.winflg &= ~1; | id[j] = id[j-1]; | 
| rect->left += toolwin.wingx; |  | 
| toolwin.wingx = 0; |  | 
 | } | } | 
| rect->right = rect->left + winlx; | 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; | 
|  | AppendMenu(ret, MF_STRING + flag, IDM_SKINMRU + j, file[j]); | 
|  | } | 
|  | return(ret); | 
|  | } | 
 |  |  | 
| if (changes) { | static void skinchange(HWND hWnd) { | 
| break; |  | 
| } | const char              *p; | 
|  | UINT            i; | 
|  | HBITMAP         hbmp; | 
|  | BITMAP          bmp; | 
|  | WINLOCEX        wlex; | 
 |  |  | 
| if (toolwin.winflg & 2) { | p = np2tool.skin; | 
| toolwin.wingy += rect->top - toolwin.winty; | if (p[0]) { | 
| rect->top = toolwin.winty; | for (i=0; i<(SKINMRU_MAX - 1); i++) { | 
|  | if (!file_cmpname(p, np2tool.skinmru[i])) { | 
|  | break; | 
|  | } | 
 | } | } | 
| else { | while(i > 0) { | 
| d = SNAPDOTPULL; | CopyMemory(np2tool.skinmru[i], np2tool.skinmru[i-1], | 
| do { | sizeof(np2tool.skinmru[0])); | 
| connectx = ((rect->right >= mainrc.left) && | i--; | 
| (rect->left <= mainrc.right)); | } | 
| if (connectx) { | file_cpyname(np2tool.skinmru[0], p, sizeof(np2tool.skinmru[0])); | 
| d = rect->top - mainrc.bottom; | } | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | 
| break; | (UINT)createskinmenu(), str_toolskin); | 
| } | ModifyMenu(GetSystemMenu(hWnd, FALSE), 0, MF_BYPOSITION | MF_POPUP, | 
| d = rect->bottom - mainrc.top; | (UINT)createskinmenu(), str_toolskin); | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | DrawMenuBar(hWnd); | 
| break; | sysmng_update(SYS_UPDATEOSCFG); | 
| } |  | 
| if ((rect->right == mainrc.left) || | wlex = np2_winlocexallwin(hWndMain); | 
| (rect->left == mainrc.right)) { | winlocex_setholdwnd(wlex, hWnd); | 
| d = rect->top - mainrc.top; | toolwindestroy(); | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | hbmp = skinload(np2tool.skin); | 
| break; | if (hbmp == NULL) { | 
| } | SendMessage(hWnd, WM_CLOSE, 0, 0); | 
| d = rect->bottom - mainrc.bottom; | return; | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } |  | 
| } |  | 
| d = rect->top - workrc.top; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| d = rect->bottom - workrc.bottom; |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| break; |  | 
| } |  | 
| } while(0); |  | 
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |  | 
| toolwin.winflg |= 2; |  | 
| rect->top -= d; |  | 
| toolwin.wingy = d; |  | 
| toolwin.winty = rect->top; |  | 
| changes = TRUE; |  | 
| } |  | 
| } |  | 
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { |  | 
| toolwin.winflg &= ~2; |  | 
| rect->top += toolwin.wingy; |  | 
| toolwin.wingy = 0; |  | 
| changes = TRUE; |  | 
| } |  | 
| rect->bottom = rect->top + winly; |  | 
| } while(changes); |  | 
|  |  | 
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); |  | 
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); |  | 
| if ((toolwin.winflg & 3) && ((!connectx) || (!connecty))) { |  | 
| toolwin.winflg &= ~3; |  | 
| rect->left += toolwin.wingx; |  | 
| rect->top += toolwin.wingy; |  | 
| rect->right = rect->left + winlx; |  | 
| rect->bottom = rect->top + winly; |  | 
| toolwin.wingx = 0; |  | 
| toolwin.wingy = 0; |  | 
 | } | } | 
 |  | 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 openpopup(HWND hWnd, LPARAM lp) { | 
 |  |  | 
 |  | HMENU   hMenu; | 
 |  | HMENU   mainmenu; | 
 |  | POINT   pt; | 
 |  |  | 
 |  | hMenu = CreatePopupMenu(); | 
 |  | if (!winui_en) { | 
 |  | 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_STRING, IDM_TOOLCLOSE, str_toolclose); | 
 |  | pt.x = LOWORD(lp); | 
 |  | pt.y = HIWORD(lp); | 
 |  | ClientToScreen(hWnd, &pt); | 
 |  | TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL); | 
 |  | DestroyMenu(hMenu); | 
 |  | } | 
 |  |  | 
 | static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | 
 |  |  | 
 |  | HMENU           hMenu; | 
 |  | 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); | 
| toolwincreate(hWnd, lp); | 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); | 
|  | break; | 
|  |  | 
|  | case WM_SYSCOMMAND: | 
|  | switch(wp) { | 
|  | case IDM_SKINSEL: | 
|  | case IDM_SKINDEF: | 
|  | case IDM_SKINMRU + 0: | 
|  | case IDM_SKINMRU + 1: | 
|  | case IDM_SKINMRU + 2: | 
|  | case IDM_SKINMRU + 3: | 
|  | return(SendMessage(hWnd, WM_COMMAND, wp, lp)); | 
|  |  | 
|  | default: | 
|  | return(DefWindowProc(hWnd, msg, wp, lp)); | 
|  | } | 
 | break; | break; | 
 |  |  | 
 | case WM_COMMAND: | case WM_COMMAND: | 
| Line 588  static LRESULT CALLBACK twproc(HWND hWnd | Line 697  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD1BROWSE: | case IDC_BASE + IDC_TOOLFDD1BROWSE: | 
| soundmng_stop(); | if (!winui_en) { | 
| dialog_changefdd(hWnd, 0); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD1OPEN, 0); | 
| soundmng_play(); | } | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: | 
| Line 605  static LRESULT CALLBACK twproc(HWND hWnd | Line 714  static LRESULT CALLBACK twproc(HWND hWnd | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD2BROWSE: | case IDC_BASE + IDC_TOOLFDD2BROWSE: | 
| soundmng_stop(); | if (!winui_en) { | 
| dialog_changefdd(hWnd, 1); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD2OPEN, 0); | 
| soundmng_play(); | } | 
 | break; | break; | 
 |  |  | 
 | case IDC_BASE + IDC_TOOLFDD2EJECT: | case IDC_BASE + IDC_TOOLFDD2EJECT: | 
 | diskdrv_setfdd(1, NULL, 0); | diskdrv_setfdd(1, NULL, 0); | 
 | toolwin_setfdd(1, NULL); | toolwin_setfdd(1, NULL); | 
 | break; | break; | 
 |  |  | 
 |  | case IDC_BASE + IDC_TOOLRESET: | 
 |  | if (!winui_en) { | 
 |  | SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); | 
 |  | SetForegroundWindow(hWndMain); | 
 |  | } | 
 |  | break; | 
 |  |  | 
 |  | case IDC_BASE + IDC_TOOLPOWER: | 
 |  | if (!winui_en) { | 
 |  | SendMessage(hWndMain, WM_CLOSE, 0, 0L); | 
 |  | } | 
 |  | break; | 
 |  |  | 
 |  | case IDM_SKINSEL: | 
 |  | soundmng_disable(SNDPROC_TOOL); | 
 |  | r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, | 
 |  | sizeof(np2tool.skin), NULL); | 
 |  | soundmng_enable(SNDPROC_TOOL); | 
 |  | if (r) { | 
 |  | skinchange(hWnd); | 
 |  | } | 
 |  | break; | 
 |  |  | 
 |  | case IDM_SKINDEF: | 
 |  | np2tool.skin[0] = '\0'; | 
 |  | 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], | 
 |  | sizeof(np2tool.skin)); | 
 |  | skinchange(hWnd); | 
 |  | break; | 
 |  |  | 
 |  | case IDM_TOOLCLOSE: | 
 |  | SendMessage(hWnd, WM_CLOSE, 0, 0); | 
 |  | break; | 
 |  |  | 
 |  | default: | 
 |  | if (!winui_en) { | 
 |  | return(SendMessage(hWndMain, msg, wp, lp)); | 
 |  | } | 
 |  | break; | 
 | } | } | 
 | break; | break; | 
 |  |  | 
 |  | case WM_KEYDOWN:                                                // TAB¤ò²¡¤·¤¿»þ¤ËÉüµ¢ | 
 |  | if ((short)wp == VK_TAB) { | 
 |  | idc = GetWindowLong(hWnd, GTWL_FOCUS); | 
 |  | if (idc < IDC_MAXITEMS) { | 
 |  | SetFocus(toolwin.sub[idc]); | 
 |  | } | 
 |  | return(0); | 
 |  | } | 
 |  | return(SendMessage(hWndMain, msg, wp, lp)); | 
 |  |  | 
 |  | case WM_KEYUP: | 
 |  | if ((short)wp == VK_TAB) { | 
 |  | return(0); | 
 |  | } | 
 |  | return(SendMessage(hWndMain, msg, wp, lp)); | 
 |  |  | 
 | case WM_PAINT: | case WM_PAINT: | 
 | toolwinpaint(hWnd); | toolwinpaint(hWnd); | 
 | break; | break; | 
 |  |  | 
 |  | case WM_DRAWITEM: | 
 |  | tooldrawbutton(hWnd, wp, (LPDRAWITEMSTRUCT)lp); | 
 |  | break; | 
 |  |  | 
 | case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: | 
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); | 
 | break; | break; | 
 |  |  | 
 | case WM_EXITMENULOOP: | case WM_EXITMENULOOP: | 
| soundmng_play(); | soundmng_enable(SNDPROC_TOOL); | 
 | break; | break; | 
 |  |  | 
 | case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: | 
| soundmng_stop(); | soundmng_disable(SNDPROC_TOOL); | 
| movingstart(); | winlocex_destroy(toolwin.wlex); | 
|  | toolwin.wlex = np2_winlocexallwin(hWnd); | 
 | break; | break; | 
 |  |  | 
| case WM_EXITSIZEMOVE: | case WM_MOVING: | 
| soundmng_play(); | 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 654  static LRESULT CALLBACK twproc(HWND hWnd | Line 834  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; | 
|  |  | 
|  | case WM_RBUTTONDOWN: | 
|  | 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 678  BOOL toolwin_initapp(HINSTANCE hInstance | Line 875  BOOL toolwin_initapp(HINSTANCE hInstance | 
 |  |  | 
 | WNDCLASS wc; | WNDCLASS wc; | 
 |  |  | 
| wc.style = 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 = 0; | wc.cbWndExtra = GTWL_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); | 
 | 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) { | 
 |  |  | 
 | char    path[MAX_PATH]; |  | 
 | HBITMAP hbmp; | HBITMAP hbmp; | 
 | BITMAP  bmp; | BITMAP  bmp; | 
 | HWND    hWnd; | HWND    hWnd; | 
| Line 702  void toolwin_open(void) { | Line 898  void toolwin_open(void) { | 
 | return; | return; | 
 | } | } | 
 | ZeroMemory(&toolwin, sizeof(toolwin)); | ZeroMemory(&toolwin, sizeof(toolwin)); | 
| skinsetdef(); | hbmp = skinload(np2tool.skin); | 
| milstr_ncpy(path, modulefile, sizeof(path)); |  | 
| file_cutname(path); |  | 
| file_catname(path, np2skin, sizeof(path)); |  | 
| hbmp = skinload(path); |  | 
 | if (hbmp == NULL) { | if (hbmp == NULL) { | 
 | goto twope_err1; | goto twope_err1; | 
 | } | } | 
 | GetObject(hbmp, sizeof(BITMAP), &bmp); | GetObject(hbmp, sizeof(BITMAP), &bmp); | 
 | toolwin.hbmp = hbmp; | toolwin.hbmp = hbmp; | 
| hWnd = CreateWindowEx(0, 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); | 
|  | SetForegroundWindow(hWndMain); | 
 | return; | return; | 
 |  |  | 
 | twope_err2: | 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; |  | 
|  |  | 
| if (toolwin.hwnd == NULL) { |  | 
| return; |  | 
| } |  | 
| GetWindowRect(hWndMain, &mainrc); |  | 
| GetWindowRect(toolwin.hwnd, &toolrc); |  | 
| if (((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right) && |  | 
| ((toolrc.bottom == mainrc.top) || (toolrc.top == mainrc.bottom))) || |  | 
| ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom) && |  | 
| ((toolrc.right == mainrc.left) || (toolrc.left == mainrc.right)))) { |  | 
| toolwin.parentcn = 1; |  | 
| toolwin.parentx = mainrc.left; |  | 
| toolwin.parenty = mainrc.top; |  | 
| } |  | 
| } |  | 
 |  |  | 
| void toolwin_movingend(void) { | return(toolwin.hwnd); | 
|  |  | 
| RECT    mainrc; |  | 
| RECT    toolrc; |  | 
| int             dx; |  | 
| int             dy; |  | 
|  |  | 
| if ((toolwin.hwnd) && (toolwin.parentcn)) { |  | 
| GetWindowRect(hWndMain, &mainrc); |  | 
| GetWindowRect(toolwin.hwnd, &toolrc); |  | 
| dx = mainrc.left - toolwin.parentx; |  | 
| dy = mainrc.top - toolwin.parenty; |  | 
| MoveWindow(toolwin.hwnd, toolrc.left + dx, toolrc.top + dy, |  | 
| toolrc.right - toolrc.left, |  | 
| toolrc.bottom - toolrc.top, TRUE); |  | 
| } |  | 
| toolwin.parentcn = 0; |  | 
 | } | } | 
 |  |  | 
 | void toolwin_setfdd(BYTE drv, const char *name) { | void toolwin_setfdd(BYTE drv, const char *name) { | 
| Line 785  void toolwin_setfdd(BYTE drv, const char | Line 946  void toolwin_setfdd(BYTE drv, const char | 
 | char    *q; | char    *q; | 
 | char    *p; | char    *p; | 
 | UINT    i; | UINT    i; | 
 |  | HWND    sub; | 
 |  |  | 
 | if (drv >= FDDLIST_DRV) { | if (drv >= FDDLIST_DRV) { | 
 | return; | return; | 
| Line 797  void toolwin_setfdd(BYTE drv, const char | Line 959  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 += sizeof(fdd->name[0]); | 
| Line 809  void toolwin_setfdd(BYTE drv, const char | Line 971  void toolwin_setfdd(BYTE drv, const char | 
 | p -= sizeof(fdd->name[0]); | p -= sizeof(fdd->name[0]); | 
 | q -= sizeof(fdd->name[0]); | q -= sizeof(fdd->name[0]); | 
 | } | } | 
| milstr_ncpy(fdd->name[0], name, sizeof(fdd->name[0])); | file_cpyname(fdd->name[0], name, sizeof(fdd->name[0])); | 
 | } | } | 
 | sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); | 
 | if (toolwin.hwnd != NULL) { | if (toolwin.hwnd != NULL) { | 
| setlist(drv); | sub = toolwin.sub[fddlist[drv]]; | 
| SetForegroundWindow(hWndMain); | if (sub) { | 
|  | remakefddlist(sub, fdd); | 
|  | SetForegroundWindow(hWndMain); | 
|  | } | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  |  | 
 | static void setdiskacc(UINT num, BYTE count) { | static void setdiskacc(UINT num, BYTE count) { | 
 |  |  | 
 | const DISKACC   *acc; | const DISKACC   *acc; | 
| BYTE            counter; | HWND            sub; | 
 |  |  | 
 | if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { | 
 | return; | return; | 
 | } | } | 
 | if (num < (sizeof(diskacc)/sizeof(DISKACC))) { | if (num < (sizeof(diskacc)/sizeof(DISKACC))) { | 
 | acc = diskacc + num; | acc = diskacc + num; | 
| counter = *(acc->counter); | sub = NULL; | 
|  | if (*(acc->counter) == 0) { | 
|  | sub = toolwin.sub[acc->idc]; | 
|  | } | 
 | *(acc->counter) = count; | *(acc->counter) = count; | 
| if (counter) { | if (sub) { | 
| InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); | InvalidateRect(sub, NULL, TRUE); | 
 | } | } | 
 | } | } | 
 | } | } | 
| Line 854  void toolwin_draw(BYTE frame) { | Line 1021  void toolwin_draw(BYTE frame) { | 
 | const DISKACC   *acc; | const DISKACC   *acc; | 
 | const DISKACC   *accterm; | const DISKACC   *accterm; | 
 | BYTE            counter; | BYTE            counter; | 
 |  | HWND            sub; | 
 |  |  | 
 | if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { | 
 | return; | return; | 
| Line 868  const DISKACC *accterm; | Line 1036  const DISKACC *accterm; | 
 | if (counter) { | if (counter) { | 
 | if (counter <= frame) { | if (counter <= frame) { | 
 | *(acc->counter) = 0; | *(acc->counter) = 0; | 
| InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); | sub = toolwin.sub[acc->idc]; | 
|  | if (sub) { | 
|  | InvalidateRect(sub, NULL, TRUE); | 
|  | } | 
 | } | } | 
 | else { | else { | 
 | *(acc->counter) -= frame; | *(acc->counter) -= frame; | 
| Line 881  const DISKACC *accterm; | Line 1052  const DISKACC *accterm; | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
 | static const char np2toolini[] = "np2tool.ini"; |  | 
 | static const char ini_title[] = "NP2 tool"; | static const char ini_title[] = "NP2 tool"; | 
 |  |  | 
 | static const INITBL iniitem[] = { | static const INITBL iniitem[] = { | 
 | {"WindposX", INITYPE_SINT32,    &np2tool.posx,                  0}, | {"WindposX", INITYPE_SINT32,    &np2tool.posx,                  0}, | 
 | {"WindposY", INITYPE_SINT32,    &np2tool.posy,                  0}, | {"WindposY", INITYPE_SINT32,    &np2tool.posy,                  0}, | 
 |  | {"WindType", INITYPE_BOOL,              &np2tool.type,                  0}, | 
 |  | {"SkinFile", INITYPE_STR,               np2tool.skin,                   MAX_PATH}, | 
 |  | {"SkinMRU0", INITYPE_STR,               np2tool.skinmru[0],             MAX_PATH}, | 
 |  | {"SkinMRU1", INITYPE_STR,               np2tool.skinmru[1],             MAX_PATH}, | 
 |  | {"SkinMRU2", INITYPE_STR,               np2tool.skinmru[2],             MAX_PATH}, | 
 |  | {"SkinMRU3", INITYPE_STR,               np2tool.skinmru[3],             MAX_PATH}, | 
 | {"FD1NAME0", INITYPE_STR,               np2tool.fdd[0].name[0], MAX_PATH}, | {"FD1NAME0", INITYPE_STR,               np2tool.fdd[0].name[0], MAX_PATH}, | 
 | {"FD1NAME1", INITYPE_STR,               np2tool.fdd[0].name[1], MAX_PATH}, | {"FD1NAME1", INITYPE_STR,               np2tool.fdd[0].name[1], MAX_PATH}, | 
 | {"FD1NAME2", INITYPE_STR,               np2tool.fdd[0].name[2], MAX_PATH}, | {"FD1NAME2", INITYPE_STR,               np2tool.fdd[0].name[2], MAX_PATH}, | 
| Line 904  static const INITBL iniitem[] = { | Line 1080  static const INITBL iniitem[] = { | 
 | {"FD2NAME6", INITYPE_STR,               np2tool.fdd[1].name[6], MAX_PATH}, | {"FD2NAME6", INITYPE_STR,               np2tool.fdd[1].name[6], MAX_PATH}, | 
 | {"FD2NAME7", INITYPE_STR,               np2tool.fdd[1].name[7], MAX_PATH}}; | {"FD2NAME7", INITYPE_STR,               np2tool.fdd[1].name[7], MAX_PATH}}; | 
 |  |  | 
 | static void getinifile(char *path, int leng) { |  | 
 |  |  | 
 | milstr_ncpy(path, modulefile, leng); |  | 
 | file_cutname(path); |  | 
 | file_catname(path, np2toolini, leng); |  | 
 | } |  | 
 |  |  | 
 | void toolwin_readini(void) { | void toolwin_readini(void) { | 
 |  |  | 
 | char    path[MAX_PATH]; | char    path[MAX_PATH]; | 
| Line 918  void toolwin_readini(void) { | Line 1087  void toolwin_readini(void) { | 
 | 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; | 
|  | initgetfile(path, sizeof(path)); | 
 | ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | 
 | } | } | 
 |  |  | 
| Line 926  void toolwin_writeini(void) { | Line 1096  void toolwin_writeini(void) { | 
 |  |  | 
 | char    path[MAX_PATH]; | char    path[MAX_PATH]; | 
 |  |  | 
| getinifile(path, sizeof(path)); | initgetfile(path, sizeof(path)); | 
 | ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | 
 | } | } | 
 |  |  |