demonstrator for possible CE bug

demonstrator for possible CE bug

Post by Kevin Verno » Wed, 23 May 2001 00:34:53



The code below demonstrates what appears to be a CE bug. If I paste this
only this code into the CChildView of an MFC generated view based app
without document support and lace up the message map.When I run the
demonstrator and scribble intensely on the view then any attempt to display
the default menus fails. In the full app where I first encountered the bug
on showing a dialog via AfxMessageBox() I get a zero return and
GetLastError() indicates no space.

Has anyone else experienced this kind of problem and developed a workaround.

Anyone from Microsoft listening who'd like the demonstrator source to see
the problem for themself.

Anyone see any stupids in the mouse handling?

CChildView::OnLButtonDown(UINT nFlags, CPoint point)
{
 m_StrokeStart.x = point.x;
 m_StrokeStart.y = point.y;

 m_MouseInMotion = true;

Quote:}

void CChildView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
 // its rumoured that a mouse button down can be converted to a db click if
it follows the previous one too
 // closely

 OnLButtonDown( nFlags, point);

Quote:}

void CChildView::OnLButtonUp(UINT nFlags, CPoint point)
{

 if (m_MouseInMotion)
 {
  m_MouseInMotion = false;
 }

Quote:}

void CChildView::OnMouseMove(UINT nFlags, CPoint point)
{

 if (m_MouseInMotion)
 {
  DrawStroke(m_StrokeStart,point);

  m_StrokeStart.x = point.x;
  m_StrokeStart.y = point.y;
 }

Quote:}

void CChildView::DrawStroke(CPoint From, CPoint To)
{

 POINT ptsMouseMove[66];
 POINT ptsCondMouseMove[66];
 UINT nMouseMovePointsCount;
 UINT nMouseMoveCondPointsCount;
 CRect Client;
 short nIndex;
 short CondIndex;

 GetClientRect(&Client);

 ::GetMouseMovePoints(&(ptsMouseMove[1]), 64,&nMouseMovePointsCount);

 if (nMouseMovePointsCount > 0)
 {
  for (short nIndex = nMouseMovePointsCount; nIndex > 0; nIndex--)
  {
   // divide point cordinates by four to get into pixel coordinate space

   ptsMouseMove[nIndex].x = ptsMouseMove[nIndex].x / 4;
   ptsMouseMove[nIndex].y = ptsMouseMove[nIndex].y / 4;

   // convert to client window coordinates

   ScreenToClient(&ptsMouseMove[nIndex]);
  }
 }

 // put in the start and end points

 ptsMouseMove[0].x = From.x;
 ptsMouseMove[0].y = From.y;
 ptsMouseMove[nMouseMovePointsCount + 1].x = To.x;
 ptsMouseMove[nMouseMovePointsCount + 1].y = To.y;

 // so lets condition the points array

 for (nIndex = 0, CondIndex = 0; nIndex < nMouseMovePointsCount + 2; nIndex
++)
 {
  // copy to the output array

  ptsCondMouseMove[CondIndex].x = ptsMouseMove[nIndex].x;
  ptsCondMouseMove[CondIndex].y = ptsMouseMove[nIndex].y;

  // constrain to be in our client rect

  if (ptsCondMouseMove[CondIndex].x < 0)
   ptsCondMouseMove[CondIndex].x = 0;

  if (ptsCondMouseMove[CondIndex].x >= Client.Width())
   ptsCondMouseMove[CondIndex].x = Client.Width() - 1;

  if (ptsCondMouseMove[CondIndex].y < 0 )
   ptsCondMouseMove[CondIndex].y = 0;

  if (ptsCondMouseMove[CondIndex].y >= Client.Height())
   ptsCondMouseMove[CondIndex].y = Client.Height() - 1;

  // now check if different from previous point

  if (CondIndex > 0)
  {
   if (ptsCondMouseMove[CondIndex].x != ptsCondMouseMove[CondIndex - 1].x
    || ptsCondMouseMove[CondIndex].y != ptsCondMouseMove[CondIndex - 1].y)

    CondIndex ++;
  }
  else
   CondIndex = 1;

 }

 // only draw if more than one point in conditioned array

 if (CondIndex > 0)
 {
  GetDC()->Polyline( ptsCondMouseMove, CondIndex);
 }

Quote:}

 
 
 

