Solved

Draw cross on view (invalidate problem)

Posted on 2001-06-07
40
534 Views
Last Modified: 2013-11-20
i'd like to draw a cross on all the views except the one one view which is the reference-view.
the crosses would be draw in the same coordinates of the original cursor.
in case the original cursor is out of the reference-view rect the crosses should be erased from the rest of the viewes.
i hope i was clear enough and understandable.

i started doing it but something is wrong:
void CDblCursorView::OnMouseMove(UINT nFlags, CPoint point)
{
     CMultiDocTemplate* pMDT = ((CDblCursorApp*)AfxGetApp())->GetDocTemplate();
     POSITION pos = pMDT->GetFirstDocPosition();

     while(pos)
     {
          CDblCursorDoc* pDoc;
          if(pDoc = (CDblCursorDoc*)pMDT->GetNextDoc(pos))
          {
               POSITION viewPos = pDoc->GetFirstViewPosition();
               while(viewPos)
               {
                    CDblCursorView* pView;
                    if(pView = (CDblCursorView*)pDoc->GetNextView(viewPos))
                    {
                         if(pView == this)
                              continue;

                         pView->DrawVirtualCross(point);
                    }
               }
          }
     }    

     CView::OnMouseMove(nFlags, point);
}

void CDblCursorView::DrawVirtualCross(CPoint point)
{
     InvalidateRect(&m_lastRect);
     CRect rect(point.x-10,point.y-10,point.x+10,point.y+10);
     GetDC()->Ellipse(&rect);    
     m_lastRect = rect;
}

as u can see i save the last rect position of the ellipse and invalidate it but the ellipse is drawing while partly erased on flickered.

your help is appreciated
0
Comment
Question by:sedgwick
  • 24
  • 16
40 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 6164589
That's because InvalidateRect doesn't draw the rect, it just marks it as invalidated so it's redrawn
with the next WM_PAINT message which won't be sent automatically until you application is in
idle state (that means no more messages are in the message-queue).

You can solve this by calling UpdateWindow() after the InvalidateRect() before you draw anything.

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6164740
thanks zoppo it works.
now, about the second issue regarding erase the cursors in case the original cursor is out of the reference-view rect.
i can't erase them from the MouseMove because he would never reach to the function, so how can i do it?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6166619
hi sedgwick,

I see two ways:
1. capture the mouse while it moves through your view so you even get mouse message when
cursor moves outside your view ... then you can release the capture and undraw the cursors in
the other views

2. Use _TrackMouseEvent() and handle WM_MOUSELEAVE message ... but, this requires
Win2000/98/Me or WinNT4/95 with IE3.0 or higher

hope that helps,

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6172848
Zoppo, i decided  to use override PreTranslateMessage
if the main frame using this code:
     CPoint point;
     GetCursorPos(&point);
     CString str;
     
     CMyApp* pApp = (CMyApp*)AfxGetApp();
     if(pMsg->message == WM_MOUSEMOVE)
     {
          POSITION pos = pApp->m_pDocTemplate->GetFirstDocPosition();
          while(pos) {
               CMyDoc* pDoc = (CMyDoc*)pApp->m_pDocTemplate->GetNextDoc(pos);

               if(!pDoc)
                    continue;

               
               POSITION viewPos = pDoc->GetFirstViewPosition();
               while(viewPos) {
                    CMyView* pView = (CMyView*)pDoc->GetNextView(viewPos);
               
                    if(!pView)
                         continue;

                    CString str;
                    pView->GetParent()->GetWindowText(str);

                    if(str == REF_VIEW_NAME)
                    {
                         CRect rect;
                         pView->GetWindowRect(&rect);
                         if(!rect.PtInRect(point)){
//mouse cursor is out of reference view bounds...need to update all windows and erase the cursors....
                         }
                    }
               }
          }    

     }    


what do u say about this solution?
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6172905
Zoppo, thanks for your guidance but the real problem is how to draw a cross in a given coordinate and erase the previous after moving the cross, check
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=mfc&qid=20131522
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6173557
Zoppo, let me start from the begining instead of dividing my problem to mini-problem i'll explain u the whole thing and if u'll come with the solution i'll give u the maximum points (300 pts).

