Process
-
hi i am calling the video player exe in my application that will show preview for the user. now the problems is that i want to disable the child window or window untill this exe run.after completion of preview the window should enable .
Here is my code :
void CPreview::OnpreviewBtnClk()
{
::MessageBox(m_hWnd,_T("here is the preview "),_T("INFORMATION"),MB_ICONINFORMATION);TCHAR szCmdline\[MAX\_PATH\]; CString szWindowTitle = \_T("rs-mplayer"); VERIFY(::GetModuleFileName(AfxGetApp()->m\_hInstance, szCmdline, \_MAX\_PATH)); szCmdline \[StrRChr (szCmdline, NULL, \_T('\\\\')) - szCmdline\] = \_T('\\0'); \_tcscat\_s(szCmdline, \_T("\\\\rs-mplayer.exe /")); ShellExecute(NULL,\_T("open"),szCmdline,NULL,sourceFileName,SW\_SHOWNORMAL);
// ProcessID = GetProcessId(szWindowTitle);
Sleep(500); CWnd \*pOtherWnd = CWnd::FindWindow(NULL, szWindowTitle); h\_Rs\_playerProcessId =pOtherWnd; if (pOtherWnd) { //ProcessID = GetProcessId(pOtherWnd); MYDATA m\_mydata; wcscpy(m\_mydata.m\_pName,sourceFileName); m\_mydata.m\_bNameLength = (BYTE)sourceFileName.GetLength(); m\_mydata.m\_ullNodeSize = m\_li64FileSize.QuadPart; COPYDATASTRUCT cpd; cpd.dwData = 1; cpd.cbData = sizeof(MYDATA); cpd.lpData = (void\*)&m\_mydata; //GetProcessTimes(h\_Rs\_playerProcessId,); copyDataResult = pOtherWnd->SendMessage(WM\_COPYDATA, (WPARAM)AfxGetApp()->m\_pMainWnd->GetSafeHwnd(), (LPARAM)&cpd); } ProcessID; // PreviewFile(szCmdline, sourceFileName, szWindowTitle, m\_li64FileSize.QuadPart);
}
Please reply me soon got struct from past two days Best Regards sarfaraz
-
hi i am calling the video player exe in my application that will show preview for the user. now the problems is that i want to disable the child window or window untill this exe run.after completion of preview the window should enable .
Here is my code :
void CPreview::OnpreviewBtnClk()
{
::MessageBox(m_hWnd,_T("here is the preview "),_T("INFORMATION"),MB_ICONINFORMATION);TCHAR szCmdline\[MAX\_PATH\]; CString szWindowTitle = \_T("rs-mplayer"); VERIFY(::GetModuleFileName(AfxGetApp()->m\_hInstance, szCmdline, \_MAX\_PATH)); szCmdline \[StrRChr (szCmdline, NULL, \_T('\\\\')) - szCmdline\] = \_T('\\0'); \_tcscat\_s(szCmdline, \_T("\\\\rs-mplayer.exe /")); ShellExecute(NULL,\_T("open"),szCmdline,NULL,sourceFileName,SW\_SHOWNORMAL);
// ProcessID = GetProcessId(szWindowTitle);
Sleep(500); CWnd \*pOtherWnd = CWnd::FindWindow(NULL, szWindowTitle); h\_Rs\_playerProcessId =pOtherWnd; if (pOtherWnd) { //ProcessID = GetProcessId(pOtherWnd); MYDATA m\_mydata; wcscpy(m\_mydata.m\_pName,sourceFileName); m\_mydata.m\_bNameLength = (BYTE)sourceFileName.GetLength(); m\_mydata.m\_ullNodeSize = m\_li64FileSize.QuadPart; COPYDATASTRUCT cpd; cpd.dwData = 1; cpd.cbData = sizeof(MYDATA); cpd.lpData = (void\*)&m\_mydata; //GetProcessTimes(h\_Rs\_playerProcessId,); copyDataResult = pOtherWnd->SendMessage(WM\_COPYDATA, (WPARAM)AfxGetApp()->m\_pMainWnd->GetSafeHwnd(), (LPARAM)&cpd); } ProcessID; // PreviewFile(szCmdline, sourceFileName, szWindowTitle, m\_li64FileSize.QuadPart);
}
Please reply me soon got struct from past two days Best Regards sarfaraz
1. Instead of
ShellExecute
, use CreateProcess[^]. This will give you a handle to the process in the struct specified forlpProcessInformation
. 2. Use EnableWindow[^] to disable whatever you wish to disable. 3. Run a timer with SetTimer[^], e.g. let it run every 5 seconds. 4. In the timer function, use WaitForSingleObject[^] with the handle of the process and a timeout of zero. When this gives youWAIT_OBJECT_0
, it means that the process has exited. If it did not, do nothing special. 5. If the process DID exit (you got the event signalled in step 4), then kill the timer with KillTimer[^], useEnableWindow
to re-enable what you need and don't forget to close the handles you got in that structure in step 1. Wouldn't this work for you?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
1. Instead of
ShellExecute
, use CreateProcess[^]. This will give you a handle to the process in the struct specified forlpProcessInformation
. 2. Use EnableWindow[^] to disable whatever you wish to disable. 3. Run a timer with SetTimer[^], e.g. let it run every 5 seconds. 4. In the timer function, use WaitForSingleObject[^] with the handle of the process and a timeout of zero. When this gives youWAIT_OBJECT_0
, it means that the process has exited. If it did not, do nothing special. 5. If the process DID exit (you got the event signalled in step 4), then kill the timer with KillTimer[^], useEnableWindow
to re-enable what you need and don't forget to close the handles you got in that structure in step 1. Wouldn't this work for you?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
while(pOtherWnd!=0)
{
pOtherWnd = CWnd::FindWindow(NULL, szWindowTitle);
//WaitForSingleObject(h_Rs_playerProcessId,INFINITE)
CPreview::EnableWindow(FALSE);
if(pOtherWnd == NULL)
{
CPreview::EnableWindow(TRUE);break; } sleepmode=5000; Sleep(sleepmode);
} lang="c++"></
i got the pOtherWnd is handle i set the timer sleepmode in sleep(sleepmode) its working fine after some time the window will strat not responding .. i have added the code with respect to the earlier code which i had posted . i tried with waitsingleobject by getting the handle og main window even though its not working help me out this Best Regards sarfaraz
-
while(pOtherWnd!=0)
{
pOtherWnd = CWnd::FindWindow(NULL, szWindowTitle);
//WaitForSingleObject(h_Rs_playerProcessId,INFINITE)
CPreview::EnableWindow(FALSE);
if(pOtherWnd == NULL)
{
CPreview::EnableWindow(TRUE);break; } sleepmode=5000; Sleep(sleepmode);
} lang="c++"></
i got the pOtherWnd is handle i set the timer sleepmode in sleep(sleepmode) its working fine after some time the window will strat not responding .. i have added the code with respect to the earlier code which i had posted . i tried with waitsingleobject by getting the handle og main window even though its not working help me out this Best Regards sarfaraz
Noone said you should use WaitForSingleObject with the window handle, of coure that doesn't work. And your aproach is wrong because while you are running this while loop -i assume you do this in the main GUI thread- your application is not processing any incoming messages, thus it will not respond.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
Noone said you should use WaitForSingleObject with the window handle, of coure that doesn't work. And your aproach is wrong because while you are running this while loop -i assume you do this in the main GUI thread- your application is not processing any incoming messages, thus it will not respond.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
hey bro i got it .. i added ontimer msg to GUI thread. thanks to you for sharing your knowledge