--- np2/win9x/toolwin.cpp 2003/10/29 21:35:58 1.5 +++ np2/win9x/toolwin.cpp 2003/10/30 22:33:34 1.10 @@ -24,13 +24,22 @@ enum { IDC_TOOLFDD2LIST, IDC_TOOLFDD2BROWSE, IDC_TOOLFDD2EJECT, + IDC_TOOLRESET, + IDC_TOOLPOWER, IDC_MAXITEMS, IDC_BASE = 3000, - IDC_SKINDEF = 3100, - IDC_SKINSEL = 3101, - IDC_TOOLCLOSE = 3102 + IDC_SKINSEL = 3100, + IDC_SKINDEF = 3101, + IDC_SKINMRU = 3102, + IDC_TOOLCLOSE = IDC_SKINMRU + SKINMRU_MAX +}; + +enum { + TCTL_STATIC = 0, + TCTL_BUTTON = 1, + TCTL_DDLIST = 2 }; typedef struct { @@ -42,14 +51,14 @@ typedef struct { } TOOLSKIN; typedef struct { -const char *cname; + UINT tctl; const char *text; - DWORD style; short posx; short posy; short width; short height; - BOOL tabstop; + short extend; + short padding; } SUBITEM; typedef struct { @@ -73,6 +82,10 @@ typedef struct { SUBCLASSPROC subproc[IDC_MAXITEMS]; } TOOLWIN; +enum { + GTWL_FOCUS = 0, + GTWL_SIZE = 4 +}; NP2TOOL np2tool; static TOOLSKIN toolskin; @@ -101,6 +114,7 @@ static const DISKACC diskacc[3] = { static HBITMAP skinload(const char *path) { char fname[MAX_PATH]; + UINT i; HBITMAP ret; ZeroMemory(&toolskin, sizeof(toolskin)); @@ -108,12 +122,23 @@ static HBITMAP skinload(const char *path milstr_ncpy(toolskin.font, str_deffont, sizeof(toolskin.font)); toolskin.color1 = 0x600000; toolskin.color2 = 0xff0000; - CopyMemory(subitem, defsubitem, sizeof(defsubitem)); - if (path) { - ini_read(path, skintitle, skinini, sizeof(skinini)/sizeof(INITBL)); + ini_read(path, skintitle, skinini1, sizeof(skinini1)/sizeof(INITBL)); } - if ((path) && (toolskin.main[0])) { + if (toolskin.main[0]) { + ZeroMemory(subitem, sizeof(defsubitem)); + for (i=0; i= FDDLIST_DRV) { - return; - } - fdd = np2tool.fdd + drv; p = fdd->name[0]; for (cnt=0; cnt= IDC_MAXITEMS) { return(0); } if (msg == WM_KEYDOWN) { - if ((TCHAR)wp == VK_TAB) { + if ((short)wp == VK_TAB) { dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; newidc = idc; do { @@ -319,14 +335,15 @@ static LRESULT CALLBACK twsub(HWND hWnd, if (newidc >= IDC_MAXITEMS) { 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]); break; } } while(idc != newidc); } - else if ((TCHAR)wp == VK_RETURN) { - if (subitem[idc].cname == str_button) { + else if ((short)wp == VK_RETURN) { + if (subitem[idc].tctl == TCTL_BUTTON) { return(CallWindowProc(toolwin.subproc[idc], hWnd, WM_KEYDOWN, VK_SPACE, 0)); } @@ -362,6 +379,14 @@ static LRESULT CALLBACK twsub(HWND hWnd, return(FALSE); } } + else if (msg == WM_SETFOCUS) { + SetWindowLong(GetParent(hWnd), GTWL_FOCUS, idc); + } + else if (msg == WM_SYSKEYDOWN) { + if (((short)wp == VK_SPACE) && (lp & 0x20000000)) { + return(SendMessage(GetParent(hWnd), msg, wp, lp)); + } + } return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); } @@ -371,6 +396,8 @@ static void toolwincreate(HWND hWnd) { const SUBITEM *p; UINT i; HWND sub; +const char *cls; + DWORD style; toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, @@ -385,29 +412,71 @@ const SUBITEM *p; p = subitem; for (i=0; icname, p->text, - WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, - hWnd, (HMENU)(i + IDC_BASE), hInst, NULL); + sub = NULL; + cls = 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.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); - SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); - SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, + toolwin.subproc[i] = NULL; + if (sub) { + toolwin.subproc[i] = (SUBCLASSPROC)GetWindowLong(sub, GWL_WNDPROC); + SetWindowLong(sub, GWL_WNDPROC, (LONG)twsub); + SendMessage(sub, WM_SETFONT, (WPARAM)toolwin.hfont, MAKELPARAM(TRUE, 0)); + } p++; } for (i=0; i= IDC_MAXITEMS) { + 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 HMENU createskinmenu(void) { + + HMENU ret; + UINT cnt; +const char *base; + UINT flag; + char *p; + UINT i; + UINT j; + UINT id[SKINMRU_MAX]; +const char *file[SKINMRU_MAX]; + + ret = CreatePopupMenu(); + AppendMenu(ret, MF_STRING, IDC_SKINSEL, str_skinsel); + AppendMenu(ret, MF_SEPARATOR, 0, NULL); + + base = np2tool.skin; + flag = (base[0] == '\0')?MF_CHECKED:0; + AppendMenu(ret, MF_STRING + flag, IDC_SKINDEF, str_skindef); + for (cnt=0; cnti; j--) { + id[j] = id[j-1]; + } + id[i] = cnt; + file[cnt] = p; + } + for (i=0; i 0) { + CopyMemory(np2tool.skinmru[i], np2tool.skinmru[i-1], + sizeof(np2tool.skinmru[0])); + i--; + } + file_cpyname(np2tool.skinmru[0], p, sizeof(np2tool.skinmru[0])); + } + ModifyMenu(GetSystemMenu(hWnd, FALSE), 0, MF_BYPOSITION | MF_POPUP, + (UINT)createskinmenu(), str_toolskin); + DrawMenuBar(hWnd); + sysmng_update(SYS_UPDATEOSCFG); + toolwin_movingstart(); toolwindestroy(); hbmp = skinload(np2tool.skin); @@ -492,38 +664,80 @@ static void movingproc(RECT *rect) { return; } - changes = FALSE; - do { - if (toolwin.winflg & 1) { - toolwin.wingx += rect->left - toolwin.wintx; - rect->left = toolwin.wintx; + if (toolwin.winflg & 0x03) { + toolwin.wingx += rect->left - toolwin.wintx; + rect->left = toolwin.wintx; + if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { + toolwin.winflg &= ~0x03; + rect->left += toolwin.wingx; + toolwin.wingx = 0; } - else { - d = SNAPDOTPULL; + rect->right = rect->left + winlx; + } + if (toolwin.winflg & 0x0c) { + toolwin.wingy += rect->top - toolwin.winty; + rect->top = toolwin.winty; + if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { + toolwin.winflg &= ~0x0c; + rect->top += toolwin.wingy; + toolwin.wingy = 0; + } + rect->bottom = rect->top + winly; + } + + 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; + } + } + + do { + changes = FALSE; + if ((!(toolwin.winflg & 0x01)) && + (rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)) { do { - connecty = ((rect->bottom >= mainrc.top) && - (rect->top <= mainrc.bottom)); - if (connecty) { - d = rect->left - mainrc.right; + 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.left; + d = rect->right - mainrc.right; 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)) { + do { d = rect->left - workrc.left; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; @@ -534,53 +748,49 @@ static void movingproc(RECT *rect) { } } while(0); if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - toolwin.winflg |= 1; + toolwin.winflg |= 0x02; rect->left -= d; + rect->right = rect->left + winlx; toolwin.wingx = d; toolwin.wintx = rect->left; + changes = TRUE; } } - if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { - toolwin.winflg &= ~1; - rect->left += toolwin.wingx; - toolwin.wingx = 0; - } - rect->right = rect->left + winlx; - - if (changes) { - break; - } - if (toolwin.winflg & 2) { - toolwin.wingy += rect->top - toolwin.winty; - rect->top = toolwin.winty; - } - else { - d = SNAPDOTPULL; + if ((!(toolwin.winflg & 0x04)) && + (rect->right >= mainrc.left) && (rect->left <= mainrc.right)) { do { - connectx = ((rect->right >= mainrc.left) && - (rect->left <= mainrc.right)); - if (connectx) { - d = rect->top - mainrc.bottom; + d = rect->top - mainrc.bottom; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + d = rect->bottom - mainrc.top; + if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { + break; + } + if ((rect->right == mainrc.left) || + (rect->left == mainrc.right)) { + d = rect->top - mainrc.top; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - d = rect->bottom - mainrc.top; + d = rect->bottom - mainrc.bottom; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; } - if ((rect->right == mainrc.left) || - (rect->left == mainrc.right)) { - 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)) { + do { d = rect->top - workrc.top; if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { break; @@ -591,61 +801,50 @@ static void movingproc(RECT *rect) { } } while(0); if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { - toolwin.winflg |= 2; + toolwin.winflg |= 0x08; rect->top -= d; + rect->bottom = rect->top + winly; 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; - } } // ---- -static void open_popup(HWND hWnd, LPARAM lp) { +static void openpopup(HWND hWnd, LPARAM lp) { - HMENU hMenu; - POINT pt; + HMENU hMenu; + POINT pt; hMenu = CreatePopupMenu(); - AppendMenu(hMenu, MF_STRING, IDC_SKINDEF, str_skindef); - AppendMenu(hMenu, MF_STRING, IDC_SKINSEL, str_skinsel); + AppendMenu(hMenu, MF_POPUP, (UINT)createskinmenu(), str_toolskin); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); AppendMenu(hMenu, MF_STRING, IDC_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); + ModifyMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, (UINT)0, str_toolskin); DestroyMenu(hMenu); } static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { + HMENU hMenu; BOOL r; + UINT idc; switch(msg) { case WM_CREATE: + hMenu = GetSystemMenu(hWnd, FALSE); + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, + (UINT)createskinmenu(), str_toolskin); + InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); SetWindowPos(hWnd, 0, 0, 0, 0, 0, @@ -655,22 +854,13 @@ static LRESULT CALLBACK twproc(HWND hWnd case WM_SYSCOMMAND: switch(wp) { - case IDC_SKINDEF: - np2tool.skin[0] = '\0'; - changeskin(hWnd); - sysmng_update(SYS_UPDATEOSCFG); - break; - case IDC_SKINSEL: - soundmng_stop(); - r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, - sizeof(np2tool.skin), NULL); - soundmng_play(); - if (r) { - changeskin(hWnd); - sysmng_update(SYS_UPDATEOSCFG); - } - break; + case IDC_SKINDEF: + case IDC_SKINMRU + 0: + case IDC_SKINMRU + 1: + case IDC_SKINMRU + 2: + case IDC_SKINMRU + 3: + return(SendMessage(hWnd, WM_COMMAND, wp, lp)); default: return(DefWindowProc(hWnd, msg, wp, lp)); @@ -686,9 +876,9 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case IDC_BASE + IDC_TOOLFDD1BROWSE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); dialog_changefdd(hWnd, 0); - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case IDC_BASE + IDC_TOOLFDD1EJECT: @@ -703,9 +893,9 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case IDC_BASE + IDC_TOOLFDD2BROWSE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); dialog_changefdd(hWnd, 1); - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case IDC_BASE + IDC_TOOLFDD2EJECT: @@ -713,9 +903,38 @@ static LRESULT CALLBACK twproc(HWND hWnd toolwin_setfdd(1, NULL); break; - case IDC_SKINDEF: + case IDC_BASE + IDC_TOOLRESET: + SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); + SetForegroundWindow(hWndMain); + break; + + case IDC_BASE + IDC_TOOLPOWER: + SendMessage(hWndMain, WM_CLOSE, 0, 0L); + break; + case IDC_SKINSEL: - SendMessage(hWnd, WM_SYSCOMMAND, wp, lp); + 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 IDC_SKINDEF: + np2tool.skin[0] = '\0'; + skinchange(hWnd); + break; + + case IDC_SKINMRU + 0: + case IDC_SKINMRU + 1: + case IDC_SKINMRU + 2: + case IDC_SKINMRU + 3: + file_cpyname(np2tool.skin, + np2tool.skinmru[LOWORD(wp) - IDC_SKINMRU], + sizeof(np2tool.skin)); + skinchange(hWnd); break; case IDC_TOOLCLOSE: @@ -724,25 +943,49 @@ static LRESULT CALLBACK twproc(HWND hWnd } 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); + } + break; + + case WM_SYSKEYDOWN: // ALT+SPACEを自前処理 + if (((short)wp == VK_SPACE) && (lp & 0x20000000)) { + POINT pt; + pt.x = 0; + pt.y = 0; + ClientToScreen(hWnd, &pt); + return(SendMessage(hWnd, 0x313, 0, MAKELPARAM(pt.x, pt.y))); + } + break; + case WM_PAINT: toolwinpaint(hWnd); break; + case WM_DRAWITEM: + tooldrawbutton(hWnd, wp, (LPDRAWITEMSTRUCT)lp); + break; + case WM_ENTERMENULOOP: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); break; case WM_EXITMENULOOP: - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case WM_ENTERSIZEMOVE: - soundmng_stop(); + soundmng_disable(SNDPROC_TOOL); movingstart(); break; case WM_EXITSIZEMOVE: - soundmng_play(); + soundmng_enable(SNDPROC_TOOL); break; case WM_MOVING: @@ -776,7 +1019,7 @@ static LRESULT CALLBACK twproc(HWND hWnd break; case WM_RBUTTONDOWN: - open_popup(hWnd, lp); + openpopup(hWnd, lp); break; default: @@ -789,10 +1032,10 @@ BOOL toolwin_initapp(HINSTANCE hInstance WNDCLASS wc; - wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = twproc; wc.cbClsExtra = 0; - wc.cbWndExtra = 0; + wc.cbWndExtra = GTWL_SIZE; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -807,7 +1050,6 @@ void toolwin_open(void) { HBITMAP hbmp; BITMAP bmp; HWND hWnd; - HMENU hMenu; if (toolwin.hwnd) { return; @@ -829,11 +1071,6 @@ void toolwin_open(void) { } UpdateWindow(hWnd); ShowWindow(hWnd, SW_SHOW); - - 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); return; @@ -853,7 +1090,6 @@ void toolwin_close(void) { } } -#if 1 void toolwin_movingstart(void) { RECT mainrc; @@ -954,46 +1190,6 @@ void toolwin_movingend(void) { } MoveWindow(toolwin.hwnd, toolrc.left, toolrc.top, cx, cy, TRUE); } -#else -void toolwin_movingstart(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) { - - 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; -} -#endif void toolwin_setfdd(BYTE drv, const char *name) { @@ -1001,6 +1197,7 @@ void toolwin_setfdd(BYTE drv, const char char *q; char *p; UINT i; + HWND sub; if (drv >= FDDLIST_DRV) { return; @@ -1013,7 +1210,7 @@ void toolwin_setfdd(BYTE drv, const char fdd->insert = 1; q = fdd->name[0]; for (i=0; i<(FDDLIST_MAX - 1); i++) { - if (!milstr_cmp(q, name)) { + if (!file_cmpname(q, name)) { break; } q += sizeof(fdd->name[0]); @@ -1025,29 +1222,35 @@ void toolwin_setfdd(BYTE drv, const char p -= 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); if (toolwin.hwnd != NULL) { - remakefddlist(drv); - SetForegroundWindow(hWndMain); + sub = toolwin.sub[fddlist[drv]]; + if (sub) { + remakefddlist(sub, fdd); + SetForegroundWindow(hWndMain); + } } } static void setdiskacc(UINT num, BYTE count) { const DISKACC *acc; - BYTE counter; + HWND sub; if (toolwin.hwnd == NULL) { return; } if (num < (sizeof(diskacc)/sizeof(DISKACC))) { acc = diskacc + num; - counter = *(acc->counter); + sub = NULL; + if (*(acc->counter) == 0) { + sub = toolwin.sub[acc->idc]; + } *(acc->counter) = count; - if (counter) { - InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); + if (sub) { + InvalidateRect(sub, NULL, TRUE); } } } @@ -1069,6 +1272,7 @@ void toolwin_draw(BYTE frame) { const DISKACC *acc; const DISKACC *accterm; BYTE counter; + HWND sub; if (toolwin.hwnd == NULL) { return; @@ -1083,7 +1287,10 @@ const DISKACC *accterm; if (counter) { if (counter <= frame) { *(acc->counter) = 0; - InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); + sub = toolwin.sub[acc->idc]; + if (sub) { + InvalidateRect(sub, NULL, TRUE); + } } else { *(acc->counter) -= frame; @@ -1096,13 +1303,16 @@ const DISKACC *accterm; // ---- -static const char np2toolini[] = "np2tool.ini"; 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}, + {"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}, {"FD1NAME1", INITYPE_STR, np2tool.fdd[0].name[1], MAX_PATH}, {"FD1NAME2", INITYPE_STR, np2tool.fdd[0].name[2], MAX_PATH}, @@ -1120,13 +1330,6 @@ static const INITBL iniitem[] = { {"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) { - - milstr_ncpy(path, modulefile, leng); - file_cutname(path); - file_catname(path, np2toolini, leng); -} - void toolwin_readini(void) { char path[MAX_PATH]; @@ -1134,7 +1337,7 @@ void toolwin_readini(void) { ZeroMemory(&np2tool, sizeof(np2tool)); np2tool.posx = CW_USEDEFAULT; np2tool.posy = CW_USEDEFAULT; - getinifile(path, sizeof(path)); + initgetfile(path, sizeof(path)); ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); } @@ -1142,7 +1345,7 @@ void toolwin_writeini(void) { char path[MAX_PATH]; - getinifile(path, sizeof(path)); + initgetfile(path, sizeof(path)); ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); }