say u have several child windows while one of them is called the reference window/view.
i need to draw a cross in each one of the viewes except in the reference view, the coordinates of those crosses (or any kind of drawing which should look like a cursor) should be the same as the original cursor in the reference view.

if the cursor is out of the reference view frame all the other crosses should be erased.

my problems so far are:
1. i can't manage to erase the crosses in case the cursor is out of the reference view frame.
2. when i'm zooming in, the crosses or not in the same coordinate as the cursor in the reference view.
3. when i moving the cursor on a view which is not the reference one but the position of the cursor is on the rectangle of the reference view (despite the fact that the reference view is behind the view in focus) the crosses are been drawn.

its probably hard to understand my goals but i hope the code would shed a light...

CMyView::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_bVirtualCrossesMode)
{
     CMultiDocTemplate* pMDT = ((CMyApp*)AfxGetApp())->GetTheSingleTemplate();
     POSITION pos = pMDT->GetFirstDocPosition();

     while(pos)
     {
          CMyDoc* pDoc;
          if(pDoc = (CMyDoc*)pMDT->GetNextDoc(pos))
          {
               POSITION viewPos = pDoc->GetFirstViewPosition();
               while(viewPos)
               {
                    CZMyView* pView;
                    if(pView = (CMyView*)pDoc->GetNextView(viewPos))
                    {
                    //here i check that the current view is the reference view                               if(pView->GetDocument()->GetDocId() == ((CZ3App*)AfxGetApp())->GetReferenceUniqueID() ||
                              pView->GetDocument()->GetDocId() == GetDocument()->GetDocId())
                              continue;
                         else
//looping again on the viewes and update them all...
                         pView->ActivateVirtualCursor(point);
                    }
               }
          }
     }

   }
}

//m_zoomFactor-> in case of zoom in the value is changing accordingly

void CMyView::ActivateVirtualCursor(CPoint point)
{
CPoint newPoint = point + GetDeviceScrollPosition();
     newPoint.x /= m_zoomFactor;
     newPoint.y /= m_zoomFactor;
     if( point.y==0 || point.x==0 )
          return;     // invalid cross
     
     int crossLen = (m_zoomFactor < 2) ? 2 : ((m_zoomFactor < 8) ? 4 : 8 );
     int centerPixelOffset = m_zoomFactor / 2;     // compensate for the size of the zoomed pixel (center)

     InvalidateRect(m_lastRectVirtaualCursorPos);
     UpdateWindow();

     int newX=point.x+centerPixelOffset;
     int newY=point.y+centerPixelOffset;

     CRect rect1(newX-crossLen-1, newY, newX+crossLen+2, newY+1);
     CRect rect2(newX, newY-crossLen-1, newX+1, newY+crossLen+2);

     GetDC()->Rectangle(rect1);
     GetDC()->Rectangle(rect2);

     CRect uniRect;
     uniRect.UnionRect(&rect1, &rect2);

     m_lastRectVirtaualCursorPos = uniRect;

}

think u can help?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6176285
Hi again,

1.) PreTranslateMessage won't help here ... problem simply is that a window recieves WM_MOUSEMOVE
messages only as long as the mouse moves inside its client rect. There's is no real possibility to avoid
that the mouse cursor 'jumps' from within your view's client area to outside of your applications frame and
so you won't get any message at all (except you would implement either a global mouse hook or a
transparent, full screen sized window as topmost above the desktop and handle all messages yourself).

_TrackMouseEvent is especially made for this purpose so I think you should use it.

2.) hmm, maybe you have to calculate logical coordinates from device coordinates if you use CScrollView.
So you should be able to do the drawing without need to get current scroll position or zoom. See LPtoDP,
DPtoLP...

3.) This comes from your PreTranslateMessage: Every WM_MOUSEMOVE message which is handled in
PreTranslateMessage is anyhow sent to your ref-view ... I think you shouldn't use PreTranslateMessage
here at all because you don't really need ... simple WM_MOUSEMOVE and WM_MOUSELEAVE handlers
should be enough:::


