|
-
October 5th, 2010, 04:43 AM
#1
CTabCtrl Enumeration Problem
Hi All,
I am trying to Enumerate all the child and sub child windows of a CTabCtrl window which is in external window. (Not my application)
I can successfully enumerate all the childs of the CTabCtrl window but they dont come in the perfect order of the Tab Page (Tabpage index wise).
Suppose there are Five Tab pages in CTabCtrl say A, B, C, D and E.
For every tab page there are five Dialog controls (Having class "#32770")
In each dialog controls there are some controls like Textbox, dropdownlist and ListBox etc.
When i try to enumerate them, the order of the dialog control (inside each tabpage) changes in the EnumWindow procedure.
Some times A-B-C-D-E and some times D-E-A-B-C and so on.
One thing i have noticed is that as the focus of the Tabpage in CTabCtrl changes, the enum order also changes.
Now my problem is that i want child controls of specific Tabpage, which i am not able to achieve.
Following is the Tab Enumeration Code
Code:
HWND m_fDialogs[5];
int DlgCounter=0;
BOOL CALLBACK EnumAllDialogs(HWND hwndChild,LPARAM lp)
{
char szClassName[256];
GetClassName(hwndChild,szClassName,strlen(szClassName)-1);
CString strClassName = CString(szClassName);
if(strClassName=="#32770")
{
m_fDialogs[DlgCounter] = hwndChild;
DlgCounter++;
}
return TRUE;
}
Here the order of the handles in the array changes as the focus of the Tabpage changes. I need to have the controls from the dialogs of the Tabpage 0 and 3.
Thanx for any kind of help...
-
October 5th, 2010, 05:09 AM
#2
Re: CTabCtrl Enumeration Problem
You'd make your problem much easier using CPropertySheet/CPropertyPage classes
Victor Nijegorodov
-
October 5th, 2010, 05:58 AM
#3
Re: CTabCtrl Enumeration Problem
 Originally Posted by VictorN
You'd make your problem much easier using CPropertySheet/CPropertyPage classes
what i have done from your suggestion is
Code:
CPropertySheet *cps = (CPropertySheet*)CWnd::FromHandle(m_fSysTab);
//m_fSysTab is the HWND of the CTabCtrl Control found in enumeration
int pageCount = cps->GetPageCount()
Here i got an unhandled exception...
Am i on wrong path???
Thanx for any kind of help...
-
October 5th, 2010, 06:16 AM
#4
Re: CTabCtrl Enumeration Problem
I never suggested you to cast tab control to CPropertySheet. 
Moreover, it is wrong!
CPropertySheet uses tab control as a child window.
Victor Nijegorodov
-
October 5th, 2010, 07:03 AM
#5
Re: CTabCtrl Enumeration Problem
 Originally Posted by VictorN
I never suggested you to cast tab control to CPropertySheet. 
Moreover, it is wrong!
CPropertySheet uses tab control as a child window.
How can i have CPropertySheet from the following windows hierarchy.
Code:
---> Message Bar
|---> Message Bar
|---> SysTabControl32
|---> "32770" Dialog
|---> TextBox
|---> "32770" Dialog
|---> TextBox
|---> "32770" Dialog
|---> TextBox
|---> "32770" Dialog
|---> TextBox
|---> "32770" Dialog
|---> TextBox
This is the hierarchy as per SPY++.
Now what i am doing is...
1. Enumerating Wndows to get MessageBar
2. Enumerating Windows to get MessageBar
3. Enumerating Windows to get SysTabControl32
4. Enumerating All Dialog Controls of SysTabControl32
How can i do this with CPropertySheet/CPropertyPage...
Please help...
Last edited by shail2k4; October 5th, 2010 at 07:06 AM.
-
October 5th, 2010, 07:14 AM
#6
Re: CTabCtrl Enumeration Problem
 Originally Posted by shail2k4
How can i have CPropertySheet from the following windows hierarchy.
You cannot.
But you could very simple solve your problem if you changed your design from using CTabCtrl+Dialogs to CPropertySheet+CPropertyPages.
Note that
there is no such a concept as a "Tabpage 0 and 3". There are tabs and you, of course, can open some "page" by new tab selection, and this "page" may be a dialog or some other window type like just a static control, or there may no "page" at all!
Victor Nijegorodov
-
October 5th, 2010, 07:32 AM
#7
Re: CTabCtrl Enumeration Problem
 Originally Posted by VictorN
You cannot.
But you could very simple solve your problem if you changed your design from using CTabCtrl+Dialogs to CPropertySheet+CPropertyPages.
Oh, i think there is misunderstanding
This is not my design... It is an external application and i want to get data from that application..
Though i have got the desired data, but as the order in the enumeration changes, everything becomes kbooom!!!
-
October 5th, 2010, 07:52 AM
#8
Re: CTabCtrl Enumeration Problem
 Originally Posted by shail2k4
Oh, i think there is misunderstanding
This is not my design... It is an external application and i want to get data from that application..
Then why didn't you mention it from the very begin in your OP? 
The order of child windows you get using EnumWindow (or using GetWindow/GetNextWindow depends on Z Order, so what you see ba enumeration is "by design" of Windows!
Note also that in some cases the dialogs corresponding some tabs may have not been created in the moment you are trying to enumerate them (usually, such dialogs are created only after corresponding tab becomes active.
Victor Nijegorodov
-
October 5th, 2010, 08:00 AM
#9
Re: CTabCtrl Enumeration Problem
 Originally Posted by VictorN
Then why didn't you mention it from the very begin in your OP? 
I have already mentioned that in my post at begining
Hi All,
I am trying to Enumerate all the child and sub child windows of a CTabCtrl window which is in external window. (Not my application)
Note also that in some cases the dialogs corresponding some tabs may have not been created in the moment you are trying to enumerate them (usually, such dialogs are created only after corresponding tab becomes active.
In every trial i am getting all five dialogs and the controls of that dialogs even if the application is not active...
The problem is the order of the enumeration...
-
October 5th, 2010, 08:21 AM
#10
Re: CTabCtrl Enumeration Problem
 Originally Posted by shail2k4
I have already mentioned that in my post at begining
You are right. I missed it... Sorry! 
 Originally Posted by shail2k4
In every trial i am getting all five dialogs and the controls of that dialogs even if the application is not active...
...
Well, perhaps you were lucky in all your trials. But there is no any guarantee it will be always so "good"...
 Originally Posted by shail2k4
The problem is the order of the enumeration...
Then try to activate the tab you need to get info from before enumerating...
Victor Nijegorodov
-
October 5th, 2010, 09:19 AM
#11
Re: CTabCtrl Enumeration Problem
 Originally Posted by VictorN
You are right. I missed it... Sorry!
No probs at all....
Will try with all of your suggestions...
Thanx a lot...
Regards,
Shail2k4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|