Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2016, 08:05 PM
Registered User
 
Join Date: Nov 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Highlighting sketcher elements

Hello,

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:

Code:
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?

Thanks





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 09: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 03:17 PM
sketcher koekke Wrox Book Feedback 1 October 20th, 2003 09:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.