34 osgViewer::Viewer::Windows windows;
35 if (!
globals->get_renderer() || !
globals->get_renderer()->getViewerBase()) {
39 globals->get_renderer()->getViewerBase()->getWindows(windows);
40 for (
auto win : windows) {
41 if (strcmp(win->className(),
"GraphicsWindowWin32")) {
45 osgViewer::GraphicsWindowWin32* platformWin =
46 static_cast<osgViewer::GraphicsWindowWin32*
>(win);
47 return platformWin->getHWND();
62 if (HIWORD(wParam) == 0) {
65 int commandId = (int)LOWORD(wParam);
66 if (commandId < menubar->getItemBindings().size()) {
67 fireBindingList(menubar->getItemBindings()[commandId]);
111 _p->menuBar = CreateMenu();
112 LONG_PTR tempWindowProc = GetWindowLongPtr(_p->mainWindow, GWLP_WNDPROC);
119 SGPropertyNode_ptr props =
fgGetNode(
"/sim/menubar/default",
true);
120 for (
auto menu : props->getChildren(
"menu")) {
123 HMENU menuItems = CreatePopupMenu();
125 if (!menu->hasValue(
"enabled")) {
126 menu->setBoolValue(
"enabled",
true);
129 bool enabled = menu->getBoolValue(
"enabled");
131 UINT flags = enabled ? MF_POPUP : MF_POPUP | MF_GRAYED;
132 const auto wlabel = simgear::strutils::convertUtf8ToWString(label);
133 AppendMenuW(_p->menuBar, flags, (UINT_PTR)menuItems, wlabel.c_str());
136 for (
auto menuItem : menu->getChildren(
"item")) {
137 if (!menuItem->hasValue(
"enabled")) {
138 menuItem->setBoolValue(
"enabled",
true);
142 std::string shortcut = menuItem->getStringValue(
"key");
144 SGBindingList bl = readBindingList(menuItem->getChildren(
"binding"),
globals->get_props());
145 UINT commandId = _p->itemBindings.size();
146 _p->itemBindings.push_back(bl);
149 AppendMenu(menuItems, MF_SEPARATOR, NULL, NULL);
151 if (!shortcut.empty()) {
152 label2 +=
"\t" + shortcut;
154 bool enabled = menuItem->getBoolValue(
"enabled");
156 UINT flags = enabled ? MF_STRING : MF_STRING | MF_GRAYED;
157 const auto wl2 = simgear::strutils::convertUtf8ToWString(label2);
158 AppendMenuW(menuItems, flags, commandId, wl2.c_str());