Further I think you should avoid to call GetDC() twice for performance issues and even I think you'll have
to call ReleaseDC after GetDC to avoid resource leakage.

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6176717
i see,
do u mind post some sample code of how to use _TrackMouseEvent and WM_MOUSELEAVE since i needed it a few weeks ago and couldn't find any help about it.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6177146
ok, somehow like this:

define a flag as class member which indicates whether mouse tracking is active or not, i.e.

class CMyView : ...
{
 ...
 BOOL m_bIsInView;
 ...
};

Set its initial state to false, i.e.
CMyView()
{
 ...
 m_bIsInView = FALSE;
 ...
}

in WM_MOUSEMOVE handler do something like this:

CMyView::OnMouseMove(...)
{
 if ( !m_bIsInView )
 {
  TRACKMOUSEEVENT tme;
  tme.cbSize = sizeof( TRACKMOUSEEVENT );
  tme.dwFlags = TME_LEAVE;
  tme.hwndTrack = m_hWnd;
  tme.dwHoverTime = HOVER_DEFAULT;

  _TrackMouseEvent( &tme );
  m_bIsInView = TRUE;
 }
 ...
}

add a WM_MOUSELEAVE handler (I think you'll have to do this manually since WM_MOUSELEAVE
is not supported by ClassWizard), i.e.

CMyView::OnMouseLeave()
{
 m_bIsInView = FALSE;
 // undraw cursors here
 ...
}

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181171
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181177
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181180
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181215
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181372
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181412
hellioooooo
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181416
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181421
here's my code:    


void CZ3View::OnMouseMove(UINT nFlags, CPoint point)
{
CZ3App* pApp = (CZ3App*)AfxGetApp();

//first checking if i'm in the right mode and if its MouseMove() of the refernce view

     CZ3App* pApp = (CZ3App*)AfxGetApp();
     if(pApp->GetMultipleGelAnalysisMode() &&
          pApp->GetMGAReferenceGelUniqueID() == GetDocument()->GetDocId())
     {
          TRACKMOUSEEVENT tme;
          tme.cbSize = sizeof(TRACKMOUSEEVENT);
          tme.dwFlags = TME_LEAVE;
          tme.hwndTrack = this->m_hWnd;
          ASSERT(::_TrackMouseEvent(&tme));

          i need to loop all the view and display the rect in the coordinates of the original cursor on the reference view:

          POSITION pos = pApp->getTheSingleTemplate()->GetFirstDocPosition();
          while(pos){
               CZ3Doc* pDoc = (CZ3Doc*)pApp->getTheSingleTemplate()->GetNextDoc(pos);
               if(pDoc){
                    POSITION viewPos = pDoc->GetFirstViewPosition();
                    while(viewPos){
                         CZ3View* pView = (CZ3View*)pDoc->GetNextView(viewPos);
                         if(pView){
                              if(pView != this){
                                   if (!pView->m_bMouseTracking)
                                        pView->m_bMouseTracking = CTrackMouseEvent(pView).Track();

                                   // Calc new rectangle
                                   CRect rectNew(point.x-10, point.y-10, point.x+10, point.y+10);
                                   CClientDC dc(pView);

                                   // WM_MOUSEMOVE + !m_bMouseTracking becomes the equivalent of
                                   // WM_MOUSEENTER of which there is no such thing.
                                   if (!pView->m_bMouseTracking)
                                   {                                        
                                       
                                        pView->m_bMouseTracking = TRUE;
                                             
                                        // Draw new rect, but no last rect as we are starting a new
                                        dc.DrawDragRect(rectNew, CSize(2,2), NULL, CSize(0,0));
                                   }
                                   else
                                   {
                                        // Draw new rect and erase old rect
                                        dc.DrawDragRect(rectNew, CSize(2,2), pView->m_rectLast, CSize(2,2));
                                   }

                                   // Remember where we drew this rectangle
                                   pView->m_rectLast = rectNew;
                              }
                         }
                    }
               }
          }
     }

     CScrollView::OnMouseMove(nFlags, point);
}
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181423
LRESULT CZ3View::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
     CZ3App* pApp = (CZ3App*)AfxGetApp();
     if(pApp->GetMultipleGelAnalysisMode() &&
          pApp->GetMGAReferenceGelUniqueID() == GetDocument()->GetDocId())
     {
          POSITION pos = pApp->getTheSingleTemplate()->GetFirstDocPosition();
          if(pos){
               CZ3Doc* pDoc = (CZ3Doc*)pApp->getTheSingleTemplate()->GetNextDoc(pos);
               if(pDoc){
                    POSITION viewPos = pDoc->GetFirstViewPosition();
                    if(viewPos){
                         CZ3View* pView = (CZ3View*)pDoc->GetNextView(viewPos);
                         if(pView){
                                   // Draw last rect, but no new one (erase old rect)
                                   CClientDC dc(pView);
                                   dc.DrawDragRect(CRect(0,0,0,0), CSize(0,0), pView->m_rectLast, CSize(2,2));
                                   pView->m_rectLast = CRect(0,0,0,0);
                                   pView->m_bMouseTracking = FALSE;
                                   pView->Invalidate();                              
                         }
                    }
               }
          }
     }
 
    return TRUE;
}

