Ejemplo n.º 1
0
/* Set map display mode */
void
mswin_select_map_mode(int mode)
{
    HMENU hmenuMap;
    PNHMainWindow data;
    winid map_id;

    map_id = WIN_MAP;
    data = (PNHMainWindow) GetWindowLong(GetNHApp()->hMainWnd, GWL_USERDATA);
#if defined(WIN_CE_SMARTPHONE)
    /* Smartphone manu has only 2 items */
    hmenuMap = _get_main_menu(ID_VIEW);
#else
    hmenuMap = _get_main_menu(ID_MAP);
#endif

    /* override for Rogue level */
    if (Is_rogue_level(&u.uz) && !IS_MAP_ASCII(mode))
        return;

    /* set map mode menu mark */
    if (IS_MAP_ASCII(mode)) {
        CheckMenuRadioItem(hmenuMap, IDM_MAP_TILES, IDM_MAP_FIT_TO_SCREEN,
                           mapmode2menuid(IS_MAP_FIT_TO_SCREEN(mode)
                                              ? data->mapAcsiiModeSave
                                              : mode),
                           MF_BYCOMMAND);
    } else {
        CheckMenuRadioItem(hmenuMap, IDM_MAP_TILES, IDM_MAP_FIT_TO_SCREEN,
                           mapmode2menuid(MAP_MODE_TILES), MF_BYCOMMAND);
    }

#if defined(WIN_CE_SMARTPHONE)
    /* update "Fit To Screen" item text */
    {
        TCHAR wbuf[BUFSZ];
        TBBUTTONINFO tbbi;

        ZeroMemory(wbuf, sizeof(wbuf));
        if (!LoadString(GetNHApp()->hApp,
                        (IS_MAP_FIT_TO_SCREEN(mode) ? IDS_CAP_NORMALMAP
                                                    : IDS_CAP_ENTIREMAP),
                        wbuf, BUFSZ)) {
            panic("cannot load main menu strings");
        }

        ZeroMemory(&tbbi, sizeof(tbbi));
        tbbi.cbSize = sizeof(tbbi);
        tbbi.dwMask = TBIF_TEXT;
        tbbi.pszText = wbuf;
        if (!SendMessage(GetNHApp()->hMenuBar, TB_SETBUTTONINFO,
                         IDM_MAP_FIT_TO_SCREEN, (LPARAM) &tbbi)) {
            error("Cannot update IDM_MAP_FIT_TO_SCREEN menu item.");
        }
    }
#else
    /* set fit-to-screen mode mark */
    CheckMenuItem(hmenuMap, IDM_MAP_FIT_TO_SCREEN,
                  MF_BYCOMMAND | (IS_MAP_FIT_TO_SCREEN(mode) ? MF_CHECKED
                                                             : MF_UNCHECKED));
#endif

    if (IS_MAP_ASCII(iflags.wc_map_mode)
        && !IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
        data->mapAcsiiModeSave = iflags.wc_map_mode;
    }

    iflags.wc_map_mode = mode;

    /*
    ** first, check if WIN_MAP has been inialized.
    ** If not - attempt to retrieve it by type, then check it again
    */
    if (WIN_MAP != WIN_ERR)
        mswin_map_mode(mswin_hwnd_from_winid(WIN_MAP), mode);
}
Ejemplo n.º 2
0
/*
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
*/
LRESULT CALLBACK
MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PNHMainWindow data;

    switch (message) {
    /*-----------------------------------------------------------------------*/
    case WM_CREATE: {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        SHMENUBARINFO menubar;
#endif
        /* set window data */
        data = (PNHMainWindow) malloc(sizeof(NHMainWindow));
        if (!data)
            panic("out of memory");
        ZeroMemory(data, sizeof(NHMainWindow));
        data->mapAcsiiModeSave = MAP_MODE_ASCII12x16;
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) data);

        GetNHApp()->hMainWnd = hWnd;

/* create menu bar */
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        ZeroMemory(&menubar, sizeof(menubar));
        menubar.cbSize = sizeof(menubar);
        menubar.hwndParent = hWnd;
        menubar.dwFlags = 0;
        menubar.nToolBarId = IDC_WINHACK;
        menubar.hInstRes = GetNHApp()->hApp;
#if defined(WIN_CE_POCKETPC)
        menubar.nBmpId = IDB_MENUBAR;
        menubar.cBmpImages = 2;
#else
        menubar.nBmpId = 0;
        menubar.cBmpImages = 0;
#endif
        if (!SHCreateMenuBar(&menubar))
            panic("cannot create menu");
        GetNHApp()->hMenuBar = menubar.hwndMB;
