I'm writing a dialog that plays video on a dialog frame by frame, and displays some status info around it. The dialog resource contains just a few CStatic controls that have bitmaps drawn on them.
The loop looks like this
DWORD milliPerFrame = std::lround(1000.0 / videoFile.get(CV_CAP_PROP_FPS));
unsigned int videoFrameCount = (unsigned int)videoFile.get(CV_CAP_PROP_FRAME_COUNT),
videoFrameWidth = (unsigned int)videoFile.get(CV_CAP_PROP_FRAME_WIDTH),
videoFrameHeight = (unsigned int)videoFile.get(CV_CAP_PROP_FRAME_HEIGHT);
uint64_t startTime, endTime;
CVideoDlg* canvas = new CVideoDlg();
canvas->Create(IDD_VIDEO_DIALOG, this);
canvas->ShowWindow(SW_SHOW);
CRect dialogSize = canvas->getDrawingRect();
int winFrameWidth = dialogSize.right - dialogSize.left,
winFrameHeight = dialogSize.bottom - dialogSize.top;
cv::Mat vFrame, dFrame;
for (unsigned frameNo = 1; frameNo <= videoFrameCount; frameNo++)
{
startTime = getCurrTime();
videoFile.read(vFrame);
cv::resize(vFrame, dFrame, cv::Size(winFrameWidth, winFrameHeight));
canvas->setFrame(dFrame);
bool status = (frameNo % 2 == 0);
canvas->setStitchingStatus(status);
endTime = getCurrTime();
Sleep(std::max(0, (int)(milliPerFrame - (endTime - startTime))));
}
The real code calls a routine that returns a status, which I've commented out for debug purposes.
The CVideoDlg has an OnInitDialog routine which calls ModifyStyle(0xF, SS_BITMAP, 0) for each of the CStatic controls, the two set methods, and getDrawingRect.
The stitching status is simple
void CVideoDlg::setStitchingStatus(bool status)
{
m_Stitching.ShowWindow(status ? SW_SHOW : SW_HIDE);
}
setFrame is a rather long routine, that draws the frame on another CStatic using StretchDIBits.
Problem is, stepping through with the debug I can see each CStatic drawn correctly, but causing the other one to be erased.
Why is that happening, and how can I fix it?
Edit: the top right rectangle is the stitching status CStaticm, the large one is the frame.
Edit: I've overridden the dialog's PreTranslateMessage method and put a break on it to see what messages it gets that might erase it's background. Nothing.
I've added a call to the dialog's RedrawWindow, and all the bitmaps correctly appear, but I still wonder why is it deleted in the first place.