the drawing is ok but OnMouseLeave() never get called even when i'm leaving the reference view with the mouse, can u look at this please?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6181470
is CTrackMouseEvent(pView).Track() called? How is it implemented...
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6181475
Did you add a ON_MESSAGE macro for WM_MOUSELEAVE in the view's message map?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 42

Author Comment

by:sedgwick
ID: 6181628
sorry, forgot to add CTrackMouseEvent that i had:
class CTrackMouseEvent : public tagTRACKMOUSEEVENT
{
public:
     CTrackMouseEvent(CWnd* pWnd, DWORD dwFlags = TME_LEAVE, DWORD dwHoverTime = HOVER_DEFAULT)
     {
          ASSERT_VALID(pWnd);
          ASSERT(::IsWindow(pWnd->m_hWnd));

          this->cbSize = sizeof(TRACKMOUSEEVENT);
          this->dwFlags = dwFlags;
          this->hwndTrack = pWnd->m_hWnd;
          this->dwHoverTime = dwHoverTime;
     }

     BOOL Track()
          { return _TrackMouseEvent(this); }
};


>>Did you add a ON_MESSAGE macro for WM_MOUSELEAVE in the view's message map?

yes i did.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6181740
what's the return value from Track()?

you can also try suggestion from MSDN about 'HOWTO: Detect When the Cursor
Leaves the Window ID: Q183107' which simply simulated TrackMouseEvent using a timer...

BTW, do you use timers in your view? Maybe if you do they conflict with timers which are used
with TrackMouseEvent...

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181834
>>what's the return value from Track()?

BOOL Track()
         { return _TrackMouseEvent(this); }

i don't understand why its not working
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6181860
>>what's the return value from Track()?
>BOOL ...
:)

I meant: What does it return at runtime, TRUE or FALSE?
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6181888
Zoppo: i think i made a progress here,
its working only if i debug the OnMouseLeave(), if i run without breakpoints it doing the OnMouseLeave() completely but the Invalidate doesn't effect the other viewes(the rects are still there),
but if i stop in the breakpoint in the OnMouseLeave and then continue run the Invalidate works, any idea?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6182283
Well, problem for this is in your OnMouseLeave handler.

First, why do you use GetFirstDoc... stuff. Simply use CView::GetDocument() to retrieve the
document for the current view.

Next, you only Invalidate the first view (GetFirstView...), but you should Invalidate all views ...
you can either do it by implementing a OnUpdate() for the view with a special hint-value and
call CDocument::UpdateAllViews() with this hint-value or you can iterate through the views in
OnMouseMove, i.e.:

