From 2a8954aef5038c578ca1b01b88c7c2a8716d4fd9 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Fri, 23 Sep 2022 17:18:52 +0800 Subject: [PATCH] separator issues. --- src/ssrWin/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ssrWin/main.c b/src/ssrWin/main.c index 176e664..961a85a 100644 --- a/src/ssrWin/main.c +++ b/src/ssrWin/main.c @@ -663,6 +663,7 @@ static void on_cmd_scan_screen_qrcode(HWND hWnd) { } static void modify_popup_menu_items(struct main_wnd_data* wnd_data, HMENU hMenu) { +#define INSERT_POSITION 10 int cur_selected; int node_count = ListView_GetItemCount(wnd_data->hListView); int menu_count = GetMenuItemCount(hMenu); @@ -673,6 +674,9 @@ static void modify_popup_menu_items(struct main_wnd_data* wnd_data, HMENU hMenu) DeleteMenu(hMenu, item_id, MF_BYCOMMAND); } } + if (GetMenuItemID(hMenu, INSERT_POSITION) == 0) { + DeleteMenu(hMenu, INSERT_POSITION, MF_BYPOSITION); + } for (index = node_count - 1; index >= 0; --index) { wchar_t *tmp; struct server_config* config; @@ -684,10 +688,14 @@ static void modify_popup_menu_items(struct main_wnd_data* wnd_data, HMENU hMenu) } name = lstrlenA(config->remarks) ? config->remarks : config->remote_host; tmp = utf8_to_wchar_string(name, &malloc); - InsertMenuW(hMenu, 10, MF_STRING | MF_BYPOSITION, (UINT)(MENU_ID_NODE_BEGINNING + index), tmp ? tmp : L""); + InsertMenuW(hMenu, INSERT_POSITION, MF_STRING | MF_BYPOSITION, (UINT)(MENU_ID_NODE_BEGINNING + index), tmp ? tmp : L""); free(tmp); } + if (node_count > 0) { + InsertMenu(hMenu, INSERT_POSITION + node_count, MF_SEPARATOR | MF_BYPOSITION, 0, NULL); + } + cur_selected = adjust_current_selected_item(wnd_data->cur_selected, node_count); set_current_selected_item(wnd_data->hMainDlg, cur_selected, TRUE);