Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting the activeview from a dialogbox

Posted on 1999-07-26
2
Medium Priority
?
175 Views
Last Modified: 2013-11-20
Hello,
I am a VC++ beginner using VC++6.0 Prof on Windows 98.

I have an MDI app in which I have so far created one child window.  This is a splitter window, one part of which is a CListView (in reportview with subitems).  I have got so far as doubleclicking on an item from the listview, which produces a Propertysheet with three pages.  This propertysheet is supposed to show data relating to the item in the listview.

I have the following problems:

1)  I need to get a pointer to the view that was active before I called up the Propertypages.

2)  With this I need to get the itemtext of the selected item in the listview.

I do not know how to do either of the above items.  I have produced the following code:

void CAddrPage1::GetRecordset()
{
        //parent of the propertysheet
 CMDIChildWnd* mpaul = (CMDIChildWnd*)GetParent();
        //active view of the parent
 CListView* msteve = (CListView*)mpaul->GetActiveView();
        //underlying listcontrol
 CListCtrl &mjohn = msteve->GetListCtrl();
        //don't know how to get selected item
 CString mhelen = mjohn.GetItemText(2,0);
        //SQL statement
 CString mtext = "Select * from AddressBook where Displayname = '" +
 mhelen + "'";    
        // recordset class ClassWizard created
 m_PSet = new CAddrRset1(mtext);  
        //error handling & open recordset for use in prop pages
 m_PSet->Open();
}

This code produces a runtime error saying it can't find the CListCtrl. The code is supposed to get the listview item, and with it create the recordset needed to prime the propertypages which I am calling up.  I call it in OnCreate() of page one of the new propertypages.

I would be very grateful for code showing how to do the above. Especially I am interested in how to extract the itemtext of the selected listview item.

Thanks,
Paul Trimming
0
Comment
Question by:trimtrom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
MatthiasLange earned 300 total points
ID: 1311507
If CAddrPage1 is a property page GetParent() returns a pointer to the Property Sheet. It's not guaranteed that the parent of the property sheet is the View (default is the desktop). You should store the pointer to the view or list control in a member variable of the property sheet before using it.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1311508
I think you really don't need to go thru all this pain of getting the active view and stuff. You can accomplish your thing by passing the pointer to the selected item in the constructor of your property sheet. For this you just need to your own property sheet class which has LV_ITEM pointer as constructor argument.

CPropertySheet propSheet (LV_ITEM* pItem);

I think it should work for you.... Try it. I have not tried it..
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question