Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone..

Am bit confused how to identify whether the child window is present or not. Let me elaborate it. Am having Two main windows namely First window title [Wing Fung Bullion Investment Limited - Demo CLIENT : 019579 (CONNECTED) ] & Second window Title[Sun Gold Group Company Limited - DEMO trader : 3494 (CONNECTED) ]. When i double click on the SELL button of First window, it pop up's the child window i.e., Add Open Deal.
Here i need to identify the whether the Add Open Deal window is Opened or not ? For that am using FindWindow Api like this:

C++
HWND hwnd = :: FindWindow(NULL,"Add Open Deal");


The Problem what am facing is.. If the Add Open Deal is opened then hwnd has the value 0x0001067a{unused=-17891602}. And, If Add Open Deal window is not Opened, still hwnd has the value 0x0001067a{unused=-17891602}. Am not getting how to identify whether it is present or not..

Please suggest/guide me on this..

Thank you All.
Posted

1 solution

In your MFC context :) :
C++
inline bool CYourFirstWnd::IsDealOpened() const
{
  return (FALSE != ::IsWindow(m_cDealPopup.GetSafeHwnd()));
}
 
Share this answer
 
v2
Comments
Guru_C++ 16-Nov-12 2:22am    
Hello Eugen.. Thanks for helping.. In my application, First window (i.e., Wing Fung ) is not pro-grammatically created. Its just like third party application. Then how to use CYourFirstWnd code ? am not getting it..
Eugen Podsypalnikov 16-Nov-12 2:31am    
OK :)
- try to set the HWND variable to NULL before the second call of ::FindWindow(..)
- try to pass also the window class name (shown by Spy++) to the call of ::FindWindow(..)
- check that your searching window title is the same as the shown by Spy-tool (copy it there and then paste to your code)
Guru_C++ 16-Nov-12 3:01am    
I used the first method i.e., assigning the hwnd variable to NULL ..The result was same.. And, i used the Spy tool to check the Window name & Class name, later i came to the class name i.e., SunAwtDialog. Now the code looks like this..

HWND hwnd = NULL;
hwnd = ::FindWindow("SunAwtDialog","Add Open Deal");

The Result is same. Eventhough the Add Open Deal is closed, hwnd contains valid address..
Eugen Podsypalnikov 16-Nov-12 3:08am    
OK :)
- then use an additional call of ::IsWindowVisible(hwnFound) after the hwnFound = ::FindWindow(..)
Guru_C++ 16-Nov-12 4:19am    
Hi Eugen.. Thanks a lot for giving a hint. I guess i found the solution as u suggested to use ::IsWindowVisible(). My code looks like this:

CWnd *cwnd = NULL;
cwnd = FindWindow("SunAwtDialog","Add Open Deal");
BOOL isTrue = cwnd->IsWindowVisible();

Now.. If Add open Deal window is opened, isTrue variable contains 1.. If not opened isTrue contains 0. Based on this i can do operations on Add Open Deal window.

Thanks a lot :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900