Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does my menu appear very narrow ?

Status
Not open for further replies.

bulgakov

Programmer
Apr 24, 2003
26
GB
I have created a menu in the resource editor and have
implemented the following code (in my View class)

void CMBFView::OnContextMenu(CWnd *p, CPoint point)
{
CMenu Me;

Me.LoadMenu(ID_MY_MENU);

Me.TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this);

SetMenu(&Me);

Me.Detach();
}

And lo and behold the menu appears when I right click on the
window, the problem is the menu is so narrow I can't see the
labels, even though the menu items are there !
I am baffled have I missed something "obvious" ?
Please help. Thanks.
 
I now know what caused this, thanks for the response.
I basically created a menu in the resource editor
but didn't create a button to drop the menu off from.
So I had (displayed as a popup)

button1
button2
button3

not button1 -> button2
button3
button4

this now works. Its misleading when you display the
menu in the editor as a popup and it appears ok
but then doesn't work when you run the app !
 
bulgakov from reading your post I think you can help me with my menu difficulty. I created a menu using CreateMenu function and then AppenMenu function (have Visual C++ 6.0). I'm trying to use the resource.h and .rc files to do this. Created a .rc file. Right clicked on the .rc file folder icon and chose ID = Resource Symbols. Entered resource (menu) name. Loaded the menu using LoadMenu function and attach menu handle to CreateWindowEx function. Cannot get menu when I run function. Does my window need to be of FrameWindow class for it to work? Forum member apatterno asked for the code from your .rc file. I don't see where one can write into the .rc file because when it's created you can only rightclick and choose between ID = Resource Symbols and ID = Resource Includes.
Thanks for your help.

-x
 
your menu should look like this

xxxx <-- there could be anything, just the name of a submenu
->item 1 <- this is the submenu N1 (submenu(0))
item 2
item 3

void CMBFView::OnContextMenu(CWnd *p, CPoint point)
{
CMenu Me;

menu = Me.LoadMenu(ID_MY_MENU);
menu.GetSubMenu(0)->TrackPopupMenuEx(TPM_LEFTALIGN | TPM_LEFTBUTTON,
mpt.x, mpt.y, this, NULL);

SetMenu(&Me);

Me.Detach();
}



Ion Filipski
1c.bmp
 
Ran code and got errors including CMBFView is not a class or namespace name, undeclared identifiers -> CWnd p menu CPoint, OnContextMenu -> illegal use of type void, etc.
Would you recommend this or other win programming book?


MFC Answer Book,The:Solutions for Effective Visual C++ Applications by Eugene Kain.

-x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top