Solved

Update Child's Window View

Posted on 2002-07-08
7
420 Views
Last Modified: 2013-11-20
I created a form view using MFC. There's a window (child window) in the form view. The child window is used to display a jpeg image. I managed to display the image in the child window. My problem is when I minimize the window and then maximize it again, the image in the sub window disappear. I put some code in the CView::OnDraw function but it doesn't work :

void CTestImgView::OnDraw(CDC* pDC)
{
Image cImage(L"c:\\inetpub\\ftproot\\live\\image_cam1_418.jpg");
     
     CDC* pCamDC = m_cCam1.GetDC();

     Graphics graphics(pCamDC->GetSafeHdc());

     graphics.DrawImage(&cImage, 10, 10);

     m_cCam1.ReleaseDC(pCamDC);

m_cCam1 is the subwindow.
}

Can sombody help ?
 
0
Comment
Question by:kctan100
7 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Set WS_CLIPCHILDREN style to child window using ModifyStyle() API.

Roshmon
0
 

Author Comment

by:kctan100
Comment Utility
Setting the style to WS_CLIPCHILDREN doesn't seem to help.

The child window is actually an active-X control derived from CWnd. When I minimize or maximize the parent window, the image in the child window disappeared.
The idea is to have the image redrawn in the child whenever the parent window get minimize, maximize or overlapping with other windows occur.

0
 
LVL 1

Expert Comment

by:gurly
Comment Utility
Did you try bringing the child window to top ? maybe it is just hidden.
0
 

Author Comment

by:kctan100
Comment Utility
I did it..but it doesn't solve the problem.
0
 
LVL 8

Accepted Solution

by:
fl0yd earned 50 total points
Comment Utility
You need to call
InvalidateRect( NULL, TRUE );
to add the entire region of the child window to the update-list and a
UpdateWindow();
to finally paint all invalidated window areas.

Put those two function calls in a WM_ACTIVATE-message handler.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

15 Experts available now in Live!

Get 1:1 Help Now