Click here to Skip to main content
15,908,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: 3D , I want 3D Pin
PJ Arends16-May-02 7:09
professionalPJ Arends16-May-02 7:09 
GeneralRe: 3D , I want 3D Pin
Max Santos16-May-02 7:19
Max Santos16-May-02 7:19 
GeneralRe: 3D , I want 3D Pin
PJ Arends16-May-02 7:27
professionalPJ Arends16-May-02 7:27 
QuestionHow to export a MSWord doc to XML ? Pin
16-May-02 6:50
suss16-May-02 6:50 
AnswerRe: How to export a MSWord doc to XML ? Pin
rbc16-May-02 14:07
rbc16-May-02 14:07 
GeneralRe: How to export a MSWord doc to XML ? Pin
16-May-02 23:51
suss16-May-02 23:51 
Generalprinting Pin
16-May-02 6:48
suss16-May-02 6:48 
GeneralFunction access between views Pin
Wade H.16-May-02 6:44
Wade H.16-May-02 6:44 
Background: I have a MDI application that reads in a text file created by our parent company's application. The main view for the application is View subclassed from CRichEditView, I have since splitter'ed off a View subclassed from CTreeView. Therefore, when you open a document,etc, you are presented with the data from the file in the richedit view. I am then taking the data in the richedit view (ascii text), filtering and making it appear a little better. Everything up to this point is fine. When I filter the data that is being read in, I am running various searches on the text to find key words that are always in the ascii data. I am then using the CRichEditView's sibling CTreeView to "index" the keyword data. ie)lets say that the ascii data has the keyword "chk" in it 5 times. The "chk number" is always right next to the keyword "chk". I am using the TreeView to index the "chk number" and the begining line position for where that "chk number" appears (along with other keywords and positions). I then want to be able to have the user click on the "chk number" in the TreeView and automatically goto that position in the RichEditView.
Problem: I can add to the correct treeview if I update from within the treeview itself (ie, when it is constructed), but not if I call the function from another view. Here is some code.
void CEJOrganizerTreeView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
m_ImageList.Create(IDB_SMALL_IMGLIST,16,0,RGB(0,0,0));
//GetTreeCtrl().SetImageList(&m_ImageList,TVSIL_NORMAL);
GetTreeCtrl().SetBkColor(RGB(254,239,201));
GetTreeCtrl().ModifyStyle(TVS_HASLINES,0);
GetTreeCtrl().ModifyStyle(0,TVS_HASLINES);
m_hChecks = GetTreeCtrl().InsertItem("Chks",TVI_ROOT,TVI_LAST);
// m_hChecks is a protected HTREEITEM member var
//InsertIntoChks("Test","10");
//The above works corectly when unremarked
}
bool CEJOrganizerTreeView::InsertIntoChks(CString sChkNo, CString sPosition)
//The above is predefined as a public function to access the protected members of the class
{
HTREEITEM hLast;
hLast = GetTreeCtrl().InsertItem(sChkNo,m_hChecks,TVI_LAST);
GetTreeCtrl().InsertItem(sPosition,hLast,TVI_LAST);
return true;
}

However, If I call the InsertIntoChecks function from the following code, it does not work correctly. It WILL insert into the correct treeview, but it will not insert into the the correct branch of the tree. It always posts to the TVI_ROOT.

void CEJOrganizerView::FindChks(void)
// A subclassed CRichEditView Class
{
... some initialization code...
CMainFrame* pMDIFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMDIFrame);
CChildFrame* pMDIChild = (CChildFrame*)pMDIFrame->MDIGetActive();
ASSERT(pMDIChild);
CEJOrganizerTreeView* pTreeView = (CEJOrganizerTreeView*) pMDIChild->m_wndSplitter.GetPane(0,0);
...some more code...
pTreeView->InsertIntoChks(sChkNo,sPosition);
...some more code...
}

My only way around this so far is to insert a new branch into the root, and then insert the "chk numbers" into that new branch, and stop the treeview fom adding the original parent items to begin with.

