I am working on Win32 application. All drawing is done in WM_PAINT. It is working fine. i added one more functionality in it. When i click on button than Command prompt is executed. This i can done using WinExec. Now when i move Cmd.exe than in background drawing is not done. I update the code with CreateProcess than also the same thing is happened. Can anyone please help me whats wrong with this code. Is it because when i focus on This window than focus is losed and drawing is not done.
Code
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
TCHAR wchCmdPath[MAX_PATH];
memset(wchCmdPath,_T('\0'),MAX_PATH);
GetSystemDirectory(wchCmdPath,MAX_PATH);
wcscat(wchCmdPath,_T("\\cmd.exe"));
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line)
wchCmdPath, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
InvalidateRect(hwnd,NULL,TRUE);
UpdateWindow(hwnd);
Thanks in advance