--- np2/win9x/toolwin.cpp 2003/10/28 18:21:05 1.1 +++ np2/win9x/toolwin.cpp 2003/10/28 22:05:46 1.2 @@ -3,7 +3,9 @@ #include "resource.h" #include "np2.h" #include "dosio.h" +#include "soundmng.h" #include "sysmng.h" +#include "menu.h" #include "toolwin.h" #include "ini.h" #include "dialog.h" @@ -60,7 +62,7 @@ static const BYTE fddlist[FDDLIST_DRV] = IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; static const SUBITEM subitem[IDC_MAXITEMS] = { - {str_static, NULL, WS_VISIBLE, 0, 47, 44, 8, 3}, + {str_static, NULL, WS_VISIBLE, 0, 49, 44, 8, 3}, {str_static, NULL, WS_VISIBLE, 0, 93, 19, 8, 3}, {str_combobox, NULL, WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 6, 248, 160}, @@ -82,6 +84,9 @@ static const SUBITEM subitem[IDC_MAXITEM typedef struct { HWND hwnd; + BYTE fddaccess[2]; + BYTE hddaccess; + BYTE _padding; int winflg; int wingx; int wingy; @@ -92,18 +97,29 @@ typedef struct { int parenty; HFONT hfont; HDC hdcfont; + HBRUSH access[2]; HWND sub[IDC_MAXITEMS]; SCPROC subproc[IDC_MAXITEMS]; } TOOLWIN; static TOOLWIN toolwin; +typedef struct { + WORD idc; + BYTE *counter; +} DISKACC; + +static const DISKACC diskacc[3] = { + {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, + {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, + {IDC_TOOLHDDACC, &toolwin.hddaccess}}; + + static void calctextsize(char *path, int leng, const char *p, int width) { HDC hdc; SIZE cur; char work[MAX_PATH]; -const char *q; int l; SIZE tail; int pos; @@ -213,6 +229,21 @@ static void sellist(UINT drv) { } } +static void accdraw(HWND hWnd, BYTE count) { + + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + HBRUSH hbrush; + + hdc = BeginPaint(hWnd, &ps); + GetClientRect(hWnd, &rc); + hbrush = (HBRUSH)SelectObject(hdc, toolwin.access[(count)?1:0]); + PatBlt(hdc, rc.left, rc.top, rc.right, rc.bottom, PATCOPY); + SelectObject(hdc, hbrush); + EndPaint(hWnd, &ps); +} + static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { UINT idc; @@ -228,7 +259,7 @@ static LRESULT CALLBACK twsub(HWND hWnd, return(0); } if (msg == WM_DROPFILES) { - files = DragQueryFile((HDROP)wp, 0xFFFFFFFF, NULL, 0); + files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); if (files == 1) { DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); if (idc == IDC_TOOLFDD1LIST) { @@ -243,6 +274,20 @@ static LRESULT CALLBACK twsub(HWND hWnd, DragFinish((HDROP)wp); return(FALSE); } + else if (msg == WM_PAINT) { + if (idc == IDC_TOOLHDDACC) { + accdraw(hWnd, toolwin.hddaccess); + return(FALSE); + } + else if (idc == IDC_TOOLFDD1ACC) { + accdraw(hWnd, toolwin.fddaccess[0]); + return(FALSE); + } + else if (idc == IDC_TOOLFDD2ACC) { + accdraw(hWnd, toolwin.fddaccess[1]); + return(FALSE); + } + } return(CallWindowProc(toolwin.subproc[idc], hWnd, msg, wp, lp)); } @@ -262,6 +307,9 @@ const SUBITEM *p; ReleaseDC(NULL, hdc); SelectObject(toolwin.hdcfont, toolwin.hfont); + toolwin.access[0] = CreateSolidBrush(0x000060); + toolwin.access[1] = CreateSolidBrush(0x0000ff); + hinstance = ((LPCREATESTRUCT)lp)->hInstance; p = subitem; for (i=0; icounter); + *(acc->counter) = count; + if (counter) { + InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); + } + } +} + +void toolwin_fddaccess(BYTE drv) { + + if (drv < 2) { + setdiskacc(drv, 20); + } +} + +void toolwin_hddaccess(BYTE drv) { + + setdiskacc(2, 10); +} + +void toolwin_draw(BYTE frame) { + +const DISKACC *acc; +const DISKACC *accterm; + BYTE counter; + + if (toolwin.hwnd == NULL) { + return; + } + if (!frame) { + frame = 1; + } + acc = diskacc; + accterm = acc + (sizeof(diskacc)/sizeof(DISKACC)); + while(acc < accterm) { + counter = *acc->counter; + if (counter) { + if (counter <= frame) { + *(acc->counter) = 0; + InvalidateRect(toolwin.sub[acc->idc], NULL, TRUE); + } + else { + *(acc->counter) -= frame; + } + } + acc++; + } +} + + // ---- static const char np2toolini[] = "np2tool.ini";