Solved

Update Child's Window View

Posted on 2002-07-08
7
425 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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