LRESULT CZ3View::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
 CZ3App* pApp = (CZ3App*)AfxGetApp();
 if(pApp->GetMultipleGelAnalysisMode() &&
   pApp->GetMGAReferenceGelUniqueID() == GetDocument()->GetDocId())
 {
  POSITION pos = pApp->getTheSingleTemplate()->GetFirstDocPosition();
  if(pos){
   CZ3Doc* pDoc = (CZ3Doc*)pApp->getTheSingleTemplate()->GetNextDoc(pos);
   if(pDoc){
    for ( POSITION viewPos = pDoc->GetFirstViewPosition(); viewPos != NULL; )
    {
     CZ3View* pView = (CZ3View*)pDoc->GetNextView(viewPos);
     if(pView){
      // Draw last rect, but no new one (erase old rect)
      CClientDC dc(pView);
      dc.DrawDragRect(CRect(0,0,0,0), CSize(0,0), pView->m_rectLast, CSize(2,2));
      pView->m_rectLast = CRect(0,0,0,0);
      pView->m_bMouseTracking = FALSE;
      pView->Invalidate();                              
     }
    }
   }
  }
 }

return TRUE;
}


ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6182365
Zoppo, we both didn't notice that when i was iterating the documents and the views i wrote if(pos) instead of while(pos) so he handled only the first one and thats why he never did invalidate the views, only when i stop in breakpoint because then he redraw all the windows after i continue the code flow...

here it is:
     CZ3App* pApp = (CZ3App*)AfxGetApp();
     if(pApp->GetMultipleGelAnalysisMode() &&
          pApp->GetMGAReferenceGelUniqueID() == GetDocument()->GetDocId())
     {
          POSITION pos = pApp->getTheSingleTemplate()->GetFirstDocPosition();
          while(pos){
               CZ3Doc* pDoc = (CZ3Doc*)pApp->getTheSingleTemplate()->GetNextDoc(pos);
               if(pDoc){
                    POSITION viewPos = pDoc->GetFirstViewPosition();
                    while(viewPos){
                         CZ3View* pView = (CZ3View*)pDoc->GetNextView(viewPos);
                         if(pView){
                                   // Draw last rect, but no new one (erase old rect)
                                   CClientDC dc(pView);
                         dc.DrawDragRect(CRect(0,0,0,0), CSize(0,0), pView->m_rectLast, CSize(1,1));
                                   if(pView != this)
                                        pView->InvalidateRect(pView->m_rectLast);                              

                                   pView->m_bMouseTracking = FALSE;
                                   pView->m_rectLast = CRect(0,0,0,0);
                         }
                    }
               }
          }
     }

did u tryied to run it?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6184755
>did u tryied to run it?
no, coz I don't have the code and don't really have the time to build up a sample application...
did u tried it?
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6184919
yes i did, i have 1 tiny problem now:

The drawing is perfectly fine, when i move the cursor on the reference view, a drag rect is been drawing on all other viewes, BUT apparently the first(!) drag rect which is been drawing on the rest of the views are not been erased, and only the first.

any idea?

0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6185075
this comes from OnMouseMove I think:

 ...
 if (!pView->m_bMouseTracking)
  pView->m_bMouseTracking = CTrackMouseEvent(pView).Track();

 // Calc new rectangle
 CRect rectNew(point.x-10, point.y-10, point.x+10, point.y+10);
 CClientDC dc(pView);

 // WM_MOUSEMOVE + !m_bMouseTracking becomes the equivalent of
 // WM_MOUSEENTER of which there is no such thing.
 if (!pView->m_bMouseTracking)
 {                                        
  pView->m_bMouseTracking = TRUE;

  // Draw new rect, but no last rect as we are starting a new
  dc.DrawDragRect(rectNew, CSize(2,2), NULL, CSize(0,0));
 }
 else
 {
  // Draw new rect and erase old rect
  dc.DrawDragRect(rectNew, CSize(2,2), pView->m_rectLast, CSize(2,2));
 }
...

the second 'if (!pView->m_bMouseTracking)' is never TRUE unless Track() returns FALSE.

