Diff for /np2/win9x/toolwin.cpp between versions 1.7 and 1.10

version 1.7, 2003/10/30 12:45:38 version 1.10, 2003/10/30 22:33:34
Line 24  enum { Line 24  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,
   
         IDC_SKINDEF                             = 3100,          IDC_SKINSEL                             = 3100,
         IDC_SKINSEL                             = 3101,          IDC_SKINDEF                             = 3101,
         IDC_TOOLCLOSE                   = 3102          IDC_SKINMRU                             = 3102,
           IDC_TOOLCLOSE                   = IDC_SKINMRU + SKINMRU_MAX
   };
   
   enum {
           TCTL_STATIC                             = 0,
           TCTL_BUTTON                             = 1,
           TCTL_DDLIST                             = 2
 };  };
   
 typedef struct {  typedef struct {
Line 42  typedef struct { Line 51  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 {
Line 73  typedef struct { Line 82  typedef struct {
         SUBCLASSPROC    subproc[IDC_MAXITEMS];          SUBCLASSPROC    subproc[IDC_MAXITEMS];
 } TOOLWIN;  } TOOLWIN;
   
   enum {
           GTWL_FOCUS              = 0,
           GTWL_SIZE               = 4
   };
   
                 NP2TOOL         np2tool;                  NP2TOOL         np2tool;
 static  TOOLSKIN        toolskin;  static  TOOLSKIN        toolskin;
Line 101  static const DISKACC diskacc[3] = { Line 114  static const DISKACC diskacc[3] = {
 static HBITMAP skinload(const char *path) {  static HBITMAP skinload(const char *path) {
   
         char    fname[MAX_PATH];          char    fname[MAX_PATH];
           UINT    i;
         HBITMAP ret;          HBITMAP ret;
   
         ZeroMemory(&toolskin, sizeof(toolskin));          ZeroMemory(&toolskin, sizeof(toolskin));
Line 108  static HBITMAP skinload(const char *path Line 122  static HBITMAP skinload(const char *path
         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));  
   
         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));
Line 233  static void sellist(UINT drv) { Line 258  static void sellist(UINT drv) {
         }          }
 }  }
   
 static void remakefddlist(UINT drv) {  static void remakefddlist(HWND hwnd, TOOLFDD *fdd) {
   
         TOOLFDD *fdd;  
         char    *p;          char    *p;
         UINT    cnt;          UINT    cnt;
         char    *q;          char    *q;
Line 244  static void remakefddlist(UINT drv) { Line 268  static void remakefddlist(UINT drv) {
         UINT    j;          UINT    j;
         UINT    sel;          UINT    sel;
   
         if (drv >= FDDLIST_DRV) {  
                 return;  
         }  
         fdd = np2tool.fdd + drv;  
         p = fdd->name[0];          p = fdd->name[0];
         for (cnt=0; cnt<FDDLIST_MAX; cnt++) {          for (cnt=0; cnt<FDDLIST_MAX; cnt++) {
                 if (p[0] == '\0') {                  if (p[0] == '\0') {
Line 276  static void remakefddlist(UINT drv) { Line 296  static void remakefddlist(UINT drv) {
                         }                          }
                 }                  }
         }          }
         setlist(toolwin.sub[fddlist[drv]], fdd, sel);          setlist(hwnd, fdd, sel);
 }  }
   
 static void accdraw(HWND hWnd, BYTE count) {  static void accdraw(HWND hWnd, BYTE count) {
Line 302  static LRESULT CALLBACK twsub(HWND hWnd, Line 322  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 319  static LRESULT CALLBACK twsub(HWND hWnd, Line 335  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 362  static LRESULT CALLBACK twsub(HWND hWnd, Line 379  static LRESULT CALLBACK twsub(HWND hWnd,
                         return(FALSE);                          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));          return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp));
 }  }
   
Line 371  static void toolwincreate(HWND hWnd) { Line 396  static void toolwincreate(HWND hWnd) {
 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 385  const SUBITEM *p; Line 412  const SUBITEM *p;
   
         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), hInst, 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] = (SUBCLASSPROC)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]];
                 remakefddlist((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;
   
         if (toolwin.hbmp) {          if (toolwin.hbmp) {
                 for (i=0; i<IDC_MAXITEMS; i++) {                  for (i=0; i<IDC_MAXITEMS; i++) {
                         DestroyWindow(toolwin.sub[i]);                          sub = toolwin.sub[i];
                           if (sub) {
                                   DestroyWindow(sub);
                           }
                 }                  }
                 DeleteObject(toolwin.access[0]);                  DeleteObject(toolwin.access[0]);
                 DeleteObject(toolwin.access[1]);                  DeleteObject(toolwin.access[1]);
Line 436  static void toolwinpaint(HWND hWnd) { Line 505  static void toolwinpaint(HWND hWnd) {
         EndPaint(hWnd, &ps);          EndPaint(hWnd, &ps);
 }  }
   
 static void changeskin(HWND hWnd) {  static void tooldrawbutton(HWND hWnd, UINT idc, LPDRAWITEMSTRUCT lpdis) {
   
           POINT   pt;
           HWND    sub;
           RECT    rect;
           HDC             hdc;
           HDC             hmdc;
           RECT    btn;
   
           idc -= IDC_BASE;
           if (idc >= 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; cnt<SKINMRU_MAX; cnt++) {
                   p = np2tool.skinmru[cnt];
                   if (p[0] == '\0') {
                           break;
                   }
                   p = file_getname(p);
                   for (i=0; i<cnt; i++) {
                           if (file_cmpname(p, file[id[i]]) < 0) {
                                   break;
                           }
                   }
                   for (j=cnt; j>i; j--) {
                           id[j] = id[j-1];
                   }
                   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, IDC_SKINMRU + j, file[j]);
           }
           return(ret);
   }
   
   static void skinchange(HWND hWnd) {
   
   const char      *p;
           UINT    i;
         HBITMAP hbmp;          HBITMAP hbmp;
         BITMAP  bmp;          BITMAP  bmp;
   
           p = np2tool.skin;
           if (p[0]) {
                   for (i=0; i<(SKINMRU_MAX - 1); i++) {
                           if (!file_cmpname(p, np2tool.skinmru[i])) {
                                   break;
                           }
                   }
                   while(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();          toolwin_movingstart();
         toolwindestroy();          toolwindestroy();
         hbmp = skinload(np2tool.skin);          hbmp = skinload(np2tool.skin);
Line 643  static void movingproc(RECT *rect) { Line 815  static void movingproc(RECT *rect) {
   
 // ----  // ----
   
 static void open_popup(HWND hWnd, LPARAM lp) {  static void openpopup(HWND hWnd, LPARAM lp) {
   
         HMENU           hMenu;          HMENU   hMenu;
         POINT           pt;          POINT   pt;
   
         hMenu = CreatePopupMenu();          hMenu = CreatePopupMenu();
         AppendMenu(hMenu, MF_STRING, IDC_SKINDEF, str_skindef);          AppendMenu(hMenu, MF_POPUP, (UINT)createskinmenu(), str_toolskin);
         AppendMenu(hMenu, MF_STRING, IDC_SKINSEL, str_skinsel);  
         AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);          AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
         AppendMenu(hMenu, MF_STRING, IDC_TOOLCLOSE, str_toolclose);          AppendMenu(hMenu, MF_STRING, IDC_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);
         TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL);          TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL);
           ModifyMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, (UINT)0, str_toolskin);
         DestroyMenu(hMenu);          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;          BOOL    r;
           UINT    idc;
   
         switch(msg) {          switch(msg) {
                 case WM_CREATE:                  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,                          SetWindowLong(hWnd, GWL_STYLE,
                                                         GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION));                                                          GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION));
                         SetWindowPos(hWnd, 0, 0, 0, 0, 0,                          SetWindowPos(hWnd, 0, 0, 0, 0, 0,
Line 675  static LRESULT CALLBACK twproc(HWND hWnd Line 854  static LRESULT CALLBACK twproc(HWND hWnd
   
                 case WM_SYSCOMMAND:                  case WM_SYSCOMMAND:
                         switch(wp) {                          switch(wp) {
                                 case IDC_SKINDEF:  
                                         np2tool.skin[0] = '\0';  
                                         changeskin(hWnd);  
                                         sysmng_update(SYS_UPDATEOSCFG);  
                                         break;  
   
                                 case IDC_SKINSEL:                                  case IDC_SKINSEL:
                                         soundmng_disable(SNDPROC_TOOL);                                  case IDC_SKINDEF:
                                         r = dlgs_selectfile(hWnd, &skinui, np2tool.skin,                                  case IDC_SKINMRU + 0:
                                                                                         sizeof(np2tool.skin), NULL);                                  case IDC_SKINMRU + 1:
                                         soundmng_enable(SNDPROC_TOOL);                                  case IDC_SKINMRU + 2:
                                         if (r) {                                  case IDC_SKINMRU + 3:
                                                 changeskin(hWnd);                                          return(SendMessage(hWnd, WM_COMMAND, wp, lp));
                                                 sysmng_update(SYS_UPDATEOSCFG);  
                                         }  
                                         break;  
   
                                 default:                                  default:
                                         return(DefWindowProc(hWnd, msg, wp, lp));                                          return(DefWindowProc(hWnd, msg, wp, lp));
Line 733  static LRESULT CALLBACK twproc(HWND hWnd Line 903  static LRESULT CALLBACK twproc(HWND hWnd
                                         toolwin_setfdd(1, NULL);                                          toolwin_setfdd(1, NULL);
                                         break;                                          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:                                  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;                                          break;
   
                                 case IDC_TOOLCLOSE:                                  case IDC_TOOLCLOSE:
Line 744  static LRESULT CALLBACK twproc(HWND hWnd Line 943  static LRESULT CALLBACK twproc(HWND hWnd
                         }                          }
                         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);
                           }
                           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:                  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_disable(SNDPROC_TOOL);                          soundmng_disable(SNDPROC_TOOL);
                         break;                          break;
Line 796  static LRESULT CALLBACK twproc(HWND hWnd Line 1019  static LRESULT CALLBACK twproc(HWND hWnd
                         break;                          break;
   
                 case WM_RBUTTONDOWN:                  case WM_RBUTTONDOWN:
                         open_popup(hWnd, lp);                          openpopup(hWnd, lp);
                         break;                          break;
   
                 default:                  default:
Line 812  BOOL toolwin_initapp(HINSTANCE hInstance Line 1035  BOOL toolwin_initapp(HINSTANCE hInstance
         wc.style = CS_HREDRAW | CS_VREDRAW;          wc.style = CS_HREDRAW | CS_VREDRAW;
         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);
Line 827  void toolwin_open(void) { Line 1050  void toolwin_open(void) {
         HBITMAP hbmp;          HBITMAP hbmp;
         BITMAP  bmp;          BITMAP  bmp;
         HWND    hWnd;          HWND    hWnd;
         HMENU   hMenu;  
   
         if (toolwin.hwnd) {          if (toolwin.hwnd) {
                 return;                  return;
Line 849  void toolwin_open(void) { Line 1071  void toolwin_open(void) {
         }          }
         UpdateWindow(hWnd);          UpdateWindow(hWnd);
         ShowWindow(hWnd, SW_SHOW);          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);          SetForegroundWindow(hWndMain);
         return;          return;
   
Line 980  void toolwin_setfdd(BYTE drv, const char Line 1197  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 992  void toolwin_setfdd(BYTE drv, const char Line 1210  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 1004  void toolwin_setfdd(BYTE drv, const char Line 1222  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) {
                 remakefddlist(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 1048  void toolwin_draw(BYTE frame) { Line 1272  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 1062  const DISKACC *accterm; Line 1287  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 1075  const DISKACC *accterm; Line 1303  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},
         {"SkinFile", INITYPE_STR,               np2tool.skin,                   MAX_PATH},          {"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 1099  static const INITBL iniitem[] = { Line 1330  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 1113  void toolwin_readini(void) { Line 1337  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));          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 1121  void toolwin_writeini(void) { Line 1345  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));
 }  }
   

Removed from v.1.7  
changed lines
  Added in v.1.10


RetroPC.NET-CVS <cvs@retropc.net>