1. Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 22, 2014
- 1783 views
So, I've got a basic window programmed and all seems well so far, except that I none of my menu items are clickable until I press the 'Alt' key. All items on the sub-menus are clickable once they drop down, however, after that I have to press 'Alt' again to activate the menu bar.
Here is the menu function code for the 'File' menu which I call on WM_CREATE:
submenu = c_func(CreatePopupMenu,{}) --FILE menu c_func(AppendMenuA,{submenu, MF_STRING, ID_NEW, Menu_NEW}) c_func(AppendMenuA,{submenu, MF_STRING, ID_OPEN, Menu_OPEN}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVE, Menu_SAVE}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVEAS, Menu_SAVEAS}) c_func(AppendMenuA,{submenu, MF_STRING, ID_EXIT, Menu_EXIT}) c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_FILE})
I also have 'Edit', 'View', 'Tools', and 'Help' menu items.
Running Win7
2. Re: Windows Menu Items Not 'Clickable'
- Posted by BRyan Jan 22, 2014
- 1754 views
So, I've got a basic window programmed and all seems well so far, except that I none of my menu items are clickable until I press the 'Alt' key. All items on the sub-menus are clickable once they drop down, however, after that I have to press 'Alt' again to activate the menu bar.
Here is the menu function code for the 'File' menu which I call on WM_CREATE:
submenu = c_func(CreatePopupMenu,{}) --FILE menu c_func(AppendMenuA,{submenu, MF_STRING, ID_NEW, Menu_NEW}) c_func(AppendMenuA,{submenu, MF_STRING, ID_OPEN, Menu_OPEN}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVE, Menu_SAVE}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVEAS, Menu_SAVEAS}) c_func(AppendMenuA,{submenu, MF_STRING, ID_EXIT, Menu_EXIT}) c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_FILE})
I also have 'Edit', 'View', 'Tools', and 'Help' menu items.
Running Win7
Evan:
I think menu bar should be first after createpopupMenu that way submenus have something to append to ?
3. Re: Windows Menu Items Not 'Clickable'
- Posted by andi49 Jan 22, 2014
- 1738 views
So, I've got a basic window programmed and all seems well so far, except that I none of my menu items are clickable until I press the 'Alt' key. All items on the sub-menus are clickable once they drop down, however, after that I have to press 'Alt' again to activate the menu bar.
Here is the menu function code for the 'File' menu which I call on WM_CREATE:
submenu = c_func(CreatePopupMenu,{}) --FILE menu c_func(AppendMenuA,{submenu, MF_STRING, ID_NEW, Menu_NEW}) c_func(AppendMenuA,{submenu, MF_STRING, ID_OPEN, Menu_OPEN}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVE, Menu_SAVE}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVEAS, Menu_SAVEAS}) c_func(AppendMenuA,{submenu, MF_STRING, ID_EXIT, Menu_EXIT}) c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_FILE})
I also have 'Edit', 'View', 'Tools', and 'Help' menu items.
Running Win7
Hallo
At least for me, this is not enough code to reproduce the error
Maybe you could provide the complete code for creating the menue
including setmenu,drawmenubar etc.
You should also return zero after handling this message (WM_CREATE).
Andreas
4. Re: Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 23, 2014
- 1662 views
Here is a bit more complete bit of code:
In WinProc:
case WM_CREATE then MakeMenu(hwnd) return 0
MakeMenu function:
function MakeMenu( atom hwnd ) menubar = c_func(CreateMenu,{}) submenu = c_func(CreatePopupMenu,{}) --FILE menu c_func(AppendMenuA,{submenu, MF_STRING, ID_NEW, Menu_NEW}) c_func(AppendMenuA,{submenu, MF_STRING, ID_OPEN, Menu_OPEN}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVE, Menu_SAVE}) c_func(AppendMenuA,{submenu, MF_STRING, ID_SAVEAS, Menu_SAVEAS}) c_func(AppendMenuA,{submenu, MF_STRING, ID_EXIT, Menu_EXIT}) c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_FILE}) submenu = c_func(CreatePopupMenu,{}) --EDIT menu c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_EDIT}) submenu = c_func(CreatePopupMenu,{}) --VIEW menu c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_VIEW}) submenu = c_func(CreatePopupMenu,{}) --TOOLS menu c_func(AppendMenuA,{submenu, MF_STRING, ID_SETTINGS, Menu_SETTINGS}) c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_TOOLS}) submenu = c_func(CreatePopupMenu,{}) --HELP menu c_func(AppendMenuA,{menubar, MF_STRING + MF_POPUP, submenu, Menu_HELP}) c_func(SetMenu, {hwnd,menubar}) return 0 end function
5. Re: Windows Menu Items Not 'Clickable'
- Posted by BRyan Jan 23, 2014
- 1650 views
Evan:
Why are you using c_func ???
6. Re: Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 23, 2014
- 1647 views
Evan:
Why are you using c_func ???
Not sure I understand the question.
7. Re: Windows Menu Items Not 'Clickable'
- Posted by BRyan Jan 23, 2014
- 1630 views
Evan:
Why are you using c_func ???
Not sure I understand the question.
Sorry I don't understand what you are doing with c_func; have defined all your function in some other code some where else in your program. Why don't you use win32lib it would be easier or post a simple complete program to demonstrate your problem.
Then maybe someone else on the forum help you.
8. Re: Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 23, 2014
- 1635 views
I see what you mean. I thought you were saying that there was an alternative method to call a Windows function that was 'wrapped' using link_c_func. What would be the fun in using Win32Lib? I also brew my own beer, but I know I could go out and buy it already made.
user32 = open_dll("user32.dll") if user32 = NULL then not_found("user32.dll") end if CreateMenu = link_c_func(user32, "CreateMenu", {},C_INT) CreatePopupMenu = link_c_func(user32, "CreatePopupMenu", {},C_INT) AppendMenuA = link_c_func(user32, "AppendMenuA", {C_UINT, C_UINT, C_UINT, C_POINTER}, C_INT)
Anyway, as I said, everything works, just have to press 'Alt' before I can select any items.
I'll see if I can put together a smaller program.
9. Re: Windows Menu Items Not 'Clickable'
- Posted by andi49 Jan 23, 2014
- 1628 views
Hallo
I can't reproduce this.
I have copied your code into the window.exw Demoprogram that comes with Euphoria. It seems to work like expected.
http://openeuphoria.org/pastey/234.wc
Maybe this helps.
Andreas
10. Re: Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 24, 2014
- 1604 views
Hallo
I can't reproduce this.
I have copied your code into the window.exw Demoprogram that comes with Euphoria. It seems to work like expected.
http://openeuphoria.org/pastey/234.wc
Maybe this helps.
Andreas
I must have clobbered something. I used window.exw as a starting point for my program.
I just did the same as you and it works fine.
Thanks for the help.
Thank you too, Bernie.
11. Re: Windows Menu Items Not 'Clickable'
- Posted by evanmars Jan 24, 2014
- 1619 views
Found the problem.
Somehow I had changed the last two lines in WinProc to
c_func(DefWindowProcA, {hwnd, iMsg, wParam, lParam}) return 1
instead of
return c_func(DefWindowProcA, {hwnd, iMsg, wParam, lParam})