Solved

Update Child's Window View

Posted on 2002-07-08
7
422 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
ID: 7139644
Set WS_CLIPCHILDREN style to child window using ModifyStyle() API.

Roshmon
0
 

Author Comment

by:kctan100
ID: 7140550
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
ID: 7140562
Did you try bringing the child window to top ? maybe it is just hidden.
0
 

Author Comment

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

Accepted Solution

by:
fl0yd earned 50 total points
ID: 7149123
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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: 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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

19 Experts available now in Live!

Get 1:1 Help Now