even you should check here which views you use ... you should use view pointed to by 'this'
for TrackMouseEvent only, not in the first view of the doc...

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6185308
u mean that i should move the declaration of TRACKMOUSEEVENT inside the loop????
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 100 total points
ID: 6185510
No, I mean you should simply use the view you already know in which the mouse is moved (this), i.e.:


// add a bool member m_bFirstDraw which you set to FALSE for all views in OnMouseLeave

void CZ3View::OnMouseMove(UINT nFlags, CPoint point)
{
 CScrollView::OnMouseMove(nFlags, point);

 CZ3App* pApp = (CZ3App*)AfxGetApp();

 //first checking if i'm in the right mode and if its MouseMove() of the refernce view
 if(!pApp->GetMultipleGelAnalysisMode() || pApp->GetMGAReferenceGelUniqueID() != GetDocument()->GetDocId())
  return;

 if (!m_bMouseTracking)
  m_bMouseTracking = CTrackMouseEvent( this ).Track();
CZ3Doc* pDoc = GetDocument();
 if(pDoc)
 {
  for ( POSITION viewPos = pDoc->GetFirstViewPosition(); viewPos != NULL; )
  {
   CZ3View* pView = pDoc->GetNextView( viewPos );

   CRect rectNew(point.x-10, point.y-10, point.x+10, point.y+10);
   CClientDC dc(pView);

   if ( m_bFirstDraw )
   {
    // Draw new rect, but no last rect as we are starting a new
    dc.DrawDragRect(rectNew, CSize(2,2), NULL, CSize(0,0));
    m_bFirstDraw = FALSE;
   }
   else
   {
    // Draw new rect and erase old rect
    dc.DrawDragRect(rectNew, CSize(2,2), pView->m_rectLast, CSize(2,2));
   }

   // Remember where we drew this rectangle
   pView->m_rectLast = rectNew;
  }
 }
}

somehow like this...

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6185733
its not erasing the first draw rect,
maybe i can check if its the first drawing and then erase the first rect somehow, got any idea?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6186156
sorry, I think I made a small mistake:

set m_bFirstDraw to TRUE in
- view's constructor
- OnMouseLeave

ZOPPO
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6186243
Zoppo, the rect is not erased cause we i didn't perform any action to erase it, anyhow, your suggestion doesn't work
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6186255
maybe easiest woud be if you'd email me your project ... zoppo@cdsgmbh.de ... if you agree.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6186275
just a test
mailto:zoppo@cdsgmbh.de
0
 
LVL 42

Author Comment

by:sedgwick
ID: 6186885
dear Zoppo, i was working almost an hour to create an application which would be similar as can be to my application.
i run it and i was surprised to see that the first rect is been erased as it should be.
the rect is drawing on viewes which display images (bmp, gif, tif...).
so to make it closer i created child windows with bitmaps on them, and copy the relevant code from my application and as i said before the first rect was erased perfectly.
my hands are tied and so is my brain.
i was sending u the code anyway but i really dont know what is the problem.


0
 
LVL 42

Author Comment

by:sedgwick
ID: 6187132
dear Zoppo, i was working almost an hour to create an application which would be similar as can be to my application.
i run it and i was surprised to see that the first rect is been erased as it should be.
the rect is drawing on viewes which display images (bmp, gif, tif...).
so to make it closer i created child windows with bitmaps on them, and copy the relevant code from my application and as i said before the first rect was erased perfectly.
my hands are tied and so is my brain.
i was sending u the code anyway but i really dont know what is the problem.


0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6187299
hmm, yep, you're right, seems to work fine ... except I found one problem: if you switch to another app while
moving the cursor (i.e. through CTRL-TAB) and back to your app these rects are drawn twice. Maybe you
need to capture the mouse and react on both WM_CAPTURECHANGED and WM_ACTIVATE to handle
this.

I wish you good look ... I'm not available until friday 9.00 AM CET coz we have a free-day here in germany
tomorrow ... from my own experience I can tell you that problems are often solved much easier when you
got the time to sleep a night meanwhile.

cu,

ZOPPO
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 149
not able to insert into temp table 68 150
Window placement 17 65
scoreUp challenge 14 48
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now