Hooked up the Windows menu event system and fixed some bugs in it. Still need to define menu events in general...

This commit is contained in:
Pietro Gagliardi 2015-04-21 18:52:57 -04:00
parent dc386a599e
commit ac8e59c004
2 changed files with 15 additions and 2 deletions

View File

@ -93,7 +93,7 @@ HMENU makeMenubar(void)
// this is slow, but it will do for now
// TODO investigate faster options
static const uiMenuItem *lookupID(const uiMenu *items, UINT_PTR *cur, UINT_PTR id)
static const uiMenuItem *lookupID(const uiMenuItem *items, UINT_PTR *cur, UINT_PTR id)
{
const uiMenuItem *i;
@ -115,7 +115,7 @@ const uiMenuItem *menuIDToItem(UINT_PTR id)
cur = 100;
for (m = options.Menu; m->Name != NULL; m++) {
item = lookupID(m, &cur, id);
item = lookupID(m->Items, &cur, id);
if (item != NULL)
return item;
}

View File

@ -21,6 +21,7 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
WINDOWPOS *wp = (WINDOWPOS *) lParam;
RECT r;
HWND contenthwnd;
const uiMenuItem *item;
w = (struct window *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (w == NULL) {
@ -30,6 +31,18 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
switch (uMsg) {
case WM_COMMAND:
// not a menu
if (lParam != 0)
break;
if (HIWORD(wParam) != 0)
break;
item = menuIDToItem(LOWORD(wParam));
printf("%d", item->Type);
if (item->Type == uiMenuItemTypeCommand)
printf(" %s", item->Name);
printf("\n");
return 0;
case WM_WINDOWPOSCHANGED:
if ((wp->flags & SWP_NOSIZE) != 0)
break;