--- np2/win9x/np2.cpp 2003/10/26 11:51:46 1.12 +++ np2/win9x/np2.cpp 2003/10/29 21:35:58 1.16 @@ -24,6 +24,7 @@ #include "sstp.h" #include "sstpmsg.h" #include "dclock.h" +#include "toolwin.h" #ifdef USE_ROMEO #include "juliet.h" #endif @@ -69,7 +70,7 @@ static char szClassName[] = "NP2-MainWi {0, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 {0, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 0xffffff, 0xffbf6a, 0, 0, - 0, 1, 0, 9801, 0, 0, 0, 0, 0}; // ver0.38 + 0, 1, 0, 9801, 0, 0, 0, 0, 0, 0}; // ver0.38 char fddfolder[MAX_PATH]; char hddfolder[MAX_PATH]; @@ -90,28 +91,6 @@ static const char np2help[] = "np2.hlp"; static const char np2resume[] = "sav"; -typedef struct { -const char *str; - int id; -} SYSMENU_ITEM; - -static SYSMENU_ITEM smenu_item[] = { - {"&Centering", IDM_SCREENCENTER}, - {"&Window Snap", IDM_SNAPENABLE}, - {"&Background", IDM_BACKGROUND}, - {"Background &Sound", IDM_BGSOUND}, - {"&Key display", IDM_KEYDISP}, - {NULL, 0}, - {" 320x200", IDM_SCRNMUL4}, - {" 480x300", IDM_SCRNMUL6}, - {" 640x400", IDM_SCRNMUL8}, - {" 800x500", IDM_SCRNMUL10}, - {" 960x600", IDM_SCRNMUL12}, - {"1280x800", IDM_SCRNMUL16}, - {NULL, 0}, - }; - - static BYTE scrnmode; static void changescreen(BYTE newmode) { @@ -128,6 +107,12 @@ static void changescreen(BYTE newmode) { renewal |= (change & SCRNMODE_ROTATEMASK); } if (renewal) { + if (renewal & SCRNMODE_FULLSCREEN) { + toolwin_close(); + } + else if (renewal & SCRNMODE_ROTATEMASK) { + toolwin_movingstart(); + } soundmng_stop(); mouse_running(MOUSE_STOP); keydisp_destroy(); @@ -142,6 +127,13 @@ static void changescreen(BYTE newmode) { } } scrndraw_redraw(); + if ((renewal & SCRNMODE_FULLSCREEN) && + (!scrnmng_isfullscreen()) && (np2oscfg.toolwin)) { + toolwin_open(); + } + else if (renewal & SCRNMODE_ROTATEMASK) { + toolwin_movingend(); + } mouse_running(MOUSE_CONT); soundmng_play(); } @@ -252,6 +244,8 @@ static int flagload(const char *ext, con } if (id == IDYES) { statsave_load(path); + toolwin_setfdd(0, fdd_diskname(0)); + toolwin_setfdd(1, fdd_diskname(1)); } sysmng_workclockreset(); sysmng_updatecaption(1); @@ -289,33 +283,45 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT #ifndef __GNUC__ WINNLSEnableIME(hWnd, FALSE); #endif -// DragAcceptFiles(hWnd, TRUE); break; case WM_SYSCOMMAND: update = 0; switch(wParam) { - case IDM_SCREENCENTER: // ver0.26 + case IDM_TOOLWIN: + xmenu_settoolwin(np2oscfg.toolwin ^ 1); + if (np2oscfg.toolwin) { + toolwin_open(); + } + else { + toolwin_close(); + } + update |= SYS_UPDATEOSCFG; + break; + + case IDM_SCREENCENTER: if ((!scrnmng_isfullscreen()) && (!(GetWindowLong(hWnd, GWL_STYLE) & (WS_MAXIMIZE | WS_MINIMIZE)))) { + toolwin_movingstart(); wincentering(hWnd); + toolwin_movingend(); } break; case IDM_SNAPENABLE: xmenu_setwinsnap(np2oscfg.WINSNAP ^ 1); - update |= SYS_UPDATECFG; + update |= SYS_UPDATEOSCFG; break; case IDM_BACKGROUND: xmenu_setbackground(np2oscfg.background ^ 1); - update |= SYS_UPDATECFG; + update |= SYS_UPDATEOSCFG; break; case IDM_BGSOUND: xmenu_setbgsound(np2oscfg.background ^ 2); - update |= SYS_UPDATECFG; + update |= SYS_UPDATEOSCFG; break; case IDM_KEYDISP: @@ -404,6 +410,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case IDM_FDD1EJECT: diskdrv_setfdd(0, NULL, 0); + toolwin_setfdd(0, NULL); break; case IDM_FDD2OPEN: @@ -414,6 +421,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case IDM_FDD2EJECT: diskdrv_setfdd(1, NULL, 0); + toolwin_setfdd(1, NULL); break; case IDM_SASI1OPEN: @@ -834,31 +842,31 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case WM_PAINT: hdc = BeginPaint(hWnd, &ps); if (np2opening) { - HINSTANCE hinst; + HINSTANCE hinst; RECT rect; int width; int height; - HBITMAP hbmp; - BITMAP bmp; - HDC hmdc; + HBITMAP hbmp; + BITMAP bmp; + HDC hmdc; HBRUSH hbrush; - hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); + hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); GetClientRect(hWnd, &rect); width = rect.right - rect.left; height = rect.bottom - rect.top; - hbmp = LoadBitmap(hinst, "NP2BMP"); - GetObject(hbmp, sizeof(BITMAP), &bmp); + hbmp = LoadBitmap(hinst, "NP2BMP"); + GetObject(hbmp, sizeof(BITMAP), &bmp); hbrush = (HBRUSH)SelectObject(hdc, GetStockObject(BLACK_BRUSH)); PatBlt(hdc, 0, 0, width, height, PATCOPY); SelectObject(hdc, hbrush); - hmdc = CreateCompatibleDC(hdc); - SelectObject(hmdc, hbmp); - BitBlt(hdc, (width - bmp.bmWidth) / 2, - (height - bmp.bmHeight) / 2, + hmdc = CreateCompatibleDC(hdc); + SelectObject(hmdc, hbmp); + BitBlt(hdc, (width - bmp.bmWidth) / 2, + (height - bmp.bmHeight) / 2, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); - DeleteDC(hmdc); - DeleteObject(hbmp); + DeleteDC(hmdc); + DeleteObject(hbmp); } else { // scrnmng_update(); @@ -872,13 +880,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT break; case WM_MOVE: - if ((!scrnmng_isfullscreen()) && - (!(GetWindowLong(hWndMain, GWL_STYLE) & - (WS_MAXIMIZE | WS_MINIMIZE)))) { - GetWindowRect(hWnd, &rc); - np2oscfg.winx = rc.left; - np2oscfg.winy = rc.top; - sysmng_update(SYS_UPDATEOSCFG); + if (!scrnmng_isfullscreen()) { + if (!(GetWindowLong(hWnd, GWL_STYLE) & + (WS_MAXIMIZE | WS_MINIMIZE))) { + GetWindowRect(hWnd, &rc); + np2oscfg.winx = rc.left; + np2oscfg.winy = rc.top; + sysmng_update(SYS_UPDATEOSCFG); + } + if (GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE) { + toolwin_close(); + } + else if (np2oscfg.toolwin) { + toolwin_open(); + } } break; @@ -897,9 +912,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT soundmng_stop(); mouse_running(MOUSE_STOP); winloc_movingstart(); + toolwin_movingstart(); break; case WM_EXITSIZEMOVE: + toolwin_movingend(); mouse_running(MOUSE_CONT); soundmng_play(); break; @@ -1098,7 +1115,8 @@ static void processwait(UINT cnt) { timing_setcount(0); framecnt = 0; scrnmng_dispclock(); - keydisp_draw(np2oscfg.DRAW_SKIP); + keydisp_draw((BYTE)cnt); + toolwin_draw((BYTE)cnt); viewer_allreload(FALSE); if (np2oscfg.DISPCLK & 3) { if (sysmng_workclockrenewal()) { @@ -1128,6 +1146,7 @@ int WINAPI WinMain(HINSTANCE hInstance, file_setcd(modulefile); np2arg_analize(lpszCmdLine); initload(); + toolwin_readini(); rand_setseed((unsigned)time(NULL)); @@ -1175,6 +1194,7 @@ int WINAPI WinMain(HINSTANCE hInstance, if (!RegisterClass(&np2)) { return(FALSE); } + toolwin_initapp(hInstance); } keydisp_initialize(hPreInst); viewer_init(hPreInst); // ver0.30 @@ -1230,24 +1250,7 @@ int WINAPI WinMain(HINSTANCE hInstance, } InsertMenu(hMenu, 1, MF_BYPOSITION | MF_POPUP, (UINT)hStat, "S&tat"); } - - hMenu = GetSystemMenu(hWndMain, FALSE); // ver0.26 - for (i=0; i<(sizeof(smenu_item)/sizeof(SYSMENU_ITEM)); i++) { - if (smenu_item[i].str) { - InsertMenu(hMenu, i, MF_BYPOSITION | MF_STRING, - smenu_item[i].id, smenu_item[i].str); - } - else { - InsertMenu(hMenu, i, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - } - } - - if (np2oscfg.I286SAVE) { - InsertMenu(hMenu, 5, MF_BYPOSITION | MF_STRING, IDM_MEMORYDUMP, - "&Memory Dump"); - InsertMenu(hMenu, 6, MF_BYPOSITION | MF_STRING, IDM_DEBUGUTY, - "&Debug Utility"); - } + sysmenu_init(); DrawMenuBar(hWndMain); // ver0.30 @@ -1255,11 +1258,16 @@ int WINAPI WinMain(HINSTANCE hInstance, EnableMenuItem(GetMenu(hWndMain), IDM_HELP, MF_GRAYED); } + xmenu_settoolwin(np2oscfg.toolwin); xmenu_setwinsnap(np2oscfg.WINSNAP); xmenu_setbackground(np2oscfg.background); xmenu_setbgsound(np2oscfg.background); xmenu_setscrnmul(8); // ver0.26 + if (np2oscfg.toolwin) { + toolwin_open(); + } + scrnmode = 0; if (np2arg.fullscreen) { scrnmode |= SCRNMODE_FULLSCREEN; @@ -1432,6 +1440,7 @@ int WINAPI WinMain(HINSTANCE hInstance, DispatchMessage(&msg); } } + toolwin_close(); pccore_cfgupdate(); @@ -1461,6 +1470,7 @@ int WINAPI WinMain(HINSTANCE hInstance, if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { initsave(); + toolwin_writeini(); } TRACETERM();