ie)
void CEJOrganizerView::FindChks(void)
{
... some initialization code ...
CMainFrame* pMDIFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMDIFrame);
CChildFrame* pMDIChild = (CChildFrame*)pMDIFrame->MDIGetActive();
ASSERT(pMDIChild);
pMDIChild->SetActiveView((CView*) pMDIChild->m_wndSplitter.GetPane(0,0)); //tried this for kicks, doesn't seem to help
CEJOrganizerTreeView* pTreeView = (CEJOrganizerTreeView*) pMDIChild->m_wndSplitter.GetPane(0,0);
HTREEITEM hCurrent = pTreeView->GetTreeCtrl().GetNextItem(pTreeView->m_hChecks,TVGN_ROOT); //using this currently, but doesn't seem to matter what is used here
//HTREEITEM hChildItem = pmyTreeCtrl->GetChildItem();
//HTREEITEM hNext = pTreeView->GetTreeCtrl().GetNextSiblingItem(hCurrent); //doesnt seem to help
HTREEITEM hChkNo;
hNext = pTreeView->GetTreeCtrl().InsertItem("Checks",TVI_ROOT,TVI_LAST);
...some more code...
hChkNo = pTreeView->GetTreeCtrl().InsertItem(sChkNo,hNext,TVI_LAST);
pTreeView->GetTreeCtrl().InsertItem(sPosition,hChkNo,TVI_LAST);
...some more code...
}
My concern is by doing it the above way, since I am not able to get to the data via my first method, am I going to be able to talk back to the CRichEditView to set the cursor position from the CTreeView? Or, will I run into a similar issue (because, even though it seems that everything is working coorectly, I am unable to get the data from the tree) when I try to make the richeditview view do something via the treeview? Hopefully, I am doing something wrong. I was hopeing to avoid sending messages from one control to another, especially since the end result is that I just need data to be moved across the two sibling views and no one else.

Thank you for any help.
GeneralHelp with typedef syntax Pin
markfd16-May-02 6:37
markfd16-May-02 6:37 
GeneralRe: Help with typedef syntax Pin
Tim Smith16-May-02 6:51
Tim Smith16-May-02 6:51 
GeneralRe: Help with typedef syntax Pin
markfd16-May-02 6:57
markfd16-May-02 6:57 
GeneralRe: Help with typedef syntax Pin
Chris Losinger16-May-02 6:58
professionalChris Losinger16-May-02 6:58 
GeneralRe: Help with typedef syntax Pin
PJ Arends16-May-02 7:06
professionalPJ Arends16-May-02 7:06 
GeneralHelp with SetROP2 Pin
Juan Carlos Cobas16-May-02 6:01
Juan Carlos Cobas16-May-02 6:01 
GeneralError Handling in SOAP services (using ATL 7.0) Pin
Le centriste16-May-02 5:55
Le centriste16-May-02 5:55 
GeneralCListCtrl set multiselection Pin
Zizilamoroso16-May-02 5:01
Zizilamoroso16-May-02 5:01 
GeneralRe: CListCtrl set multiselection Pin
KaЯl16-May-02 5:31
KaЯl16-May-02 5:31 
GeneralRe: CListCtrl set multiselection Pin
Zizilamoroso16-May-02 5:38
Zizilamoroso16-May-02 5:38 
GeneralRe: CListCtrl set multiselection Pin
Zizilamoroso16-May-02 5:41
Zizilamoroso16-May-02 5:41 
GeneralRe: CListCtrl set multiselection Pin
KaЯl16-May-02 5:52
KaЯl16-May-02 5:52 
GeneralRe: CListCtrl set multiselection Pin
Jean-Marc Molina3-Oct-03 1:21
Jean-Marc Molina3-Oct-03 1:21 
QuestionDynamically Creat icons? Pin
jimNLX16-May-02 4:38
jimNLX16-May-02 4:38 
AnswerRe: Dynamically Creat icons? Pin
Shog916-May-02 17:22
sitebuilderShog916-May-02 17:22 
Generalcopy-constructor issue Pin
Carlos Sánchez García16-May-02 4:29
Carlos Sánchez García16-May-02 4:29 
GeneralRe: copy-constructor issue Pin
Joaquín M López Muñoz16-May-02 5:02
Joaquín M López Muñoz16-May-02 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.