demonstrator for possible CE bug

Post by Ashley Antony Elenjick » Wed, 23 May 2001 04:13:28


Hello Kevin,
Thanks for your posting. I think it may be helpful to know what kind of
device/WinCE version you are using? Does your drawing come up correctly?
Before drawing do you hide menus, if yes how do you try to show it up
again?

Ashley Antony Elenjickal
Windows Embedded Systems
Microsoft.

--------------------

| Subject: demonstrator for possible CE bug
| Date: Mon, 21 May 2001 16:34:53 +0100
| Lines: 146
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

| Newsgroups: microsoft.public.windowsce.app.development
| NNTP-Posting-Host: s156.pool.pm3-tele-1.cix.co.uk 194.153.23.156
| Path: cppssbbsa01.microsoft.com!tkmsftngp01!tkmsftngp05
| Xref: cppssbbsa01.microsoft.com
microsoft.public.windowsce.app.development:6361
| X-Tomcat-NG: microsoft.public.windowsce.app.development
|
| The code below demonstrates what appears to be a CE bug. If I paste this
| only this code into the CChildView of an MFC generated view based app
| without document support and lace up the message map.When I run the
| demonstrator and scribble intensely on the view then any attempt to
display
| the default menus fails. In the full app where I first encountered the bug
| on showing a dialog via AfxMessageBox() I get a zero return and
| GetLastError() indicates no space.
|
| Has anyone else experienced this kind of problem and developed a
workaround.
|
| Anyone from Microsoft listening who'd like the demonstrator source to see
| the problem for themself.
|
| Anyone see any stupids in the mouse handling?
|
| CChildView::OnLButtonDown(UINT nFlags, CPoint point)
| {
|  m_StrokeStart.x = point.x;
|  m_StrokeStart.y = point.y;
|
|  m_MouseInMotion = true;
| }
|
| void CChildView::OnLButtonDblClk(UINT nFlags, CPoint point)
| {
|  // its rumoured that a mouse button down can be converted to a db click
if
| it follows the previous one too
|  // closely
|
|  OnLButtonDown( nFlags, point);
|
| }
|
| void CChildView::OnLButtonUp(UINT nFlags, CPoint point)
| {
|
|  if (m_MouseInMotion)
|  {
|   m_MouseInMotion = false;
|  }
|
| }
|
| void CChildView::OnMouseMove(UINT nFlags, CPoint point)
| {
|
|
|  if (m_MouseInMotion)
|  {
|   DrawStroke(m_StrokeStart,point);
|
|   m_StrokeStart.x = point.x;
|   m_StrokeStart.y = point.y;
|  }
| }
|
|
|
|
| void CChildView::DrawStroke(CPoint From, CPoint To)
| {
|
|  POINT ptsMouseMove[66];
|  POINT ptsCondMouseMove[66];
|  UINT nMouseMovePointsCount;
|  UINT nMouseMoveCondPointsCount;
|  CRect Client;
|  short nIndex;
|  short CondIndex;
|
|  GetClientRect(&Client);
|
|  ::GetMouseMovePoints(&(ptsMouseMove[1]), 64,&nMouseMovePointsCount);
|
|  if (nMouseMovePointsCount > 0)
|  {
|   for (short nIndex = nMouseMovePointsCount; nIndex > 0; nIndex--)
|   {
|    // divide point cordinates by four to get into pixel coordinate space
|
|    ptsMouseMove[nIndex].x = ptsMouseMove[nIndex].x / 4;
|    ptsMouseMove[nIndex].y = ptsMouseMove[nIndex].y / 4;
|
|    // convert to client window coordinates
|
|    ScreenToClient(&ptsMouseMove[nIndex]);
|   }
|  }
|
|  // put in the start and end points
|
|  ptsMouseMove[0].x = From.x;
|  ptsMouseMove[0].y = From.y;
|  ptsMouseMove[nMouseMovePointsCount + 1].x = To.x;
|  ptsMouseMove[nMouseMovePointsCount + 1].y = To.y;
|
|
|
|  // so lets condition the points array
|
|  for (nIndex = 0, CondIndex = 0; nIndex < nMouseMovePointsCount + 2;
nIndex
| ++)
|  {
|   // copy to the output array
|
|   ptsCondMouseMove[CondIndex].x = ptsMouseMove[nIndex].x;
|   ptsCondMouseMove[CondIndex].y = ptsMouseMove[nIndex].y;
|
|   // constrain to be in our client rect
|
|   if (ptsCondMouseMove[CondIndex].x < 0)
|    ptsCondMouseMove[CondIndex].x = 0;
|
|   if (ptsCondMouseMove[CondIndex].x >= Client.Width())
|    ptsCondMouseMove[CondIndex].x = Client.Width() - 1;
|
|   if (ptsCondMouseMove[CondIndex].y < 0 )
|    ptsCondMouseMove[CondIndex].y = 0;
|
|   if (ptsCondMouseMove[CondIndex].y >= Client.Height())
|    ptsCondMouseMove[CondIndex].y = Client.Height() - 1;
|
|   // now check if different from previous point
|
|   if (CondIndex > 0)
|   {
|    if (ptsCondMouseMove[CondIndex].x != ptsCondMouseMove[CondIndex - 1].x
|     || ptsCondMouseMove[CondIndex].y != ptsCondMouseMove[CondIndex - 1].y)
|
|     CondIndex ++;
|   }
|   else
|    CondIndex = 1;
|
|  }
|
|  // only draw if more than one point in conditioned array
|
|  if (CondIndex > 0)
|  {
|   GetDC()->Polyline( ptsCondMouseMove, CondIndex);
|  }
|
| }
|
|
|

 
 
 

