1. Windows Menu Items Not 'Clickable'

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

new topic     » topic index » view message » categorize

2. Re: Windows Menu Items Not 'Clickable'

evanmars said...

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 ?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Windows Menu Items Not 'Clickable'

evanmars said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Windows Menu Items Not 'Clickable'

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 
new topic     » goto parent     » topic index » view message » categorize

5. Re: Windows Menu Items Not 'Clickable'

Evan:

Why are you using c_func ???

new topic     » goto parent     » topic index » view message » categorize

6. Re: Windows Menu Items Not 'Clickable'

BRyan said...

Evan:

Why are you using c_func ???

Not sure I understand the question.

new topic     » goto parent     » topic index » view message » categorize

7. Re: Windows Menu Items Not 'Clickable'

evanmars said...
BRyan said...

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.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Windows Menu Items Not 'Clickable'

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.

new topic     » goto parent     » topic index » view message » categorize

9. Re: Windows Menu Items Not 'Clickable'

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: Windows Menu Items Not 'Clickable'

andi49 said...

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.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Windows Menu Items Not 'Clickable'

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}) 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu