|
you can enumerate running processes if you have the name of the executable and match the filenames.
BTW, if you just want to check whether IE is running or not then this code snippet will work just fine
HWND hExplorer = ::FindWindow("IEFrame", NULL);
if (!hExplorer)
{
hExplorer = ::FindWindow("CabinetWClass", NULL);
}
if(hExplorer)
{
}
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
why not openprocess?
nave
|
|
|
|
|
you can use
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, yourID);
openprocess/EnumProcessModules/GetModuleFileNameEx/
First you should Handle to process and then you can use this function
and other functions....
|
|
|
|
|
Hi, if you already know the ProcessID you can use EnumProcesses function, instead of OpenProcess - it will tell you if the specified process is running. Good Luck!
|
|
|
|
|
Hi all,
I set the color of combobox text in OnCtlColor. But I cannot set the color for disabled combobox text. It always comes as gray always.
How can I change the text color of disabled combobox?
Thank you.
- NS -
|
|
|
|
|
NS17 wrote: But I cannot set the color for disabled combobox text. It always comes as gray always.
How can I change the text color of disabled combobox?
This cannot be set through OnCtlColor . Subclass the combo for customized functionality.
Nibu thomas
Software Developer
|
|
|
|
|
Thank you for your replay.
How can I do that? Can you give me a little bit explanation?
I am confused, about where should we write the code to set the color?
- NS -
|
|
|
|
|
Just a sample...
HBRUSH CSuperComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)
{
if (m_edit.GetSafeHwnd() == NULL)
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
}
else if (nCtlColor == CTLCOLOR_LISTBOX)
{
if (m_listbox.GetSafeHwnd() == NULL)
m_listbox.SubclassWindow(pWnd->GetSafeHwnd());
}
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
void CSuperComboBox::OnDestroy()
{
if (m_edit.GetSafeHwnd() != NULL)
m_edit.UnsubclassWindow();
if (m_listbox.GetSafeHwnd() != NULL)
m_listbox.UnsubclassWindow();
CComboBox::OnDestroy();
}
Nibu thomas
Software Developer
|
|
|
|
|
|
Hi all,
I'd like to change the icon of the child window dynamically. When I open a new window each time, I should be able to see the child window with different icon.
Using SetIcon in child window's PreCreateWindow function, I am able to set the icon; but with assertion failure.
Kindly suggest me a solution.
Thanks in advance,
Sarvan AL
|
|
|
|
|
Pass different icons to the child window everytime. And use SetIcon to display it.
Nibu thomas
Software Developer
|
|
|
|
|
Thanks Nibu,
I am able to set the icon. But I am getting the assertion error. I'm not able digonse it.
Do you have any other ideas to achieve this?
Thanks Once again,
Sarvan AL
|
|
|
|
|
Click on retry. Debug and find where it's asserting.
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
This is my code snippet.
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
SetIcon(m_hIcon, FALSE) ;
return TRUE;
}
m_hIcon is CChildFrame's member and I load the icon in the constructor, as follows:
m_hIcon = LoadIcon(AfxGetInstanceHandle(),
MAKEINTRESOURCE(ICON_TEST)) ;
What is wrong with this?
|
|
|
|
|
Yeah, I got it.
I moved the code "SetIcon(..)" into OnPaint(). Now it works.
Thanks a lot Nibu.
Sarvan AL
|
|
|
|
|
Sarvan AL wrote: I moved the code "SetIcon(..)" into OnPaint(). Now it works.
something tells me something is wrong
you must be getting Assertion failures cause the target window is not created yet.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Sarvan AL wrote: I moved the code "SetIcon(..)" into OnPaint(). Now it works.
You are using OnPaint for the wrong reasons.
Nibu thomas
Software Developer
|
|
|
|
|
Sarvan AL wrote: SetIcon(m_hIcon, FALSE) ;
Move this to OnCreate . If you use it here it will assert because the window handle is not created. It is just in PreCreateWindow stage.
Nibu thomas
Software Developer
|
|
|
|
|
I have captured video from webcam and displayed in my dialog.
How can i stop capturing video and disconnect webcam ,when i press Stop button?
JAYARAJ
|
|
|
|
|
J5121982 wrote: I have captured video from webcam and displayed in my dialog.
How?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
MFC doesn't have any functions to handle webcam either you are using DirectX or some third party SDK for this, please specify or paste some code.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Hi All,
I have a small problem with the code snippet below. Can anyone help me out in this. I launched Internet Explorer as a process from my application. I closed the Internet Explorer using the close button and when I use the following code of "OpenProcess", the method still works(meaning that the method is able to the open the process with the specified ID.
HANDLE p = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessIdentifier);
if(p != NULL)
MessageBox(_T("Please check patient context"),_T("EDMS context change"),MB_OK);
can anyone give some info on this please.
|
|
|
|
|
Please try the below method
HANDLE p = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessIdentifier);
DWORD dwEitCode = 0;
if( 0 != hProcess)
{
GetExitCodeProcess( p,&dwEitCode );
if( ( STILL_ACTIVE == dwEitCode )
{
// process is alive
}
else
{
// process is dead
}
Closehandle( p )
}
nave
|
|
|
|
|
Thanks Naveen. Its working as expected.
Could you please tell me what was wrong with my code that I used. I had also checked for NULL of that Handle returned right?
|
|
|
|