demonstrator for possible CE bug

Post by Ashley Antony Elenjick » Wed, 23 May 2001 08:46:28


You should call ReleaseDC after GetDC(). I tried it on a PocketPC with the
slight modification of adding ReleaseDC() after calling GetDC, seems to
work fine.

Ashley Antony Elenjickal
Windows Embedded Systems
Microsoft.
--------------------
| X-Tomcat-ID: 294015038

| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit

| Organization: Microsoft
| Date: Mon, 21 May 2001 19:13:28 GMT
| Subject: RE: demonstrator for possible CE bug
| X-Tomcat-NG: microsoft.public.windowsce.app.development

| Newsgroups: microsoft.public.windowsce.app.development
| Lines: 122
| Path: cppssbbsa01.microsoft.com
| Xref: cppssbbsa01.microsoft.com
microsoft.public.windowsce.app.development:6365
| NNTP-Posting-Host: tide83.microsoft.com 131.107.3.83
|
| Hello Kevin,
| Thanks for your posting. I think it may be helpful to know what kind of
| device/WinCE version you are using? Does your drawing come up correctly?
| Before drawing do you hide menus, if yes how do you try to show it up
| again?
|
| Ashley Antony Elenjickal
| Windows Embedded Systems
| Microsoft.
|
| --------------------

| | Subject: demonstrator for possible CE bug
| | Date: Mon, 21 May 2001 16:34:53 +0100
| | Lines: 146
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
| | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

