Is there any way to refresh() MFC CDialog
in the same class?
I have tried using Invalidate()
, RedrawWindow()
, UpdateWindow()
without success...
I would appreciate any kind of help.
Is there any way to refresh() MFC CDialog
in the same class?
I have tried using Invalidate()
, RedrawWindow()
, UpdateWindow()
without success...
I would appreciate any kind of help.
You have to close the program and run the program again.
Use GetModuleFileName
to find your app name. Run the program with CreateProcess
.
You can add a command line argument after applications path, for example " /restart?mydialog", so that when the program restarts, it can examine the commandline argument and launch the appropriate dialog. Example:
void CMyDialog::OnSettings()
{
wchar_t buf[MAX_PATH];
GetModuleFileName(NULL, buf, _countof(buf));
wcscat_s(buf, L" /restart?mydialog");
AfxGetMainWnd()->SendMessage(WM_CLOSE);
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi = { 0 };
CreateProcess(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
}
Now go to CMainFrame
, CMyMDIFrameWnd
, or whichever is the application's main window, and get ready to launch the dialog when L"/restart?mydialog"
appears in the command line. Example:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
...
CString s = GetCommandLine();
if (s.Find(L"/restart?mydialog") >= 0)
PostMessage(WM_COMMAND, ID_APP_ABOUT); //<== launch the correct dialog here
return 0;
}