0

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.

enter image description here

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.

Uri Raz
  • 435
  • 1
  • 3
  • 15
  • Please post an image of your dialog and clearly show the position and size of each of the static controls. – Jabberwocky Jul 27 '16 at 11:35
  • @Michael Walz - I've edited the original post to add the dialog. The top right rectangle is the stitching status CStaticm, the large one is the frame. – Uri Raz Jul 27 '16 at 11:49
  • There are _two_ rectangles on the top and they are on the _left_ side. – Jabberwocky Jul 27 '16 at 11:52
  • Yes, both are on the left side, but of those two one is one the left and one is on the right. – Uri Raz Jul 27 '16 at 12:14
  • For debugging purposes put the two statics at some significant distance and check what happens. – Jabberwocky Jul 27 '16 at 12:28
  • I've enlarged the dialog and moved the frame CStatic away about as far as it is tall, and moved the top two CStatic controls away from each other. Stepping with the debugger, the frame CStatic is drawn, and when I step to change the stitching CStatic either way, the dialog is completely erased. Next round through, the video frame is drawn, and the whole dialog is wiped at the same point, repeating until the video runs out. – Uri Raz Jul 27 '16 at 12:36
  • Try to remove the `ModifyStyle(0xF, SS_BITMAP, 0) ` it is most likely related to that some way. – Jabberwocky Jul 27 '16 at 12:44
  • Nope, commenting those out didn't change anything. – Uri Raz Jul 27 '16 at 12:57
  • Do any of your controls have `WS_EX_TRANSPARENT`? – Mark Ransom Jul 27 '16 at 13:13
  • No. Actually, the constant is nowhere to be found in the whole project. – Uri Raz Jul 27 '16 at 13:31
  • 1
    Please produce a [mcve]. There's nothing we can do without reproducing the issue. – IInspectable Jul 28 '16 at 19:38

0 Answers0