p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C++ and Visual C++ > BOOK: Ivor Horton's Beginning Visual C++ 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 24th, 2008, 03:33 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default CH 15 Context Menu - Element Menu Items

Hi All,

Having an issue with "Checking the Context Menu Items." I added the code for the list below and successfully compiled:

page 794: Implementing a Context Menu
page 795: Associating a Menu with a Class
page 797: Choosing a Context Menu
page 798: Identifying a Selected Element
page 800: Exercising the Pop-Ups

No problem so far. In "Checking the Context Menu Items" (page 800), the following code in void CSketcherView::OnContextMenu:

******** code **************
{
CMenu menu;
menu.LoadMenu(IDR_CURSOR_MENU); // Load the Context Menu

// Set Check Marks if it's the no Element Menu
if (m_pSelected == 0)
{
COLORREF Color = GetDocument()->GetElementColor();
menu.CheckMenuItem(ID_COLOR_BLACK,(BLACK == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_COLOR_RED,(RED == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_COLOR_GREEN,(GREEN == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_COLOR_BLUE,(BLUE == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);

// Check Element Menu Items
unsigned int ElementType = GetDocument()->GetElementType();
menu.CheckMenuItem(ID_ELEMENT_LINE,(LINE == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_ELEMENT_RECTANGLE,(RECTANGLE == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_ELEMENT_CIRCLE,(CIRCLE == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
menu.CheckMenuItem(ID_ELEMENT_CURVE,(CURVE == Color?MF_CHECKED:MF_UNCHECKED)|MF_BYCOMMAND);
}

CMenu* pPopup = menu.GetSubMenu(m_pSelected == 0 ? 1 : 0); // Get the First Menu
ASSERT(pPopup != NULL); // Ensure it's There

// Display the Popup Menu
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
******** end code **************

It all compiles fine, but when I right click on an element in the Sketcher program, only the menu color item is checked corectly. The menu element item is not checked at all.

An help would be greatly appreciated.

thanks,
Razzy






Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 11th, 2008, 08:19 AM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Razzy,

I see that you posted this a while ago now, so you've probably already figured out what's wrong. But just in case...

This looks suspiciously like a copy and paste error. In the lines of code which handle the element type section of the context menu the tests you're performing are against the 'Color' variable e.g. 'LINE == Color'. I think you need to change these tests to act on the 'ElementType' variable e.g. 'RECTANGLE == ElementType ...".

I think this should solve your problem. I hope that helps.

Dan

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 9th, 2008, 03:53 PM
Registered User
 
Join Date: Mar 2008
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dan,

Yes thanks. That was it.

Razzy

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not find the Add-In on the context Menu. himanshu2s BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 June 9th, 2008 03:44 AM
Need help in context menu Hannibal General .NET 0 January 3rd, 2007 12:24 AM
Context Menu ? zoltac007 BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 June 7th, 2006 06:44 PM
Context Menu JMorrell Beginning VB 6 2 February 18th, 2005 09:33 AM
context menu mookashi Pro VB 6 0 March 16th, 2004 06:48 AM



All times are GMT -4. The time now is 06:39 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc