Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Ivor Horton's Beginning Visual C++ 2013
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2013
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2013 by Ivor Horton; ISBN: 978-1-118-84571-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2013 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old November 3rd, 2016, 08:05 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2016
Location: Sacramento, CA
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Highlighting sketcher elements


I have been working my way through the ‘Sketcher’ example application beginning at the end of chapter 12. It has been going well up to chapter 15- Highlighting Elements.
My sketch elements don’t highlight. Through diagnostic and breakpoints I have determined that the program flow seems correct.

The ‘else’ portion of the View’s ‘OnMouseMove’ handler (pg 734) is triggered when the mouse moves into the area of an element. It correctly identifies if the there is a change in the selected element and calls the ‘UpdateAllViews’ method:

auto pOldSelected = m_pSelected;   // Save any previously highlighted element
m_pSelected = GetDocument()->FindElement(point);  // Not creating element.
                                                  //  Are we hovering over one?

if (m_pSelected != pOldSelected)
    //  Seleceted element has changed
	  if (m_pSelected)
		GetDocument()->UpdateAllViews(nullptr, 0, m_pSelected.get()); 
                           //  Highlight new element if not null

		RedrawWindow();  //  this is the work-around I have to add
                          //    to get Highlighting to work
	  if (pOldSelected)
		GetDocument()->UpdateAllViews(nullptr, 0, pOldSelected.get());   
                           //  UN-Highlight previous element if not null

		RedrawWindow();  //  this is the work-around I have to add
What does NOT happen that I believe is supposed to, is the View’s ‘OnDraw’ handler should be called. This is not happening.
Since ‘OnDraw’ is not being called, none of the sketch’s elements’ Draw methods are called.

Looking back to page 687- I could not see where in this code a WM_PAINT message was being sent- there is no call to ‘UpdateWindow’ in this sequence. So I added a call to ‘UpdateWindow’ in the code above. This had no effect on the execution- no highlighting of elements occurred.

In frustration (and curiosity) I changed that to a forced redraw with ‘RedrawWindow’. This worked. My sketch elements are now highlighted when the mouse moves over them.
For whatever reason the change of color for the highlighting is not getting posted as an Invalid Area of the window, so it is not generating a redraw of the window.

Is there something missing in this example? If not, where should I look next for the problem?

Reply With Quote

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 16 pg 574: Elements not supported Elements not known tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 August 6th, 2009 02:48 PM
CH 15: Highlighting Elements Razzy The Pug BOOK: Ivor Horton's Beginning Visual C++ 2005 1 November 9th, 2008 08:39 PM
Spiral Sketcher freezotic BOOK: Beginning Java 2 0 September 4th, 2004 01:08 PM
Sketcher Source JCScoobyRS Java GUI 1 November 17th, 2003 02:17 PM
sketcher koekke Wrox Book Feedback 1 October 20th, 2003 09:43 AM

All times are GMT -4. The time now is 01:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.