#else
        GetNHApp()->hMenuBar = CommandBar_Create(GetNHApp()->hApp, hWnd, 1);
        if (!GetNHApp()->hMenuBar)
            panic("cannot create menu");
        CommandBar_InsertMenubar(GetNHApp()->hMenuBar, GetNHApp()->hApp,
                                 IDC_WINHACK, 0);
#endif
        CheckMenuItem(
            _get_main_menu(ID_VIEW), IDM_VIEW_KEYPAD,
            MF_BYCOMMAND | (GetNHApp()->bCmdPad ? MF_CHECKED : MF_UNCHECKED));

    } break;

    /*-----------------------------------------------------------------------*/

    case WM_MSNH_COMMAND:
        onMSNHCommand(hWnd, wParam, lParam);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_KEYDOWN:
        data = (PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA);

        /* translate arrow keys into nethack commands */
        switch (wParam) {
        case VK_LEFT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line left */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_W));
            }
            return 0;

        case VK_RIGHT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line right */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_E));
            }
            return 0;

        case VK_UP:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_N));
            }
            return 0;

        case VK_DOWN:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_S));
            }
            return 0;

        case VK_HOME:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to upper left corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NW));
            }
            return 0;

        case VK_END:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to lower right corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, ROWNO), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, COLNO), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SW));
            }
            return 0;

        case VK_PRIOR:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NE));
            }
            return 0;

        case VK_NEXT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SE));
            }
            return 0;

        case VK_DECIMAL:
        case VK_DELETE:
            NHEVENT_KBD(KEYTABLE(KEY_WAITLOOK));
            return 0;

        case VK_INSERT:
            NHEVENT_KBD(KEYTABLE(KEY_INV));
            return 0;

        case VK_SUBTRACT:
            NHEVENT_KBD(KEYTABLE(KEY_MINUS));
            return 0;

        case VK_ADD:
            NHEVENT_KBD(KEYTABLE(KEY_PLUS));
            return 0;

        case VK_CLEAR: /* This is the '5' key */
            NHEVENT_KBD(KEYTABLE(KEY_GOINTERESTING));
            return 0;

        case VK_F4:
            if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? data->mapAcsiiModeSave
                                          : MAP_MODE_TILES);
            } else {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? MAP_MODE_ASCII_FIT_TO_SCREEN
                                          : MAP_MODE_TILES_FIT_TO_SCREEN);
            }
            return 0;

        case VK_F5:
            if (IS_MAP_ASCII(iflags.wc_map_mode)) {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_TILES_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(MAP_MODE_TILES);
                }
            } else {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_ASCII_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(data->mapAcsiiModeSave);
                }
            }
            return 0;

        case VK_RETURN: {
            int x, y;
            if (WIN_MAP != WIN_ERR) {
                mswin_map_get_cursor(mswin_hwnd_from_winid(WIN_MAP), &x, &y);
            } else {
                x = u.ux;
                y = u.uy;
            }
            NHEVENT_MS(CLICK_1, x, y);
        }
            return 0;
        }

#if defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, TRUE))
            return 0;
#endif
        return 1; /* end of WM_KEYDOWN */

/*-----------------------------------------------------------------------*/

#if defined(WIN_CE_SMARTPHONE)
    case WM_KEYUP:
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, FALSE))
            return 0;
        return 1; /* end of WM_KEYUP */
#endif
    /*-----------------------------------------------------------------------*/

    case WM_CHAR:
#if defined(WIN_CE_SMARTPHONE)
        /* if smartphone cmdpad is up then translation happens - disable
           WM_CHAR processing
           to avoid double input */
        if (GetNHApp()->bCmdPad) {
            return 1;
        }
