|
|
| version 1.10, 2003/10/30 22:33:34 | version 1.15, 2003/11/11 14:50:52 |
|---|---|
| Line 2 | Line 2 |
| #include "strres.h" | #include "strres.h" |
| #include "resource.h" | #include "resource.h" |
| #include "np2.h" | #include "np2.h" |
| #include "winloc.h" | |
| #include "dosio.h" | #include "dosio.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "sysmng.h" | #include "sysmng.h" |
| #include "menu.h" | #include "menu.h" |
| #include "toolwin.h" | #include "toolwin.h" |
| #include "ini.h" | #include "ini.h" |
| #include "np2class.h" | |
| #include "dialog.h" | #include "dialog.h" |
| #include "dialogs.h" | #include "dialogs.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "diskdrv.h" | #include "diskdrv.h" |
| extern WINLOCEX np2_winlocexallwin(HWND base); | |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| IDC_TOOLFDD1ACC, | IDC_TOOLFDD1ACC, |
| Line 30 enum { | Line 35 enum { |
| IDC_BASE = 3000, | IDC_BASE = 3000, |
| IDC_SKINSEL = 3100, | IDM_SKINSEL = 3100, |
| IDC_SKINDEF = 3101, | IDM_SKINDEF = 3101, |
| IDC_SKINMRU = 3102, | IDM_SKINMRU = 3102, |
| IDC_TOOLCLOSE = IDC_SKINMRU + SKINMRU_MAX | IDM_TOOLCLOSE = IDM_SKINMRU + SKINMRU_MAX |
| }; | }; |
| enum { | enum { |
| Line 63 const char *text; | Line 68 const char *text; |
| typedef struct { | typedef struct { |
| HWND hwnd; | HWND hwnd; |
| WINLOCEX wlex; | |
| HBITMAP hbmp; | HBITMAP hbmp; |
| BYTE fddaccess[2]; | BYTE fddaccess[2]; |
| BYTE hddaccess; | BYTE hddaccess; |
| Line 83 typedef struct { | Line 89 typedef struct { |
| } TOOLWIN; | } TOOLWIN; |
| enum { | enum { |
| GTWL_FOCUS = 0, | GTWL_FOCUS = NP2GWL_SIZE + 0, |
| GTWL_SIZE = 4 | GTWL_SIZE = NP2GWL_SIZE + 4 |
| }; | }; |
| NP2TOOL np2tool; | NP2TOOL np2tool; |
| Line 174 static void calctextsize(char *path, int | Line 180 static void calctextsize(char *path, int |
| file_cutname(path); | file_cutname(path); |
| file_cutseparator(path); | file_cutseparator(path); |
| file_cutname(path); | file_cutname(path); |
| file_cutseparator(path); | |
| l = strlen(path); | l = strlen(path); |
| if (l > 1) { | work[0] = '\0'; |
| l -= 1; | if (l) { |
| if (milstr_kanji2nd(p, l - 1)) { | milstr_ncpy(work, str_browse, sizeof(work)); |
| l--; | |
| } | |
| } | } |
| else { | |
| l = 0; | |
| } | |
| milstr_ncpy(work, str_browse, sizeof(work)); | |
| milstr_ncat(work, p + l, sizeof(work)); | milstr_ncat(work, p + l, sizeof(work)); |
| GetTextExtentPoint32(hdc, work, strlen(work), &tail); | GetTextExtentPoint32(hdc, work, strlen(work), &tail); |
| pos = 0; | pos = 0; |
| Line 382 static LRESULT CALLBACK twsub(HWND hWnd, | Line 383 static LRESULT CALLBACK twsub(HWND hWnd, |
| else if (msg == WM_SETFOCUS) { | else if (msg == WM_SETFOCUS) { |
| SetWindowLong(GetParent(hWnd), GTWL_FOCUS, idc); | 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 556 const char *base; | Line 552 const char *base; |
| const char *file[SKINMRU_MAX]; | const char *file[SKINMRU_MAX]; |
| ret = CreatePopupMenu(); | ret = CreatePopupMenu(); |
| AppendMenu(ret, MF_STRING, IDC_SKINSEL, str_skinsel); | AppendMenu(ret, MF_STRING, IDM_SKINSEL, str_skinsel); |
| AppendMenu(ret, MF_SEPARATOR, 0, NULL); | AppendMenu(ret, MF_SEPARATOR, 0, NULL); |
| base = np2tool.skin; | base = np2tool.skin; |
| flag = (base[0] == '\0')?MF_CHECKED:0; | flag = (base[0] == '\0')?MF_CHECKED:0; |
| AppendMenu(ret, MF_STRING + flag, IDC_SKINDEF, str_skindef); | AppendMenu(ret, MF_STRING + flag, IDM_SKINDEF, str_skindef); |
| for (cnt=0; cnt<SKINMRU_MAX; cnt++) { | for (cnt=0; cnt<SKINMRU_MAX; cnt++) { |
| p = np2tool.skinmru[cnt]; | p = np2tool.skinmru[cnt]; |
| if (p[0] == '\0') { | if (p[0] == '\0') { |
| Line 582 const char *file[SKINMRU_MAX]; | Line 578 const char *file[SKINMRU_MAX]; |
| for (i=0; i<cnt; i++) { | for (i=0; i<cnt; i++) { |
| j = id[i]; | j = id[i]; |
| flag = (!file_cmpname(base, np2tool.skinmru[j]))?MF_CHECKED:0; | flag = (!file_cmpname(base, np2tool.skinmru[j]))?MF_CHECKED:0; |
| AppendMenu(ret, MF_STRING + flag, IDC_SKINMRU + j, file[j]); | AppendMenu(ret, MF_STRING + flag, IDM_SKINMRU + j, file[j]); |
| } | } |
| return(ret); | return(ret); |
| } | } |
| static void skinchange(HWND hWnd) { | static void skinchange(HWND hWnd) { |
| const char *p; | const char *p; |
| UINT i; | UINT i; |
| HBITMAP hbmp; | HBITMAP hbmp; |
| BITMAP bmp; | BITMAP bmp; |
| WINLOCEX wlex; | |
| p = np2tool.skin; | p = np2tool.skin; |
| if (p[0]) { | if (p[0]) { |
| Line 608 const char *p; | Line 605 const char *p; |
| } | } |
| file_cpyname(np2tool.skinmru[0], p, sizeof(np2tool.skinmru[0])); | file_cpyname(np2tool.skinmru[0], p, sizeof(np2tool.skinmru[0])); |
| } | } |
| ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | |
| (UINT)createskinmenu(), str_toolskin); | |
| ModifyMenu(GetSystemMenu(hWnd, FALSE), 0, MF_BYPOSITION | MF_POPUP, | ModifyMenu(GetSystemMenu(hWnd, FALSE), 0, MF_BYPOSITION | MF_POPUP, |
| (UINT)createskinmenu(), str_toolskin); | (UINT)createskinmenu(), str_toolskin); |
| DrawMenuBar(hWnd); | DrawMenuBar(hWnd); |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| toolwin_movingstart(); | wlex = np2_winlocexallwin(hWndMain); |
| winlocex_setholdwnd(wlex, hWnd); | |
| toolwindestroy(); | toolwindestroy(); |
| hbmp = skinload(np2tool.skin); | hbmp = skinload(np2tool.skin); |
| if (hbmp == NULL) { | if (hbmp == NULL) { |
| Line 622 const char *p; | Line 622 const char *p; |
| } | } |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | GetObject(hbmp, sizeof(BITMAP), &bmp); |
| toolwin.hbmp = hbmp; | toolwin.hbmp = hbmp; |
| MoveWindow(hWnd, np2tool.posx, np2tool.posy, | winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); |
| bmp.bmWidth, bmp.bmHeight, TRUE); | |
| toolwincreate(hWnd); | toolwincreate(hWnd); |
| toolwin_movingend(); | winlocex_move(wlex); |
| } | winlocex_destroy(wlex); |
| // ---- moving | |
| enum { | |
| SNAPDOTPULL = 12, | |
| SNAPDOTREL = 16 | |
| }; | |
| static void movingstart(void) { | |
| toolwin.winflg = 0; | |
| toolwin.wingx = 0; | |
| toolwin.wingy = 0; | |
| } | |
| static void movingproc(RECT *rect) { | |
| RECT workrc; | |
| RECT mainrc; | |
| int winlx; | |
| int winly; | |
| BOOL changes; | |
| BOOL connectx; | |
| BOOL connecty; | |
| int d; | |
| SystemParametersInfo(SPI_GETWORKAREA, 0, &workrc, 0); | |
| GetWindowRect(hWndMain, &mainrc); | |
| winlx = rect->right - rect->left; | |
| winly = rect->bottom - rect->top; | |
| if ((winlx > (workrc.right - workrc.left)) || | |
| (winly > (workrc.bottom - workrc.top))) { | |
| return; | |
| } | |
| 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; | |
| } | |
| 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 { | |
| d = rect->left - mainrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| if ((rect->bottom == mainrc.top) || | |
| (rect->top == mainrc.bottom)) { | |
| d = rect->left - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - mainrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } | |
| } 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; | |
| } | |
| d = rect->right - workrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| toolwin.winflg |= 0x02; | |
| rect->left -= d; | |
| rect->right = rect->left + winlx; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| changes = TRUE; | |
| } | |
| } | |
| if ((!(toolwin.winflg & 0x04)) && | |
| (rect->right >= mainrc.left) && (rect->left <= mainrc.right)) { | |
| do { | |
| 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.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; | |
| } | |
| d = rect->bottom - workrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| toolwin.winflg |= 0x08; | |
| rect->top -= d; | |
| rect->bottom = rect->top + winly; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| changes = TRUE; | |
| } | |
| } | |
| } while(changes); | |
| } | } |
| Line 818 static void movingproc(RECT *rect) { | Line 634 static void movingproc(RECT *rect) { |
| static void openpopup(HWND hWnd, LPARAM lp) { | static void openpopup(HWND hWnd, LPARAM lp) { |
| HMENU hMenu; | HMENU hMenu; |
| HMENU mainmenu; | |
| POINT pt; | POINT pt; |
| hMenu = CreatePopupMenu(); | hMenu = CreatePopupMenu(); |
| if (!winui_en) { | |
| mainmenu = np2class_gethmenu(hWndMain); | |
| menu_addmenubar(hMenu, mainmenu); | |
| } | |
| AppendMenu(hMenu, MF_POPUP, (UINT)createskinmenu(), str_toolskin); | AppendMenu(hMenu, MF_POPUP, (UINT)createskinmenu(), str_toolskin); |
| AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); | AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); |
| AppendMenu(hMenu, MF_STRING, IDC_TOOLCLOSE, str_toolclose); | AppendMenu(hMenu, MF_STRING, IDM_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; | HMENU hMenu; |
| BOOL r; | BOOL r; |
| UINT idc; | UINT idc; |
| WINLOCEX wlex; | |
| switch(msg) { | switch(msg) { |
| case WM_CREATE: | case WM_CREATE: |
| np2class_wmcreate(hWnd); | |
| ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | |
| (UINT)createskinmenu(), str_toolskin); | |
| hMenu = GetSystemMenu(hWnd, FALSE); | hMenu = GetSystemMenu(hWnd, FALSE); |
| InsertMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, | InsertMenu(hMenu, 0, MF_BYPOSITION | MF_POPUP, |
| (UINT)createskinmenu(), str_toolskin); | (UINT)createskinmenu(), str_toolskin); |
| InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); |
| SetWindowLong(hWnd, GWL_STYLE, | np2class_windowtype(hWnd, (np2tool.type & 1) << 1); |
| GetWindowLong(hWnd, GWL_STYLE) & (~WS_CAPTION)); | |
| SetWindowPos(hWnd, 0, 0, 0, 0, 0, | |
| SWP_DRAWFRAME | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); | |
| toolwincreate(hWnd); | toolwincreate(hWnd); |
| break; | break; |
| case WM_SYSCOMMAND: | case WM_SYSCOMMAND: |
| switch(wp) { | switch(wp) { |
| case IDC_SKINSEL: | case IDM_SKINSEL: |
| case IDC_SKINDEF: | case IDM_SKINDEF: |
| case IDC_SKINMRU + 0: | case IDM_SKINMRU + 0: |
| case IDC_SKINMRU + 1: | case IDM_SKINMRU + 1: |
| case IDC_SKINMRU + 2: | case IDM_SKINMRU + 2: |
| case IDC_SKINMRU + 3: | case IDM_SKINMRU + 3: |
| return(SendMessage(hWnd, WM_COMMAND, wp, lp)); | return(SendMessage(hWnd, WM_COMMAND, wp, lp)); |
| default: | default: |
| Line 876 static LRESULT CALLBACK twproc(HWND hWnd | Line 697 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1BROWSE: | case IDC_BASE + IDC_TOOLFDD1BROWSE: |
| soundmng_disable(SNDPROC_TOOL); | if (!winui_en) { |
| dialog_changefdd(hWnd, 0); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD1OPEN, 0); |
| soundmng_enable(SNDPROC_TOOL); | } |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD1EJECT: | case IDC_BASE + IDC_TOOLFDD1EJECT: |
| Line 893 static LRESULT CALLBACK twproc(HWND hWnd | Line 714 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2BROWSE: | case IDC_BASE + IDC_TOOLFDD2BROWSE: |
| soundmng_disable(SNDPROC_TOOL); | if (!winui_en) { |
| dialog_changefdd(hWnd, 1); | SendMessage(hWndMain, WM_COMMAND, IDM_FDD2OPEN, 0); |
| soundmng_enable(SNDPROC_TOOL); | } |
| break; | break; |
| case IDC_BASE + IDC_TOOLFDD2EJECT: | case IDC_BASE + IDC_TOOLFDD2EJECT: |
| Line 904 static LRESULT CALLBACK twproc(HWND hWnd | Line 725 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case IDC_BASE + IDC_TOOLRESET: | case IDC_BASE + IDC_TOOLRESET: |
| SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); | if (!winui_en) { |
| SetForegroundWindow(hWndMain); | SendMessage(hWndMain, WM_COMMAND, IDM_RESET, 0); |
| SetForegroundWindow(hWndMain); | |
| } | |
| break; | break; |
| case IDC_BASE + IDC_TOOLPOWER: | case IDC_BASE + IDC_TOOLPOWER: |
| SendMessage(hWndMain, WM_CLOSE, 0, 0L); | if (!winui_en) { |
| SendMessage(hWndMain, WM_CLOSE, 0, 0L); | |
| } | |
| break; | break; |
| case IDC_SKINSEL: | case IDM_SKINSEL: |
| soundmng_disable(SNDPROC_TOOL); | soundmng_disable(SNDPROC_TOOL); |
| r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, | r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, |
| sizeof(np2tool.skin), NULL); | sizeof(np2tool.skin), NULL); |
| Line 922 static LRESULT CALLBACK twproc(HWND hWnd | Line 747 static LRESULT CALLBACK twproc(HWND hWnd |
| } | } |
| break; | break; |
| case IDC_SKINDEF: | case IDM_SKINDEF: |
| np2tool.skin[0] = '\0'; | np2tool.skin[0] = '\0'; |
| skinchange(hWnd); | skinchange(hWnd); |
| break; | break; |
| case IDC_SKINMRU + 0: | case IDM_SKINMRU + 0: |
| case IDC_SKINMRU + 1: | case IDM_SKINMRU + 1: |
| case IDC_SKINMRU + 2: | case IDM_SKINMRU + 2: |
| case IDC_SKINMRU + 3: | case IDM_SKINMRU + 3: |
| file_cpyname(np2tool.skin, | file_cpyname(np2tool.skin, |
| np2tool.skinmru[LOWORD(wp) - IDC_SKINMRU], | np2tool.skinmru[LOWORD(wp) - IDM_SKINMRU], |
| sizeof(np2tool.skin)); | sizeof(np2tool.skin)); |
| skinchange(hWnd); | skinchange(hWnd); |
| break; | break; |
| case IDC_TOOLCLOSE: | case IDM_TOOLCLOSE: |
| SendMessage(hWnd, WM_CLOSE, 0, 0); | SendMessage(hWnd, WM_CLOSE, 0, 0); |
| break; | break; |
| default: | |
| if (!winui_en) { | |
| return(SendMessage(hWndMain, msg, wp, lp)); | |
| } | |
| break; | |
| } | } |
| break; | break; |
| Line 951 static LRESULT CALLBACK twproc(HWND hWnd | Line 782 static LRESULT CALLBACK twproc(HWND hWnd |
| } | } |
| return(0); | return(0); |
| } | } |
| break; | return(SendMessage(hWndMain, msg, wp, lp)); |
| case WM_SYSKEYDOWN: // ALT+SPACEを自前処理 | case WM_KEYUP: |
| if (((short)wp == VK_SPACE) && (lp & 0x20000000)) { | if ((short)wp == VK_TAB) { |
| POINT pt; | return(0); |
| pt.x = 0; | |
| pt.y = 0; | |
| ClientToScreen(hWnd, &pt); | |
| return(SendMessage(hWnd, 0x313, 0, MAKELPARAM(pt.x, pt.y))); | |
| } | } |
| break; | return(SendMessage(hWndMain, msg, wp, lp)); |
| case WM_PAINT: | case WM_PAINT: |
| toolwinpaint(hWnd); | toolwinpaint(hWnd); |
| Line 981 static LRESULT CALLBACK twproc(HWND hWnd | Line 808 static LRESULT CALLBACK twproc(HWND hWnd |
| case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: |
| soundmng_disable(SNDPROC_TOOL); | soundmng_disable(SNDPROC_TOOL); |
| movingstart(); | winlocex_destroy(toolwin.wlex); |
| toolwin.wlex = np2_winlocexallwin(hWnd); | |
| break; | break; |
| case WM_EXITSIZEMOVE: | case WM_MOVING: |
| soundmng_enable(SNDPROC_TOOL); | 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 1004 static LRESULT CALLBACK twproc(HWND hWnd | Line 834 static LRESULT CALLBACK twproc(HWND hWnd |
| break; | break; |
| case WM_CLOSE: | case WM_CLOSE: |
| xmenu_settoolwin(0); | sysmenu_settoolwin(0); |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| DestroyWindow(hWnd); | DestroyWindow(hWnd); |
| break; | break; |
| case WM_DESTROY: | case WM_DESTROY: |
| np2class_wmdestroy(hWnd); | |
| toolwindestroy(); | toolwindestroy(); |
| toolwin.hwnd = NULL; | toolwin.hwnd = NULL; |
| break; | break; |
| case WM_LBUTTONDOWN: | case WM_LBUTTONDOWN: |
| SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L); | if (np2tool.type & 1) { |
| return(SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L)); | |
| } | |
| break; | break; |
| case WM_RBUTTONDOWN: | case WM_RBUTTONDOWN: |
| openpopup(hWnd, lp); | openpopup(hWnd, lp); |
| break; | break; |
| case WM_LBUTTONDBLCLK: | |
| np2tool.type ^= 1; | |
| wlex = np2_winlocexallwin(hWndMain); | |
| winlocex_setholdwnd(wlex, hWnd); | |
| np2class_windowtype(hWnd, (np2tool.type & 1) << 1); | |
| winlocex_move(wlex); | |
| winlocex_destroy(wlex); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| break; | |
| default: | default: |
| return(DefWindowProc(hWnd, msg, wp, lp)); | return(DefWindowProc(hWnd, msg, wp, lp)); |
| } | } |
| Line 1032 BOOL toolwin_initapp(HINSTANCE hInstance | Line 875 BOOL toolwin_initapp(HINSTANCE hInstance |
| WNDCLASS wc; | WNDCLASS wc; |
| wc.style = CS_HREDRAW | CS_VREDRAW; | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; |
| wc.lpfnWndProc = twproc; | wc.lpfnWndProc = twproc; |
| wc.cbClsExtra = 0; | wc.cbClsExtra = 0; |
| wc.cbWndExtra = GTWL_SIZE; | wc.cbWndExtra = GTWL_SIZE; |
| Line 1040 BOOL toolwin_initapp(HINSTANCE hInstance | Line 883 BOOL toolwin_initapp(HINSTANCE hInstance |
| wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); |
| wc.hCursor = LoadCursor(NULL, IDC_ARROW); | wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
| wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); |
| wc.lpszMenuName = NULL; | wc.lpszMenuName = MAKEINTRESOURCE(IDR_TOOLWIN); |
| wc.lpszClassName = np2toolclass; | wc.lpszClassName = np2toolclass; |
| return(RegisterClass(&wc)); | return(RegisterClass(&wc)); |
| } | } |
| void toolwin_open(void) { | void toolwin_create(void) { |
| HBITMAP hbmp; | HBITMAP hbmp; |
| BITMAP bmp; | BITMAP bmp; |
| Line 1061 void toolwin_open(void) { | Line 904 void toolwin_open(void) { |
| } | } |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | GetObject(hbmp, sizeof(BITMAP), &bmp); |
| toolwin.hbmp = hbmp; | toolwin.hbmp = hbmp; |
| hWnd = CreateWindow(np2toolclass, np2tooltitle, WS_SYSMENU, | hWnd = CreateWindow(np2toolclass, np2tooltitle, |
| WS_SYSMENU | WS_MINIMIZEBOX, | |
| np2tool.posx, np2tool.posy, | np2tool.posx, np2tool.posy, |
| bmp.bmWidth, bmp.bmHeight, | bmp.bmWidth, bmp.bmHeight, |
| NULL, NULL, hInst, NULL); | NULL, NULL, hInst, NULL); |
| winloc_setclientsize(hWnd, bmp.bmWidth, bmp.bmHeight); | |
| toolwin.hwnd = hWnd; | toolwin.hwnd = hWnd; |
| if (hWnd == NULL) { | if (hWnd == NULL) { |
| goto twope_err2; | goto twope_err2; |
| } | } |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOWNOACTIVATE); |
| SetForegroundWindow(hWndMain); | SetForegroundWindow(hWndMain); |
| return; | return; |
| Line 1078 twope_err2: | Line 923 twope_err2: |
| DeleteObject(hbmp); | DeleteObject(hbmp); |
| twope_err1: | twope_err1: |
| xmenu_settoolwin(0); | sysmenu_settoolwin(0); |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| return; | return; |
| } | } |
| void toolwin_close(void) { | void toolwin_destroy(void) { |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| DestroyWindow(toolwin.hwnd); | DestroyWindow(toolwin.hwnd); |
| } | } |
| } | } |
| void toolwin_movingstart(void) { | HWND toolwin_gethwnd(void) { |
| RECT mainrc; | return(toolwin.hwnd); |
| RECT toolrc; | |
| UINT connect; | |
| if (toolwin.hwnd == NULL) { | |
| return; | |
| } | |
| GetWindowRect(hWndMain, &mainrc); | |
| GetWindowRect(toolwin.hwnd, &toolrc); | |
| connect = 0; | |
| if ((toolrc.bottom >= mainrc.top) && (toolrc.top <= mainrc.bottom)) { | |
| if (toolrc.right == mainrc.left) { | |
| connect += 0x01; | |
| } | |
| else if (toolrc.left == mainrc.right) { | |
| connect += 0x02; | |
| } | |
| else if (toolrc.left == mainrc.left) { | |
| connect += 0x03; | |
| } | |
| else if (toolrc.right == mainrc.right) { | |
| connect += 0x04; | |
| } | |
| } | |
| if ((toolrc.right >= mainrc.left) && (toolrc.left <= mainrc.right)) { | |
| if (toolrc.bottom == mainrc.top) { | |
| connect += 1 << 4; | |
| } | |
| else if (toolrc.top == mainrc.bottom) { | |
| connect += 2 << 4; | |
| } | |
| else if (toolrc.top == mainrc.top) { | |
| connect += 3 << 4; | |
| } | |
| else if (toolrc.bottom == mainrc.bottom) { | |
| connect += 4 << 4; | |
| } | |
| } | |
| toolwin.parentcn = connect; | |
| toolwin.parentx = mainrc.left; | |
| toolwin.parenty = mainrc.top; | |
| } | |
| void toolwin_movingend(void) { | |
| UINT connect; | |
| RECT mainrc; | |
| RECT toolrc; | |
| int cx; | |
| int cy; | |
| connect = toolwin.parentcn; | |
| toolwin.parentcn = 0; | |
| if ((toolwin.hwnd == NULL) || (!connect)) { | |
| return; | |
| } | |
| GetWindowRect(hWndMain, &mainrc); | |
| GetWindowRect(toolwin.hwnd, &toolrc); | |
| cx = toolrc.right - toolrc.left; | |
| cy = toolrc.bottom - toolrc.top; | |
| toolrc.left += mainrc.left - toolwin.parentx; | |
| toolrc.top += mainrc.top - toolwin.parenty; | |
| switch(connect & 0x0f) { | |
| case 1: | |
| toolrc.left = mainrc.left - cx; | |
| break; | |
| case 2: | |
| toolrc.left = mainrc.right; | |
| break; | |
| case 3: | |
| toolrc.left = mainrc.left; | |
| break; | |
| case 4: | |
| toolrc.left = mainrc.right - cx; | |
| break; | |
| } | |
| switch((connect >> 4) & 0x0f) { | |
| case 1: | |
| toolrc.top = mainrc.top - cy; | |
| break; | |
| case 2: | |
| toolrc.top = mainrc.bottom; | |
| break; | |
| case 3: | |
| toolrc.top = mainrc.top; | |
| break; | |
| case 4: | |
| toolrc.top = mainrc.bottom - cy; | |
| break; | |
| } | |
| MoveWindow(toolwin.hwnd, toolrc.left, toolrc.top, cx, cy, TRUE); | |
| } | } |
| void toolwin_setfdd(BYTE drv, const char *name) { | void toolwin_setfdd(BYTE drv, const char *name) { |
| Line 1308 static const char ini_title[] = "NP2 too | Line 1057 static const char ini_title[] = "NP2 too |
| static const INITBL iniitem[] = { | static const INITBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, |
| {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, | {"WindposY", INITYPE_SINT32, &np2tool.posy, 0}, |
| {"WindType", INITYPE_BOOL, &np2tool.type, 0}, | |
| {"SkinFile", INITYPE_STR, np2tool.skin, MAX_PATH}, | {"SkinFile", INITYPE_STR, np2tool.skin, MAX_PATH}, |
| {"SkinMRU0", INITYPE_STR, np2tool.skinmru[0], MAX_PATH}, | {"SkinMRU0", INITYPE_STR, np2tool.skinmru[0], MAX_PATH}, |
| {"SkinMRU1", INITYPE_STR, np2tool.skinmru[1], MAX_PATH}, | {"SkinMRU1", INITYPE_STR, np2tool.skinmru[1], MAX_PATH}, |
| Line 1337 void toolwin_readini(void) { | Line 1087 void toolwin_readini(void) { |
| ZeroMemory(&np2tool, sizeof(np2tool)); | ZeroMemory(&np2tool, sizeof(np2tool)); |
| np2tool.posx = CW_USEDEFAULT; | np2tool.posx = CW_USEDEFAULT; |
| np2tool.posy = CW_USEDEFAULT; | np2tool.posy = CW_USEDEFAULT; |
| np2tool.type = 1; | |
| initgetfile(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)); |
| } | } |