在多列中显示菜单项

Displaying menu items in multiple columns

我正在尝试改进我正在开发的 Train Conductor 游戏的用户界面。

我正在做的其中一件事是在弹出菜单中显示车辆列表。我想使用多列而不是单个长列。

单击鼠标右键时弹出菜单的车辆列表。

我不确定如何处理这个问题,我确定答案很简单,只是我没有看到。

现在看起来如何

我希望它看起来如何

以下是将列表附加到菜单部分的代码片段:

Guide::GetTrainList(&TrainList); //this receives the list of the trains

if(TrainList.size() > 0) //this will tell the code to continue if the trains exist (decided by the player which trains to play with)
{
    for(int j = 0; j < TrainList.size(); j++)
    {
        CString FollowTrain = TrainList[j]->GetMenuName();
        FollowTrain.Append((m_FollowTrain != NULL && m_FollowTrain == TrainList[j])?L" (Followed)":L"");
        GoToTrainMenu.AppendMenu(MF_STRING, Counter++, TrainList[j]->GetMenuName());
        FollowTrainMenu.AppendMenu(MF_STRING, Counter++, FollowTrain);
        MoveTrainMenu.AppendMenu(MF_STRING, Counter++, TrainList[j]->GetMenuName());
    }

    PopupMenu.AppendMenu(MF_POPUP, (unsigned int)GoToTrainMenu.Detach(), GetStringFromResource(GOTOTRAIN));
    PopupMenu.AppendMenu(MF_POPUP, (unsigned int)FollowTrainMenu.Detach(), GetStringFromResource(FOLLOWTRAIN));
    PopupMenu.AppendMenu(MF_POPUP, (unsigned int)MoveTrainMenu.Detach(), GetStringFromResource(MOVETRAIN));
}

MF_MENUBARBREAKMF_MENUBREAK 添加到标志以创建菜单列:

HMENU hMenu = CreatePopupMenu();
AppendMenuA(hMenu, MF_STRING, 1, "Foo");
AppendMenuA(hMenu, MF_STRING|MF_MENUBREAK, 2, "Bar");
AppendMenuA(hMenu, MF_STRING, 3, "Baz");
AppendMenuA(hMenu, MF_STRING, 4, "A");
AppendMenuA(hMenu, MF_STRING|MF_MENUBARBREAK, 5, "B");
AppendMenuA(hMenu, MF_STRING, 6, "C");
UINT cmd = TrackPopupMenuEx(hMenu, TPM_RETURNCMD|TPM_RIGHTBUTTON, pt.x, pt.y, hWnd, NULL);