|
|
| version 1.2, 2003/10/28 22:05:46 | version 1.25, 2007/12/28 20:36:40 |
|---|---|
| Line 2 | Line 2 |
| #include "strres.h" | #include "strres.h" |
| #include "resource.h" | #include "resource.h" |
| #include "np2.h" | #include "np2.h" |
| #include "winloc.h" | |
| #include "oemtext.h" | |
| #include "dosio.h" | #include "dosio.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "sysmng.h" | #include "sysmng.h" |
| #include "menu.h" | #include "menu.h" |
| #include "toolwin.h" | #include "toolwin.h" |
| #include "ini.h" | #include "ini.h" |
| #include "np2class.h" | |
| #include "dialog.h" | #include "dialog.h" |
| #include "dialogs.h" | |
| #include "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 | |
| NP2TOOL np2tool; | |
| static const char np2toolclass[] = "np2-toolwin"; | |
| static const char np2tooltitle[] = "NP2 tool"; | |
| static const char str_deffont[] = "£Í£Ó £Ð¥´¥·¥Ã¥¯"; | |
| static const char str_static[] = "STATIC"; | |
| static const char str_combobox[] = "COMBOBOX"; | |
| static const char str_button[] = "BUTTON"; | |
| static const char str_browse[] = "..."; | |
| static const char str_eject[] = "Eject"; | |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| Line 42 enum { | Line 30 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 |
| }; | }; |
| typedef struct { | enum { |
| const char *cname; | TCTL_STATIC = 0, |
| const char *text; | TCTL_BUTTON = 1, |
| DWORD style; | TCTL_DDLIST = 2 |
| DWORD exstyle; | |
| short posx; | |
| short posy; | |
| short width; | |
| short height; | |
| } SUBITEM; | |
| static const BYTE fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const SUBITEM subitem[IDC_MAXITEMS] = { | |
| {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}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 7, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 7, 34, 17}, | |
| {str_static, NULL, WS_VISIBLE, 0, 93, 41, 8, 3}, | |
| {str_combobox, NULL, | |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 28, 248, 160}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 29, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 29, 34, 17}, | |
| }; | }; |
| // static const DWORD mvccol[MVC_MAXCOLOR] = { | typedef struct { |
| // 0xc0e8f8, 0xd8ecf4, 0x48a8c8, 0x000000}; | OEMCHAR main[MAX_PATH]; |
| OEMCHAR font[64]; | |
| SINT32 fontsize; | |
| UINT32 color1; | |
| UINT32 color2; | |
| } TOOLSKIN; | |
| typedef struct { | typedef struct { |
| HWND hwnd; | UINT tctl; |
| BYTE fddaccess[2]; | const OEMCHAR *text; |
| BYTE hddaccess; | short posx; |
| BYTE _padding; | short posy; |
| int winflg; | short width; |
| int wingx; | short height; |
| int wingy; | short extend; |
| int wintx; | short padding; |
| int winty; | } SUBITEM; |
| int parentcn; | |
| int parentx; | typedef struct { |
| int parenty; | HWND hwnd; |
| HFONT hfont; | WINLOCEX wlex; |
| HDC hdcfont; | HBITMAP hbmp; |
| HBRUSH access[2]; | UINT8 fddaccess[2]; |
| HWND sub[IDC_MAXITEMS]; | UINT8 hddaccess; |
| SCPROC subproc[IDC_MAXITEMS]; | UINT8 _padding; |
| int winflg; | |
| int wingx; | |
| int wingy; | |
| int wintx; | |
| int winty; | |
| UINT parentcn; | |
| int parentx; | |
| int parenty; | |
| HFONT hfont; | |
| HDC hdcfont; | |
| HBRUSH access[2]; | |
| HWND sub[IDC_MAXITEMS]; | |
| SUBCLASSPROC subproc[IDC_MAXITEMS]; | |
| } TOOLWIN; | } TOOLWIN; |
| #define GTWLP_FOCUS (NP2GWLP_SIZE + (0 * sizeof(LONG_PTR))) | |
| #define GTWLP_SIZE (NP2GWLP_SIZE + (1 * sizeof(LONG_PTR))) | |
| NP2TOOL np2tool; | |
| static TOOLSKIN toolskin; | |
| static SUBITEM subitem[IDC_MAXITEMS]; | |
| static TOOLWIN toolwin; | static TOOLWIN toolwin; |
| #include "toolwin.res" | |
| typedef struct { | typedef struct { |
| WORD idc; | UINT16 idc; |
| BYTE *counter; | UINT8 *counter; |
| } DISKACC; | } DISKACC; |
| static const UINT8 fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const DISKACC diskacc[3] = { | static const DISKACC diskacc[3] = { |
| {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, | {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, |
| {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, | {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, |
| {IDC_TOOLHDDACC, &toolwin.hddaccess}}; | {IDC_TOOLHDDACC, &toolwin.hddaccess}}; |
| // ---- | |
| static HBITMAP skinload(const OEMCHAR *path) { | |
| OEMCHAR fname[MAX_PATH]; | |
| UINT i; | |
| HBITMAP ret; | |
| ZeroMemory(&toolskin, sizeof(toolskin)); | |
| toolskin.fontsize = 12; | |
| milstr_ncpy(toolskin.font, str_deffont, NELEMENTS(toolskin.font)); | |
| toolskin.color1 = 0x600000; | |
| toolskin.color2 = 0xff0000; | |
| if (path) { | |
| ini_read(path, skintitle, skinini1, NELEMENTS(skinini1)); | |
| } | |
| if (toolskin.main[0]) { | |
| ZeroMemory(subitem, sizeof(defsubitem)); | |
| for (i=0; i<IDC_MAXITEMS; i++) { | |
| subitem[i].tctl = defsubitem[i].tctl; | |
| subitem[i].text = defsubitem[i].text; | |
| } | |
| } | |
| else { | |
| CopyMemory(subitem, defsubitem, sizeof(defsubitem)); | |
| } | |
| if (path) { | |
| ini_read(path, skintitle, skinini2, NELEMENTS(skinini2)); | |
| } | |
| if (toolskin.main[0]) { | |
| milstr_ncpy(fname, path, NELEMENTS(fname)); | |
| file_cutname(fname); | |
| file_catname(fname, toolskin.main, NELEMENTS(fname)); | |
| #if defined(OSLANG_UTF8) | |
| TCHAR tchr[MAX_PATH]; | |
| oemtotchar(tchr, NELEMENTS(tchr), fname, -1); | |
| #else | |
| const TCHAR *tchr = fname; | |
| #endif | |
| ret = (HBITMAP)LoadImage(g_hInstance, tchr, IMAGE_BITMAP, | |
| 0, 0, LR_LOADFROMFILE); | |
| if (ret != NULL) { | |
| return(ret); | |
| } | |
| } | |
| return(LoadBitmap(g_hInstance, _T("NP2TOOL"))); | |
| } | |
| static void calctextsize(char *path, int leng, const char *p, int width) { | // ---- |
| static void calctextsize(OEMCHAR *path, int leng, const OEMCHAR *p, int width) { | |
| HDC hdc; | HDC hdc; |
| SIZE cur; | SIZE cur; |
| char work[MAX_PATH]; | OEMCHAR work[MAX_PATH]; |
| int l; | int l; |
| SIZE tail; | SIZE tail; |
| int pos; | int pos; |
| int step; | int step; |
| // NetscapeÉ÷Ì£ | |
| milstr_ncpy(path, p, leng); | milstr_ncpy(path, p, leng); |
| hdc = toolwin.hdcfont; | hdc = toolwin.hdcfont; |
| GetTextExtentPoint32(hdc, p, strlen(p), &cur); | GetTextExtentPoint32(hdc, p, OEMSTRLEN(p), &cur); |
| if (cur.cx < width) { | if (cur.cx < width) { |
| return; | return; |
| } | } |
| Line 136 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); |
| l = strlen(path); | file_cutseparator(path); |
| if (l > 1) { | l = OEMSTRLEN(path); |
| l -= 1; | work[0] = '\0'; |
| if (milstr_kanji2nd(p, l)) { | if (l) { |
| l--; | milstr_ncpy(work, str_browse, NELEMENTS(work)); |
| } | |
| } | |
| else { | |
| l = 0; | |
| } | } |
| milstr_ncpy(work, str_browse, sizeof(work)); | milstr_ncat(work, p + l, NELEMENTS(work)); |
| milstr_ncat(work, p + l, sizeof(work)); | GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); |
| GetTextExtentPoint32(hdc, work, strlen(work), &tail); | |
| pos = 0; | pos = 0; |
| while(pos < l) { | while(pos < l) { |
| step = ((((p[pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)?2:1; | #if defined(_UNICODE) |
| step = 1; | |
| #else | |
| step = (IsDBCSLeadByte((BYTE)p[pos]))?2:1; | |
| #endif | |
| GetTextExtentPoint32(hdc, p, pos + step, &cur); | GetTextExtentPoint32(hdc, p, pos + step, &cur); |
| if (cur.cx + tail.cx >= width) { | if (cur.cx + tail.cx >= width) { |
| break; | break; |
| Line 164 static void calctextsize(char *path, int | Line 207 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; | OEMCHAR basedir[MAX_PATH]; |
| TOOLFDD *fdd; | UINT i; |
| char *p; | const OEMCHAR *p; |
| UINT i; | OEMCHAR dir[MAX_PATH]; |
| char basedir[MAX_PATH]; | const OEMCHAR *q; |
| char dir[MAX_PATH]; | |
| 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]], NELEMENTS(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, NELEMENTS(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(p); |
| } | } |
| else { | else { |
| calctextsize(dir, sizeof(dir), p, width); | calctextsize(dir, NELEMENTS(dir), p, width); |
| q = dir; | q = dir; |
| } | } |
| SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); |
| p += sizeof(fdd->name[0]); | p += NELEMENTS(fdd->name[0]); |
| } | } |
| if (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 accdraw(HWND hWnd, BYTE count) { | static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { |
| OEMCHAR *p; | |
| UINT cnt; | |
| OEMCHAR *q; | |
| OEMCHAR *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 += NELEMENTS(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, UINT8 count) { | |
| HDC hdc; | HDC hdc; |
| PAINTSTRUCT ps; | PAINTSTRUCT ps; |
| Line 247 static void accdraw(HWND hWnd, BYTE coun | Line 322 static void accdraw(HWND hWnd, BYTE coun |
| static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { |
| UINT idc; | UINT idc; |
| int dir; | |
| UINT newidc; | |
| int files; | int files; |
| char fname[MAX_PATH]; | OEMCHAR 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_DROPFILES) { | if (msg == WM_KEYDOWN) { |
| if ((short)wp == VK_TAB) { | |
| dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; | |
| newidc = idc; | |
| do { | |
| newidc += dir; | |
| if (newidc >= IDC_MAXITEMS) { | |
| newidc = (dir >= 0)?0:(IDC_MAXITEMS - 1); | |
| } | |
| if ((toolwin.sub[newidc] != NULL) && | |
| (subitem[newidc].tctl != TCTL_STATIC)) { | |
| SetFocus(toolwin.sub[newidc]); | |
| break; | |
| } | |
| } while(idc != newidc); | |
| } | |
| else if ((short)wp == VK_RETURN) { | |
| if (subitem[idc].tctl == TCTL_BUTTON) { | |
| return(CallWindowProc(toolwin.subproc[idc], | |
| hWnd, WM_KEYDOWN, VK_SPACE, 0)); | |
| } | |
| } | |
| } | |
| else if (msg == WM_DROPFILES) { | |
| files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); | files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); |
| if (files == 1) { | if (files == 1) { |
| DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); | #if defined(OSLANG_UTF8) |
| TCHAR tchr[MAX_PATH]; | |
| DragQueryFile((HDROP)wp, 0, tchr, NELEMENTS(tchr)); | |
| tchartooem(fname, NELEMENTS(fname), tchr, -1); | |
| #else | |
| DragQueryFile((HDROP)wp, 0, fname, NELEMENTS(fname)); | |
| #endif | |
| if (idc == IDC_TOOLFDD1LIST) { | if (idc == IDC_TOOLFDD1LIST) { |
| diskdrv_setfdd(0, fname, 0); | diskdrv_setfdd(0, fname, 0); |
| toolwin_setfdd(0, fname); | toolwin_setfdd(0, fname); |
| Line 288 static LRESULT CALLBACK twsub(HWND hWnd, | Line 390 static LRESULT CALLBACK twsub(HWND hWnd, |
| return(FALSE); | return(FALSE); |
| } | } |
| } | } |
| else if (msg == WM_SETFOCUS) { | |
| SetWindowLongPtr(GetParent(hWnd), GTWLP_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; | |
| HINSTANCE hinstance; | |
| const SUBITEM *p; | |
| UINT i; | |
| HWND sub; | |
| toolwin.hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, | #if defined(OSLANG_UTF8) |
| TCHAR fontface[64]; | |
| oemtotchar(fontface, NELEMENTS(fontface), toolskin.font, -1); | |
| #else | |
| const TCHAR *fontface = toolskin.font; | |
| #endif | |
| toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, | |
| SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, | SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, |
| DEFAULT_QUALITY, FIXED_PITCH, str_deffont); | DEFAULT_QUALITY, FIXED_PITCH, fontface); |
| hdc = GetDC(NULL); | HDC hdc = GetDC(NULL); |
| toolwin.hdcfont = CreateCompatibleDC(hdc); | toolwin.hdcfont = CreateCompatibleDC(hdc); |
| ReleaseDC(NULL, hdc); | ReleaseDC(NULL, hdc); |
| SelectObject(toolwin.hdcfont, toolwin.hfont); | SelectObject(toolwin.hdcfont, toolwin.hfont); |
| Line 310 const SUBITEM *p; | Line 415 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; | const SUBITEM *p = subitem; |
| p = subitem; | UINT i; |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| sub = CreateWindowEx(p->exstyle, p->cname, p->text, | HWND sub = NULL; |
| WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, | const TCHAR *cls = NULL; |
| hWnd, (HMENU)(i + IDC_BASE), hinstance, NULL); | DWORD style; |
| 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)) { | |
| #if defined(OSLANG_UTF8) | |
| TCHAR ptext[64]; | |
| oemtotchar(ptext, NELEMENTS(ptext), p->text, -1); | |
| #else | |
| const TCHAR *ptext = p->text; | |
| #endif | |
| sub = CreateWindow(cls, ptext, WS_CHILD | WS_VISIBLE | style, | |
| p->posx, p->posy, p->width, p->height, | |
| hWnd, (HMENU)(i + IDC_BASE), g_hInstance, 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)GetWindowLongPtr(sub, |
| GWLP_WNDPROC); | |
| SetWindowLongPtr(sub, GWLP_WNDPROC, (LONG_PTR)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); | HWND 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; | |
| } | |
| } | } |
| SetWindowLongPtr(hWnd, GTWLP_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); | |
| } | } |
| static void toolwinpaint(HWND hWnd) { | static void toolwinpaint(HWND hWnd) { |
| HDC hdc; | HDC hdc; |
| PAINTSTRUCT ps; | PAINTSTRUCT ps; |
| HINSTANCE hinst; | |
| HBITMAP hbmp; | |
| 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) { |
| hbmp = LoadBitmap(hinst, "NP2TOOL"); | GetObject(toolwin.hbmp, sizeof(BITMAP), &bmp); |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | hmdc = CreateCompatibleDC(hdc); |
| hmdc = CreateCompatibleDC(hdc); | SelectObject(hmdc, toolwin.hbmp); |
| SelectObject(hmdc, 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); | } |
| DeleteObject(hbmp); | |
| EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); |
| } | } |
| static void tooldrawbutton(HWND hWnd, UINT idc, LPDRAWITEMSTRUCT lpdis) { | |
| // ---- moving | POINT pt; |
| HWND sub; | |
| enum { | RECT rect; |
| SNAPDOTPULL = 12, | HDC hdc; |
| SNAPDOTREL = 16 | HDC hmdc; |
| }; | RECT btn; |
| static void movingstart(void) { | |
| toolwin.winflg = 0; | idc -= IDC_BASE; |
| toolwin.wingx = 0; | if (idc >= IDC_MAXITEMS) { |
| toolwin.wingy = 0; | 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 movingproc(RECT *rect) { | |
| RECT workrc; | // ---- |
| RECT mainrc; | |
| int winlx, winly; | |
| BOOL connectx; | |
| BOOL connecty; | |
| int d; | |
| SystemParametersInfo(SPI_GETWORKAREA, 0, &workrc, 0); | static void setSkinMruMenu(HMENU hMenu) |
| GetWindowRect(hWndMain, &mainrc); | { |
| winlx = rect->right - rect->left; | HMENU hmenuSub; |
| winly = rect->bottom - rect->top; | const OEMCHAR *pcszBase; |
| UINT uCount; | |
| OEMCHAR *pszMru; | |
| const OEMCHAR *pcszMruList[SKINMRU_MAX]; | |
| UINT i; | |
| UINT uID[SKINMRU_MAX]; | |
| UINT j; | |
| UINT uFlag; | |
| for (i=0; i<SKINMRU_MAX; i++) | |
| { | |
| DeleteMenu(hMenu, IDM_TOOL_SKINMRU + i, MF_BYCOMMAND); | |
| } | |
| if ((winlx > (workrc.right - workrc.left)) || | if (!menu_searchmenu(hMenu, IDM_TOOL_SKINDEF, &hmenuSub, NULL)) |
| (winly > (workrc.bottom - workrc.top))) { | { |
| return; | return; |
| } | } |
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); | pcszBase = np2tool.skin; |
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); | |
| if ((toolwin.winflg & 3) && (!connectx) && (!connecty)) { | CheckMenuItem(hMenu, IDM_TOOL_SKINDEF, MFCHECK(pcszBase[0] == '\0')); |
| toolwin.winflg &= ~3; | |
| rect->left += toolwin.wingx; | for (uCount=0; uCount<SKINMRU_MAX; uCount++) |
| rect->top += toolwin.wingy; | { |
| toolwin.wingx = 0; | pszMru = np2tool.skinmru[uCount]; |
| toolwin.wingy = 0; | if (pszMru[0] == '\0') |
| { | |
| break; | |
| } | |
| pszMru = file_getname(pszMru); | |
| for (i=0; i<uCount; i++) | |
| { | |
| if (file_cmpname(pszMru, pcszMruList[uID[i]]) < 0) | |
| { | |
| break; | |
| } | |
| } | |
| for (j=uCount; j>i; j--) | |
| { | |
| uID[j] = uID[j-1]; | |
| } | |
| uID[i] = uCount; | |
| pcszMruList[uCount] = pszMru; | |
| } | } |
| if (toolwin.winflg & 1) { | for (i=0; i<uCount; i++) |
| toolwin.wingx += rect->left - toolwin.wintx; | { |
| rect->left = toolwin.wintx; | j = uID[i]; |
| uFlag = MFCHECK(!file_cmpname(pcszBase, np2tool.skinmru[j])); | |
| #if defined(OSLANG_UTF8) | |
| TCHAR szPath[MAX_PATH]; | |
| oemtotchar(szPath, NELEMENTS(szPath), pcszMruList[j], -1); | |
| #else | |
| const TCHAR *szPath = pcszMruList[j]; | |
| #endif | |
| AppendMenu(hmenuSub, MF_STRING + uFlag, IDM_TOOL_SKINMRU + j, szPath); | |
| } | } |
| else { | } |
| d = SNAPDOTPULL; | |
| do { | #if 0 |
| if (connecty) { | static HMENU createskinmenu(void) |
| d = rect->right - mainrc.left; | { |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | HMENU hMenu; |
| break; | const OEMCHAR *pcszBase; |
| } | UINT uCount; |
| d = rect->left - mainrc.right; | OEMCHAR *pszMru; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | const OEMCHAR *pcszMruList[SKINMRU_MAX]; |
| break; | UINT i; |
| } | UINT uID[SKINMRU_MAX]; |
| if ((rect->bottom == mainrc.top) || | UINT j; |
| (rect->top == mainrc.bottom)) { | UINT uFlag; |
| d = rect->left - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_TOOLWIN)); |
| break; | |
| } | pcszBase = np2tool.skin; |
| d = rect->right - mainrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | CheckMenuItem(hMenu, IDM_TOOL_SKINDEF, MFCHECK(pcszBase[0] == '\0')); |
| break; | for (uCount=0; uCount<SKINMRU_MAX; uCount++) |
| } | { |
| } | pszMru = np2tool.skinmru[uCount]; |
| if (pszMru[0] == '\0') | |
| { | |
| break; | |
| } | |
| pszMru = file_getname(pszMru); | |
| for (i=0; i<uCount; i++) | |
| { | |
| if (!file_cmpname(pszMru, pcszMruList[uID[i]])) | |
| { | |
| break; | |
| } | } |
| } while(0); | } |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | for (j=uCount; j>i; j--) |
| toolwin.winflg |= 1; | { |
| rect->left -= d; | uID[j] = uID[j-1]; |
| toolwin.wingx = d; | } |
| toolwin.wintx = rect->left; | uID[i] = uCount; |
| } | pcszMruList[uCount] = pszMru; |
| } | |
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~1; | |
| rect->left += toolwin.wingx; | |
| toolwin.wingx = 0; | |
| } | |
| if (toolwin.winflg & 2) { | |
| toolwin.wingy += rect->top - toolwin.winty; | |
| rect->top = toolwin.winty; | |
| } | } |
| else { | for (i=0; i<uCount; i++) |
| d = SNAPDOTPULL; | { |
| do { | j = uID[i]; |
| if (connectx) { | uFlag = MFCHECK(!file_cmpname(pcszBase, np2tool.skinmru[j])); |
| d = rect->bottom - mainrc.top; | #if defined(OSLANG_UTF8) |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | TCHAR szPath[MAX_PATH]; |
| break; | oemtotchar(szPath, NELEMENTS(szPath), pcszMruList[j], -1); |
| } | #else |
| d = rect->top - mainrc.bottom; | const TCHAR *szPath = pcszMruList[j]; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | #endif |
| break; | AppendMenu(hMenu, MF_STRING + uFlag, IDM_TOOL_SKINMRU + j, szPath); |
| } | } |
| if ((rect->right == mainrc.left) || | return hMenu; |
| (rect->left == mainrc.right)) { | } |
| d = rect->top - mainrc.top; | #endif |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | static void skinchange(HWND hWnd) |
| } | { |
| d = rect->bottom - mainrc.bottom; | const OEMCHAR *p; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | UINT i; |
| break; | HBITMAP hbmp; |
| } | BITMAP bmp; |
| } | WINLOCEX wlex; |
| p = np2tool.skin; | |
| if (p[0]) { | |
| for (i=0; i<(SKINMRU_MAX - 1); i++) { | |
| if (!file_cmpname(p, np2tool.skinmru[i])) { | |
| break; | |
| } | } |
| } while(0); | } |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | while(i > 0) { |
| toolwin.winflg |= 2; | CopyMemory(np2tool.skinmru[i], np2tool.skinmru[i-1], |
| rect->top -= d; | sizeof(np2tool.skinmru[0])); |
| toolwin.wingy = d; | i--; |
| toolwin.winty = rect->top; | } |
| } | file_cpyname(np2tool.skinmru[0], p, NELEMENTS(np2tool.skinmru[0])); |
| } | |
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~2; | |
| rect->top += toolwin.wingy; | |
| toolwin.wingy = 0; | |
| } | } |
| setSkinMruMenu(np2class_gethmenu(hWnd)); | |
| setSkinMruMenu(GetSystemMenu(hWnd, FALSE)); | |
| DrawMenuBar(hWnd); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| rect->right = rect->left + winlx; | wlex = np2_winlocexallwin(g_hWndMain); |
| rect->bottom = rect->top + winly; | winlocex_setholdwnd(wlex, hWnd); |
| toolwindestroy(); | |
| hbmp = skinload(np2tool.skin); | |
| if (hbmp == NULL) { | |
| SendMessage(hWnd, WM_CLOSE, 0, 0); | |
| return; | |
| } | |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| toolwin.hbmp = hbmp; | |
| winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); | |
| toolwincreate(hWnd); | |
| winlocex_move(wlex); | |
| winlocex_destroy(wlex); | |
| } | } |
| // ---- | // ---- |
| static LRESULT CALLBACK twproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static void openpopup(HWND hWnd, LPARAM lp) |
| { | |
| HMENU hMenu; | |
| POINT pt; | |
| hMenu = CreatePopupMenu(); | |
| if (!winui_en) | |
| { | |
| menu_addmenu(hMenu, 0, np2class_gethmenu(g_hWndMain), FALSE); | |
| } | |
| menu_addmenures(hMenu, -1, IDR_TOOLWIN, FALSE); | |
| menu_addmenures(hMenu, -1, IDR_CLOSE, TRUE); | |
| setSkinMruMenu(hMenu); | |
| 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 void toolwin_oncreate(HWND hWnd) | |
| { | |
| HMENU hMenu; | |
| int nCount; | |
| np2class_wmcreate(hWnd); | |
| setSkinMruMenu(np2class_gethmenu(hWnd)); | |
| hMenu = GetSystemMenu(hWnd, FALSE); | |
| nCount = menu_addmenures(hMenu, 0, IDR_TOOLWIN, FALSE); | |
| if (nCount) | |
| { | |
| InsertMenu(hMenu, nCount, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | |
| setSkinMruMenu(hMenu); | |
| } | |
| np2class_windowtype(hWnd, (np2tool.type & 1) << 1); | |
| toolwincreate(hWnd); | |
| } | |
| static LRESULT CALLBACK twproc(HWND hWnd, UINT uMsg, WPARAM wp, LPARAM lp) | |
| { | |
| BOOL r; | |
| UINT idc; | |
| WINLOCEX wlex; | |
| switch(msg) { | switch(uMsg) { |
| case WM_CREATE: | case WM_CREATE: |
| SetWindowLong(hWnd, GWL_STYLE, | toolwin_oncreate(hWnd); |
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | break; |
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | |
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | case WM_SYSCOMMAND: |
| toolwincreate(hWnd, lp); | switch(wp) { |
| case IDM_TOOL_SKINSEL: | |
| case IDM_TOOL_SKINDEF: | |
| case IDM_TOOL_SKINMRU + 0: | |
| case IDM_TOOL_SKINMRU + 1: | |
| case IDM_TOOL_SKINMRU + 2: | |
| case IDM_TOOL_SKINMRU + 3: | |
| return(SendMessage(hWnd, WM_COMMAND, wp, lp)); | |
| default: | |
| return(DefWindowProc(hWnd, uMsg, wp, lp)); | |
| } | |
| break; | break; |
| case WM_COMMAND: | case WM_COMMAND: |
| Line 518 static LRESULT CALLBACK twproc(HWND hWnd | Line 797 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(g_hWndMain, WM_COMMAND, IDM_FDD1OPEN, 0); |
| soundmng_play(); | } |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: |
| Line 535 static LRESULT CALLBACK twproc(HWND hWnd | Line 814 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(g_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(g_hWndMain, WM_COMMAND, IDM_RESET, 0); | |
| SetForegroundWindow(g_hWndMain); | |
| } | |
| break; | |
| case IDC_BASE + IDC_TOOLPOWER: | |
| if (!winui_en) { | |
| SendMessage(g_hWndMain, WM_CLOSE, 0, 0L); | |
| } | |
| break; | |
| case IDM_TOOL_SKINSEL: | |
| soundmng_disable(SNDPROC_TOOL); | |
| r = dlgs_openfile(hWnd, &fpSkin, np2tool.skin, | |
| NELEMENTS(np2tool.skin), NULL); | |
| soundmng_enable(SNDPROC_TOOL); | |
| if (r) { | |
| skinchange(hWnd); | |
| } | |
| break; | |
| case IDM_TOOL_SKINDEF: | |
| np2tool.skin[0] = '\0'; | |
| skinchange(hWnd); | |
| break; | |
| case IDM_TOOL_SKINMRU + 0: | |
| case IDM_TOOL_SKINMRU + 1: | |
| case IDM_TOOL_SKINMRU + 2: | |
| case IDM_TOOL_SKINMRU + 3: | |
| file_cpyname(np2tool.skin, | |
| np2tool.skinmru[LOWORD(wp) - IDM_TOOL_SKINMRU], | |
| NELEMENTS(np2tool.skin)); | |
| skinchange(hWnd); | |
| break; | |
| case IDM_CLOSE: | |
| SendMessage(hWnd, WM_CLOSE, 0, 0); | |
| break; | |
| default: | |
| if (!winui_en) { | |
| return(SendMessage(g_hWndMain, uMsg, wp, lp)); | |
| } | |
| break; | |
| } | } |
| break; | break; |
| case WM_KEYDOWN: // TAB¤ò²¡¤·¤¿»þ¤ËÉüµ¢ | |
| if ((short)wp == VK_TAB) { | |
| idc = (UINT)GetWindowLongPtr(hWnd, GTWLP_FOCUS); | |
| if (idc < IDC_MAXITEMS) { | |
| SetFocus(toolwin.sub[idc]); | |
| } | |
| return(0); | |
| } | |
| return(SendMessage(g_hWndMain, uMsg, wp, lp)); | |
| case WM_KEYUP: | |
| if ((short)wp == VK_TAB) { | |
| return(0); | |
| } | |
| return(SendMessage(g_hWndMain, uMsg, wp, lp)); | |
| case WM_PAINT: | case WM_PAINT: |
| toolwinpaint(hWnd); | toolwinpaint(hWnd); |
| break; | break; |
| case WM_DRAWITEM: | |
| tooldrawbutton(hWnd, (UINT)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 584 static LRESULT CALLBACK twproc(HWND hWnd | Line 934 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case WM_CLOSE: | case WM_CLOSE: |
| xmenu_settoolwin(0); | sysmenu_settoolwin(0); |
| 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; |
| TRACEOUT(("WM_DESTROY")); | |
| 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(g_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: |
| return(DefWindowProc(hWnd, msg, wp, lp)); | return(DefWindowProc(hWnd, uMsg, wp, lp)); |
| } | } |
| return(0); | return(0); |
| } | } |
| Line 608 BOOL toolwin_initapp(HINSTANCE hInstance | Line 975 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 = GTWLP_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(HINSTANCE hInstance) { |
| HBITMAP hbmp; | |
| BITMAP bmp; | |
| TCHAR szCaption[128]; | |
| HWND hWnd; | HWND hWnd; |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| return; | return; |
| } | } |
| ZeroMemory(&toolwin, sizeof(toolwin)); | ZeroMemory(&toolwin, sizeof(toolwin)); |
| hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, | hbmp = skinload(np2tool.skin); |
| np2tool.posx, np2tool.posy, 410, 52, | if (hbmp == NULL) { |
| NULL, NULL, hInst, NULL); | goto twope_err1; |
| } | |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| toolwin.hbmp = hbmp; | |
| loadstringresource(LOWORD(IDS_CAPTION_TOOL), | |
| szCaption, NELEMENTS(szCaption)); | |
| hWnd = CreateWindow(np2toolclass, szCaption, | |
| WS_SYSMENU | WS_MINIMIZEBOX, | |
| np2tool.posx, np2tool.posy, | |
| bmp.bmWidth, bmp.bmHeight, | |
| NULL, NULL, hInstance, NULL); | |
| winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); | |
| toolwin.hwnd = hWnd; | toolwin.hwnd = hWnd; |
| if (hWnd == NULL) { | if (hWnd == NULL) { |
| return; | goto twope_err2; |
| } | } |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOWNOACTIVATE); |
| SetForegroundWindow(g_hWndMain); | |
| return; | |
| twope_err2: | |
| DeleteObject(hbmp); | |
| twope_err1: | |
| sysmenu_settoolwin(0); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| return; | |
| } | } |
| void toolwin_close(void) { | void toolwin_destroy(void) { |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| TRACEOUT(("DestroyWindow(toolwin.hwnd)")); | |
| DestroyWindow(toolwin.hwnd); | DestroyWindow(toolwin.hwnd); |
| // toolwin.hwnd = NULL; | |
| } | } |
| } | } |
| void toolwin_movingstart(void) { | HWND toolwin_gethwnd(void) { |
| RECT mainrc; | |
| RECT toolrc; | |
| if (toolwin.hwnd == NULL) { | return(toolwin.hwnd); |
| 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; | |
| } | } |
| void toolwin_setfdd(BYTE drv, const char *name) { | void toolwin_setfdd(UINT8 drv, const OEMCHAR *name) { |
| TOOLFDD *fdd; | TOOLFDD *fdd; |
| char *q; | OEMCHAR *q; |
| char *p; | OEMCHAR *p; |
| UINT i; | UINT i; |
| HWND sub; | |
| if (drv >= FDDLIST_DRV) { | if (drv >= FDDLIST_DRV) { |
| return; | return; |
| Line 706 void toolwin_setfdd(BYTE drv, const char | Line 1063 void toolwin_setfdd(BYTE drv, const char |
| fdd->insert = 1; | fdd->insert = 1; |
| q = fdd->name[0]; | q = fdd->name[0]; |
| for (i=0; i<(FDDLIST_MAX - 1); i++) { | for (i=0; i<(FDDLIST_MAX - 1); i++) { |
| if (!milstr_cmp(q, name)) { | if (!file_cmpname(q, name)) { |
| break; | break; |
| } | } |
| q += sizeof(fdd->name[0]); | q += NELEMENTS(fdd->name[0]); |
| } | } |
| p = q - sizeof(fdd->name[0]); | p = q - NELEMENTS(fdd->name[0]); |
| while(i > 0) { | while(i > 0) { |
| i--; | i--; |
| CopyMemory(q, p, sizeof(fdd->name[0])); | CopyMemory(q, p, sizeof(fdd->name[0])); |
| p -= sizeof(fdd->name[0]); | p -= NELEMENTS(fdd->name[0]); |
| q -= sizeof(fdd->name[0]); | q -= NELEMENTS(fdd->name[0]); |
| } | } |
| milstr_ncpy(fdd->name[0], name, sizeof(fdd->name[0])); | file_cpyname(fdd->name[0], name, NELEMENTS(fdd->name[0])); |
| } | } |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| if (toolwin.hwnd != NULL) { | if (toolwin.hwnd != NULL) { |
| setlist(drv); | sub = toolwin.sub[fddlist[drv]]; |
| SetForegroundWindow(hWndMain); | if (sub) { |
| remakefddlist(sub, fdd); | |
| SetForegroundWindow(g_hWndMain); | |
| } | |
| } | } |
| } | } |
| static void setdiskacc(UINT num, UINT8 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 < NELEMENTS(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); |
| } | } |
| } | } |
| } | } |
| void toolwin_fddaccess(BYTE drv) { | void toolwin_fddaccess(UINT8 drv) { |
| if (drv < 2) { | if (drv < 2) { |
| setdiskacc(drv, 20); | setdiskacc(drv, 20); |
| } | } |
| } | } |
| void toolwin_hddaccess(BYTE drv) { | void toolwin_hddaccess(UINT8 drv) { |
| setdiskacc(2, 10); | setdiskacc(2, 10); |
| } | } |
| void toolwin_draw(BYTE frame) { | void toolwin_draw(UINT8 frame) { |
| const DISKACC *acc; | const DISKACC *acc; |
| const DISKACC *accterm; | const DISKACC *accterm; |
| BYTE counter; | UINT8 counter; |
| HWND sub; | |
| if (toolwin.hwnd == NULL) { | if (toolwin.hwnd == NULL) { |
| return; | return; |
| Line 771 const DISKACC *accterm; | Line 1134 const DISKACC *accterm; |
| frame = 1; | frame = 1; |
| } | } |
| acc = diskacc; | acc = diskacc; |
| accterm = acc + (sizeof(diskacc)/sizeof(DISKACC)); | accterm = acc + NELEMENTS(diskacc); |
| while(acc < accterm) { | while(acc < accterm) { |
| counter = *acc->counter; | counter = *acc->counter; |
| if (counter) { | if (counter) { |
| 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 790 const DISKACC *accterm; | Line 1156 const DISKACC *accterm; |
| // ---- | // ---- |
| static const char np2toolini[] = "np2tool.ini"; | static const OEMCHAR ini_title[] = OEMTEXT("NP2 tool"); |
| static const char ini_title[] = "NP2 tool"; | |
| static const INITBL iniitem[] = { | static const PFTBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | PFVAL("WindposX", PFTYPE_SINT32, &np2tool.posx), |
| {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, | PFVAL("WindposY", PFTYPE_SINT32, &np2tool.posy), |
| {"FD1NAME0", INITYPE_STR, np2tool.fdd[0].name[0], MAX_PATH}, | PFVAL("WindType", PFTYPE_BOOL, &np2tool.type), |
| {"FD1NAME1", INITYPE_STR, np2tool.fdd[0].name[1], MAX_PATH}, | PFSTR("SkinFile", PFTYPE_STR, np2tool.skin), |
| {"FD1NAME2", INITYPE_STR, np2tool.fdd[0].name[2], MAX_PATH}, | PFSTR("SkinMRU0", PFTYPE_STR, np2tool.skinmru[0]), |
| {"FD1NAME3", INITYPE_STR, np2tool.fdd[0].name[3], MAX_PATH}, | PFSTR("SkinMRU1", PFTYPE_STR, np2tool.skinmru[1]), |
| {"FD1NAME4", INITYPE_STR, np2tool.fdd[0].name[4], MAX_PATH}, | PFSTR("SkinMRU2", PFTYPE_STR, np2tool.skinmru[2]), |
| {"FD1NAME5", INITYPE_STR, np2tool.fdd[0].name[5], MAX_PATH}, | PFSTR("SkinMRU3", PFTYPE_STR, np2tool.skinmru[3]), |
| {"FD1NAME6", INITYPE_STR, np2tool.fdd[0].name[6], MAX_PATH}, | PFSTR("FD1NAME0", PFTYPE_STR, np2tool.fdd[0].name[0]), |
| {"FD1NAME7", INITYPE_STR, np2tool.fdd[0].name[7], MAX_PATH}, | PFSTR("FD1NAME1", PFTYPE_STR, np2tool.fdd[0].name[1]), |
| {"FD2NAME0", INITYPE_STR, np2tool.fdd[1].name[0], MAX_PATH}, | PFSTR("FD1NAME2", PFTYPE_STR, np2tool.fdd[0].name[2]), |
| {"FD2NAME1", INITYPE_STR, np2tool.fdd[1].name[1], MAX_PATH}, | PFSTR("FD1NAME3", PFTYPE_STR, np2tool.fdd[0].name[3]), |
| {"FD2NAME2", INITYPE_STR, np2tool.fdd[1].name[2], MAX_PATH}, | PFSTR("FD1NAME4", PFTYPE_STR, np2tool.fdd[0].name[4]), |
| {"FD2NAME3", INITYPE_STR, np2tool.fdd[1].name[3], MAX_PATH}, | PFSTR("FD1NAME5", PFTYPE_STR, np2tool.fdd[0].name[5]), |
| {"FD2NAME4", INITYPE_STR, np2tool.fdd[1].name[4], MAX_PATH}, | PFSTR("FD1NAME6", PFTYPE_STR, np2tool.fdd[0].name[6]), |
| {"FD2NAME5", INITYPE_STR, np2tool.fdd[1].name[5], MAX_PATH}, | PFSTR("FD1NAME7", PFTYPE_STR, np2tool.fdd[0].name[7]), |
| {"FD2NAME6", INITYPE_STR, np2tool.fdd[1].name[6], MAX_PATH}, | PFSTR("FD2NAME0", PFTYPE_STR, np2tool.fdd[1].name[0]), |
| {"FD2NAME7", INITYPE_STR, np2tool.fdd[1].name[7], MAX_PATH}}; | PFSTR("FD2NAME1", PFTYPE_STR, np2tool.fdd[1].name[1]), |
| PFSTR("FD2NAME2", PFTYPE_STR, np2tool.fdd[1].name[2]), | |
| static void getinifile(char *path, int leng) { | PFSTR("FD2NAME3", PFTYPE_STR, np2tool.fdd[1].name[3]), |
| PFSTR("FD2NAME4", PFTYPE_STR, np2tool.fdd[1].name[4]), | |
| milstr_ncpy(path, modulefile, leng); | PFSTR("FD2NAME5", PFTYPE_STR, np2tool.fdd[1].name[5]), |
| file_cutname(path); | PFSTR("FD2NAME6", PFTYPE_STR, np2tool.fdd[1].name[6]), |
| file_catname(path, np2toolini, leng); | PFSTR("FD2NAME7", PFTYPE_STR, np2tool.fdd[1].name[7])}; |
| } | |
| void toolwin_readini(void) { | void toolwin_readini(void) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| ZeroMemory(&np2tool, sizeof(np2tool)); | ZeroMemory(&np2tool, sizeof(np2tool)); |
| np2tool.posx = CW_USEDEFAULT; | np2tool.posx = CW_USEDEFAULT; |
| np2tool.posy = CW_USEDEFAULT; | np2tool.posy = CW_USEDEFAULT; |
| getinifile(path, sizeof(path)); | np2tool.type = 1; |
| ini_read(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | initgetfile(path, NELEMENTS(path)); |
| ini_read(path, ini_title, iniitem, NELEMENTS(iniitem)); | |
| } | } |
| void toolwin_writeini(void) { | void toolwin_writeini(void) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| getinifile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); |
| ini_write(path, ini_title, iniitem, sizeof(iniitem)/sizeof(INITBL)); | ini_write(path, ini_title, iniitem, NELEMENTS(iniitem)); |
| } | } |