| | Newsgroups: microsoft.public.windowsce.app.development
| | NNTP-Posting-Host: s156.pool.pm3-tele-1.cix.co.uk 194.153.23.156
| | Path: cppssbbsa01.microsoft.com!tkmsftngp01!tkmsftngp05
| | Xref: cppssbbsa01.microsoft.com
| microsoft.public.windowsce.app.development:6361
| | X-Tomcat-NG: microsoft.public.windowsce.app.development
| |
| | The code below demonstrates what appears to be a CE bug. If I paste this
| | only this code into the CChildView of an MFC generated view based app
| | without document support and lace up the message map.When I run the
| | demonstrator and scribble intensely on the view then any attempt to
| display
| | the default menus fails. In the full app where I first encountered the
bug
| | on showing a dialog via AfxMessageBox() I get a zero return and
| | GetLastError() indicates no space.
| |
| | Has anyone else experienced this kind of problem and developed a
| workaround.
| |
| | Anyone from Microsoft listening who'd like the demonstrator source to
see
| | the problem for themself.
| |
| | Anyone see any stupids in the mouse handling?
| |
| | CChildView::OnLButtonDown(UINT nFlags, CPoint point)
| | {
| |  m_StrokeStart.x = point.x;
| |  m_StrokeStart.y = point.y;
| |
| |  m_MouseInMotion = true;
| | }
| |
| | void CChildView::OnLButtonDblClk(UINT nFlags, CPoint point)
| | {
| |  // its rumoured that a mouse button down can be converted to a db
click
| if
| | it follows the previous one too
| |  // closely
| |
| |  OnLButtonDown( nFlags, point);
| |
| | }
| |
| | void CChildView::OnLButtonUp(UINT nFlags, CPoint point)
| | {
| |
| |  if (m_MouseInMotion)
| |  {
| |   m_MouseInMotion = false;
| |  }
| |
| | }
| |
| | void CChildView::OnMouseMove(UINT nFlags, CPoint point)
| | {
| |
| |
| |  if (m_MouseInMotion)
| |  {
| |   DrawStroke(m_StrokeStart,point);
| |
| |   m_StrokeStart.x = point.x;
| |   m_StrokeStart.y = point.y;
| |  }
| | }
| |
| |
| |
| |
| | void CChildView::DrawStroke(CPoint From, CPoint To)
| | {
| |
| |  POINT ptsMouseMove[66];
| |  POINT ptsCondMouseMove[66];
| |  UINT nMouseMovePointsCount;
| |  UINT nMouseMoveCondPointsCount;
| |  CRect Client;
| |  short nIndex;
| |  short CondIndex;
| |
| |  GetClientRect(&Client);
| |
| |  ::GetMouseMovePoints(&(ptsMouseMove[1]), 64,&nMouseMovePointsCount);
| |
| |  if (nMouseMovePointsCount > 0)
| |  {
| |   for (short nIndex = nMouseMovePointsCount; nIndex > 0; nIndex--)
| |   {
| |    // divide point cordinates by four to get into pixel coordinate space
| |
| |    ptsMouseMove[nIndex].x = ptsMouseMove[nIndex].x / 4;
| |    ptsMouseMove[nIndex].y = ptsMouseMove[nIndex].y / 4;
| |
| |    // convert to client window coordinates
| |
| |    ScreenToClient(&ptsMouseMove[nIndex]);
| |   }
| |  }
| |
| |  // put in the start and end points
| |
| |  ptsMouseMove[0].x = From.x;
| |  ptsMouseMove[0].y = From.y;
| |  ptsMouseMove[nMouseMovePointsCount + 1].x = To.x;
| |  ptsMouseMove[nMouseMovePointsCount + 1].y = To.y;
| |
| |
| |
| |  // so lets condition the points array
| |
| |  for (nIndex = 0, CondIndex = 0; nIndex < nMouseMovePointsCount + 2;
| nIndex
| | ++)
| |  {
| |   // copy to the output array
| |
| |   ptsCondMouseMove[CondIndex].x = ptsMouseMove[nIndex].x;
| |   ptsCondMouseMove[CondIndex].y = ptsMouseMove[nIndex].y;
| |
| |   // constrain to be in our client rect
| |
| |   if (ptsCondMouseMove[CondIndex].x < 0)
| |    ptsCondMouseMove[CondIndex].x = 0;
| |
| |   if (ptsCondMouseMove[CondIndex].x >= Client.Width())
| |    ptsCondMouseMove[CondIndex].x = Client.Width() - 1;
| |
| |   if (ptsCondMouseMove[CondIndex].y < 0 )
| |    ptsCondMouseMove[CondIndex].y = 0;
| |
| |   if (ptsCondMouseMove[CondIndex].y >= Client.Height())
| |    ptsCondMouseMove[CondIndex].y = Client.Height() - 1;
| |
| |   // now check if different from previous point
| |
| |   if (CondIndex > 0)
| |   {
| |    if (ptsCondMouseMove[CondIndex].x != ptsCondMouseMove[CondIndex -
1].x
| |     || ptsCondMouseMove[CondIndex].y != ptsCondMouseMove[CondIndex -
1].y)
| |
| |     CondIndex ++;
| |   }
| |   else
| |    CondIndex = 1;
| |
| |  }
| |
| |  // only draw if more than one point in conditioned array
| |
| |  if (CondIndex > 0)
| |  {
| |   GetDC()->Polyline( ptsCondMouseMove, CondIndex);
| |  }
| |
| | }
| |
| |
| |
|
|