Refresh window in Visual C ++

I have a Visual C ++ project, but I cannot update the window and redraw myself. I used

RedrawWindow();
m_ProgressDlg->RedrawWindow();

      

and

UpdateData(false);
m_ProgressDlg->UpdateData(false);

      

but it never seems good.

How can i do this?

0


a source to share


6 answers


You can use UpdateWindow in conjunction with InvalidateRect for immediate redrawing.



+4


a source


For client area use InvalidateRect + UpdateWindow. If you want to redraw the non-client area of ​​the window, try calling SetWindowPos with SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE.



+2


a source


:: InvalidateRect (hwnd, NULL, TRUE). The WinAPI function (or wnd-> InvalidateRect (NULL)) has to do the trick: it invalidates the client area and forces the system to send a WM_PAINT to the window to redraw it. If immediate redrawing is required, you should also call UpdateWindow () immediately after canceling.

+1


a source


It looks like you are using MFC.

I believe your application is busy and is not processing messages from the queue, so it is not processing the WM_PAINT that would update the window.

Use the RDW_UPDATENOW parameter with RedrawWindow to force redrawing even when your window is busy.

+1


a source


But in the release version it doesn't work correctly and if with the omitted space it looks like

0


a source


You might also try to call Invalidate () and RedrawWindow (), while m_hWnd is NULL, if "not good" means "failure". Try:

if (m_hWnd)
{
   Invalidate();
   RedrawWindow();
}

      

(I know this is old, but some of us still have one leg stuck in MFC nasty.)

0


a source







All Articles