#endif

        if (wParam == '\n' || wParam == '\r' || wParam == C('M'))
            return 0; /* we already processed VK_RETURN */

        /* all characters go to nethack except Ctrl-P that scrolls message
         * window up */
        if (wParam == C('P') || wParam == C('p')) {
            SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_VSCROLL,
                        MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
        } else {
            NHEVENT_KBD((lParam & 1 << 29) ? M(tolower(wParam)) : wParam);
        }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_COMMAND:
        /* process commands - menu commands mostly */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            return SendMessage(GetNHApp()->hPopupWnd, message, wParam,
                               lParam);
        } else if (onWMCommand(hWnd, wParam, lParam))
            return DefWindowProc(hWnd, message, wParam, lParam);
        else
            return 0;

    /*-----------------------------------------------------------------------*/

    case WM_ACTIVATE:
        if (LOWORD(wParam) != WA_INACTIVE) {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
            if (GetNHApp()->bFullScreen)
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
            else
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
            mswin_layout_main_window(NULL);
        }
        break;

    case WM_SETTINGCHANGE:
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bFullScreen)
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
        else
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
        mswin_layout_main_window(NULL);
        break;

    case WM_SIZE:
        mswin_layout_main_window(NULL);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_SETFOCUS:
        /* if there is a menu window out there -
           transfer input focus to it */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            SetFocus(GetNHApp()->hPopupWnd);
        }
        break;

    /*-----------------------------------------------------------------------*/

    case WM_CLOSE: {
/* exit gracefully */
#ifdef SAFERHANGUP
        /* destroy popup window - it has its own loop and we need to
           return control to NetHack core at this point */
        if (IsWindow(GetNHApp()->hPopupWnd))
            SendMessage(GetNHApp()->hPopupWnd, WM_COMMAND, IDCANCEL, 0);

        /* tell NetHack core that "hangup" is requested */
        hangup(1);
#else
        dosave0();
        terminate(EXIT_SUCCESS);
#endif
    }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_DESTROY: {
        /* apparently we never get here
           TODO: work on exit routines - need to send
           WM_QUIT somehow */

        /* clean up */
        free((PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA));
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0);

        terminate(EXIT_SUCCESS);
    } break;

    /*-----------------------------------------------------------------------*/

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 3
0
LRESULT
onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PNHMainWindow data;

    data = (PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA);
    wmId = LOWORD(wParam);
    wmEvent = HIWORD(wParam);

    // process the menu selections:
    switch (wmId) {
    case IDM_ABOUT:
        DialogBox(GetNHApp()->hApp, (LPCTSTR) IDD_ABOUTBOX, hWnd,
                  (DLGPROC) About);
        break;

    case IDM_EXIT:
        done2();
        break;

    case IDM_SAVE:
        dosave();
        break;

    case IDM_MAP_TILES:
    case IDM_MAP_ASCII4X6:
    case IDM_MAP_ASCII6X8:
    case IDM_MAP_ASCII8X8:
    case IDM_MAP_ASCII16X8:
    case IDM_MAP_ASCII7X12:
    case IDM_MAP_ASCII8X12:
    case IDM_MAP_ASCII12X16:
    case IDM_MAP_ASCII16X12:
    case IDM_MAP_ASCII10X18:
        mswin_select_map_mode(menuid2mapmode(wmId));
        break;

    case IDM_MAP_FIT_TO_SCREEN:
        if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
            mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                      ? data->mapAcsiiModeSave
                                      : MAP_MODE_TILES);
        } else {
            mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                      ? MAP_MODE_ASCII_FIT_TO_SCREEN
                                      : MAP_MODE_TILES_FIT_TO_SCREEN);
        }
        break;

    case IDM_VIEW_KEYPAD:
        GetNHApp()->bCmdPad = !GetNHApp()->bCmdPad;
        CheckMenuItem(
            _get_main_menu(ID_VIEW), IDM_VIEW_KEYPAD,
            MF_BYCOMMAND | (GetNHApp()->bCmdPad ? MF_CHECKED : MF_UNCHECKED));
        mswin_layout_main_window(GetNHApp()->hCmdWnd);
        break;

    case IDM_VIEW_OPTIONS:
        doset();
        break;

    case IDM_DIRECT_COMMAND: /* SmartPhone: display dialog to type in arbitary
                                command text */
        mswin_direct_command();
        break;

    case IDM_HELP_LONG:
        display_file(HELP, TRUE);
        break;

    case IDM_HELP_COMMANDS:
        display_file(SHELP, TRUE);
        break;

    case IDM_HELP_HISTORY:
        (void) dohistory();
        break;

    case IDM_HELP_INFO_CHAR:
        (void) dowhatis();
        break;

    case IDM_HELP_INFO_KEY:
        (void) dowhatdoes();
        break;

    case IDM_HELP_OPTIONS:
        option_help();
        break;

    case IDM_HELP_OPTIONS_LONG:
        display_file(OPTIONFILE, TRUE);
        break;

    case IDM_HELP_EXTCMD:
        (void) doextlist();
        break;

    case IDM_HELP_LICENSE:
        display_file(LICENSE, TRUE);
        break;

    case IDM_HELP_MENU:
        dohelp();
        break;

    default:
        return 1;
    }
    return 0;
}
Ejemplo n.º 4
0
/*
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
*/
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PNHMainWindow data;

	switch (message) 
	{
		case WM_CREATE:
			/* set window data */
			data = (PNHMainWindow)malloc(sizeof(NHMainWindow));
			if( !data ) panic("out of memory");
			ZeroMemory(data, sizeof(NHMainWindow));
			data->mapAcsiiModeSave = MAP_MODE_ASCII12x16;
			SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);

			GetNHApp()->hMainWnd = hWnd;
		break;

		case WM_MSNH_COMMAND:
			onMSNHCommand(hWnd, wParam, lParam);
		break;

        case WM_KEYDOWN: 
		{
			data = (PNHMainWindow)GetWindowLong(hWnd, GWL_USERDATA);

			/* translate arrow keys into nethack commands */
            switch (wParam) 
            { 
			case VK_LEFT:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one line left */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_HSCROLL,
						MAKEWPARAM(SB_LINEUP, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_W));
				}
			return 0;

			case VK_RIGHT:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one line right */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_HSCROLL,
						MAKEWPARAM(SB_LINEDOWN, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_E));
				}
			return 0;

			case VK_UP:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one line up */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_LINEUP, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_N));
				}
			return 0;

			case VK_DOWN:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one line down */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_LINEDOWN, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_S));
				}
			return 0;

			case VK_HOME:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window to upper left corner */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_THUMBTRACK, 0),
						(LPARAM)NULL
					);

					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_HSCROLL,
						MAKEWPARAM(SB_THUMBTRACK, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_NW));
				}
			return 0;

			case VK_END:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window to lower right corner */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_THUMBTRACK, ROWNO),
						(LPARAM)NULL
					);

					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_HSCROLL,
						MAKEWPARAM(SB_THUMBTRACK, COLNO),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_SW));
				}
			return 0;

			case VK_PRIOR:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one page up */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_PAGEUP, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_NE));
				}
			return 0;

			case VK_NEXT:
				if( STATEON(VK_CONTROL) ) {
					/* scroll map window one page down */
					SendMessage(
						mswin_hwnd_from_winid(WIN_MAP),
						WM_VSCROLL,
						MAKEWPARAM(SB_PAGEDOWN, 0),
						(LPARAM)NULL
					);
				} else {
					NHEVENT_KBD(KEYTABLE(KEY_SE));
				}
			return 0;

			case VK_DECIMAL:
			case VK_DELETE:
				NHEVENT_KBD(KEYTABLE(KEY_WAITLOOK));
			return 0;

			case VK_INSERT:
				NHEVENT_KBD(KEYTABLE(KEY_INV));
			return 0;

			case VK_SUBTRACT:
				NHEVENT_KBD(KEYTABLE(KEY_MINUS));
			return 0;

			case VK_ADD:
				NHEVENT_KBD(KEYTABLE(KEY_PLUS));
			return 0;

			case VK_CLEAR: /* This is the '5' key */
				NHEVENT_KBD(KEYTABLE(KEY_GOINTERESTING));
			return 0;

			case VK_F4:
				if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
					mswin_select_map_mode(
						IS_MAP_ASCII(iflags.wc_map_mode)? 
							data->mapAcsiiModeSave :
							MAP_MODE_TILES
					);
				} else {
					mswin_select_map_mode(
						IS_MAP_ASCII(iflags.wc_map_mode)?
							MAP_MODE_ASCII_FIT_TO_SCREEN :
							MAP_MODE_TILES_FIT_TO_SCREEN
					);
				}
			return 0;

			case VK_F5:
				if( IS_MAP_ASCII(iflags.wc_map_mode) ) {
					if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
						mswin_select_map_mode(MAP_MODE_TILES_FIT_TO_SCREEN);
					} else {
						mswin_select_map_mode(MAP_MODE_TILES);
					}
				} else {
					if( IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode) ) {
						mswin_select_map_mode(MAP_MODE_ASCII_FIT_TO_SCREEN);
					} else {
						mswin_select_map_mode(data->mapAcsiiModeSave);
					}
				}
			return 0;

			default: {
				WORD c;
				BYTE kbd_state[256];

				c = 0;
				ZeroMemory(kbd_state, sizeof(kbd_state));
				GetKeyboardState(kbd_state);

				if( ToAscii( wParam, (lParam>>16)&0xFF, kbd_state, &c, 0) ) {
					NHEVENT_KBD( c&0xFF );
					return 0;
				} else {
					return 1;
				}
			}

			} /* end switch */
		} break;

        case WM_SYSCHAR: /* Alt-char pressed */
        {
            /*
              If not nethackmode, don't handle Alt-keys here.
              If no Alt-key pressed it can never be an extended command 
            */
	    if (GetNHApp()->regNetHackMode && ((lParam & 1<<29) != 0))
            {
                unsigned char c = (unsigned char)(wParam & 0xFF);
		unsigned char scancode = (lParam >> 16) & 0xFF;
                if (index(extendedlist, tolower(c)) != 0)
		{
		    NHEVENT_KBD(M(tolower(c)));
		} else if (scancode == (SCANLO + SIZE(scanmap)) - 1) {
		    NHEVENT_KBD(M('?'));
		}
		return 0;
            }
            return DefWindowProc(hWnd, message, wParam, lParam);
        }