/* Set window caption */
SetWindowText(ret, "Menu/Text");
- if (!GetNHApp()->bWindowsLocked) {
- DWORD style;
- style = GetWindowLong(ret, GWL_STYLE);
- style |= WS_CAPTION;
- SetWindowLong(ret, GWL_STYLE, style);
- SetWindowPos(ret, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
- | SWP_NOZORDER
- | SWP_FRAMECHANGED);
- }
+ mswin_apply_window_style(ret);
SetMenuType(ret, type);
return ret;
activate = TRUE;
}
- data->is_active = activate;
+ data->is_active = activate && !GetNHApp()->regNetHackMode;
/* set menu type */
SetMenuListType(hWnd, how);
ap = data->menu.gacc;
for (i = 0; i < data->menu.size; i++) {
if (data->menu.items[i].accelerator != 0) {
- next_char = (char) (data->menu.items[i].accelerator + 1);
+ if (isalpha(data->menu.items[i].accelerator)) {
+ next_char = (char)(data->menu.items[i].accelerator + 1);
+ }
} else if (NHMENU_IS_SELECTABLE(data->menu.items[i])) {
- if ((next_char >= 'a' && next_char <= 'z')
- || (next_char >= 'A' && next_char <= 'Z')) {
+ if (isalpha(next_char)) {
data->menu.items[i].accelerator = next_char;
} else {
if (next_char > 'z')
next_char = 'A';
else if (next_char > 'Z')
- break;
+ next_char = 'a';
data->menu.items[i].accelerator = next_char;
}
data->is_active = FALSE;
LayoutMenu(hWnd); // hide dialog buttons
mswin_popup_destroy(hWnd);
+
+ /* If we just used the permanent inventory window to pick something,
+ * set the menu back to its display inventory state.
+ */
+ if (flags.perm_invent && mswin_winid_from_handle(hWnd) == WIN_INVEN
+ && how != PICK_NONE) {
+ data->menu.prompt[0] = '\0';
+ SetMenuListType(hWnd, PICK_NONE);
+ for (i = 0; i < data->menu.size; i++)
+ data->menu.items[i].count = 0;
+ LayoutMenu(hWnd);
+ }
}
+
return ret_val;
}
/*-----------------------------------------------------------------------------*/
: SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
}
}
- return FALSE;
+ return FALSE;
+
+ case WM_CTLCOLORDLG:
+ return (INT_PTR)(text_bg_brush
+ ? text_bg_brush
+ : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
case WM_DESTROY:
if (data) {
if (data->type != MENU_TYPE_MENU)
break;
- if (strlen(msg_data->str) == 0)
- break;
if (data->menu.size == data->menu.allocated) {
data->menu.allocated += 10;
data->menu.items[new_item].attr = msg_data->attr;
strncpy(data->menu.items[new_item].str, msg_data->str,
NHMENU_STR_SIZE);
+ /* prevent & being interpreted as a mnemonic start */
+ strNsubst(data->menu.items[new_item].str, "&", "&&", 0);
data->menu.items[new_item].presel = msg_data->presel;
/* calculate tabstop size */
switch (how) {
case PICK_NONE:
- dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
+ dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
| LVS_SINGLESEL;
break;
case PICK_ONE:
- dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
+ dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
| LVS_SINGLESEL;
break;
case PICK_ANY:
- dwStyles = WS_VISIBLE | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VSCROLL
+ dwStyles = WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_VSCROLL
| WS_HSCROLL | LVS_REPORT | LVS_OWNERDRAWFIXED
| LVS_SINGLESEL;
break;
data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ /* We may continue getting window messages after a window's WM_DESTROY is
+ called. We need to handle the case that USERDATA has been freed. */
+ if (data == NULL)
+ return NULL;
+
if (data->type == MENU_TYPE_TEXT) {
return GetDlgItem(hWnd, IDC_MENU_TEXT);
} else {
if (iflags.use_menu_color
&& (menucolr = get_menu_coloring(item->str, &color, &attr))) {
- /* TODO: use attr too */
+ SelectObject(lpdis->hDC,
+ mswin_get_font(NHW_MENU, attr, lpdis->hDC, FALSE));
if (color != NO_COLOR)
SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
}
}
}
- if (isdigit(ch)) {
+ if (isdigit((uchar) ch)) {
int count;
i = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED);
if (i >= 0) {
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
|| is_accelerator) {
if (data->how == PICK_ANY || data->how == PICK_ONE) {
- for (i = 0; i < data->menu.size; i++) {
+ topIndex = ListView_GetTopIndex(hwndList);
+ if( topIndex < 0 || topIndex > data->menu.size ) break; // impossible?
+ int iter = topIndex;
+ do {
+ i = iter % data->menu.size;
if (data->menu.items[i].accelerator == ch) {
if (data->how == PICK_ANY) {
SelectMenuItem(
return -2;
}
}
- }
+ } while( (++iter % data->menu.size) != topIndex );
}
}
break;