[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

MFC CPropertyPage/CPropertySheet synchronization question

Hi,

In my project, I got a synchronization problem in CPropertyPages on a CPropertySheet. Here is the scenario:

In a CFormView page, there is right pane and left page. Left pane is a CListCtrl, which list all the current items. Right pane contains a CPropertySheet which has 2 CPropertyPages.

On selecting one of the items in the right pane, the first property page in the right page displays some configuration info of the item. These info is editable. The second property page displays a summary of the cofiguration of the first page and the info is read-only.

My questions are:

1. How can I display the current info in the second page?
   This means the second page should display the updated info whenever user makes change in the first page.

2. How can I display the current info in both pages when user select another item in the CListCtrl in the left pane?
   Currently, I load the info in all pages whenever a user select an item in the list ctrl. However, it is not efficient. I wnat the new item info will be only reloaded for the current active page. And the other page can display the info when user makes it active.

Thanks in advance.

Andy
0
xxg4813
Asked:
xxg4813
  • 4
  • 4
1 Solution
 
Jaime OlivaresCommented:
1. How can I display the current info in the second page?
   This means the second page should display the updated info whenever user makes change in the first page.

Construct first page
Construct second page
Place a pointer to second page as a member of first page (to let 1st page know how to communicate with second one)
Add pages to propertysheet and create them...
You have to trap notifications from first page (like EN_CHANGE) and call a single update function in second page, using the pointer you assigned early.


2. How can I display the current info in both pages when user select another item in the CListCtrl in the left pane?
   Currently, I load the info in all pages whenever a user select an item in the list ctrl. However, it is not efficient. I wnat the new item info will be only reloaded for the current active page. And the other page can display the info when user makes it active.

Just update first page, this will generate events that will make 1st page to call second page's update function...
0
 
xxg4813Author Commented:
Hi Jaime,

Thanks! For question 1, I got your rough idea. I will try.

For question 2, could you give me more deatil? What kind of events will be generated by the 1st page?

with many thanks!

Andy
0
 
Jaime OlivaresCommented:
If you change text in page1 programatically, an EN_CHANGE event will be generated automatically
If you change selection in a combo, an CBN_SELCHANGE event will be generated automatically
etc..
So, if you have a handler for those events (to comply with purpose of question 1) then you have solved both questions in one step....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
xxg4813Author Commented:
Hi Jaime,

Thanks agian.

Unfortunately, my controls are both CListCtrl. I tried to catch LVN_ITEMCHANGED event. However, I found this event is also caught when the program initially populate the CListCtrl. Am I catching the wrong event? Otherwise, if I put the update function under this event, it will get called too many times. :(

Andy
0
 
xxg4813Author Commented:
Hi Jaime,

Thanks!

I figured out the second quetsion. I can use a bool variable to test if it is initializing the CListCtrl or modifying it. So,  please discard my previous comment.

However, I still cannot figure out the first problem by trying your idea. How do you handle the following case:

1. Select an item in left panel, which is a list ctrl. And show the content in 1st page.
2. Do nothing and switch to 2nd page.

In this case, 2nd page should display the same content as 1st page. But I cannot figure out a way to only load 1st page before I switch to 2nd page.

What's your opinion?

andy
0
 
Jaime OlivaresCommented:
>In this case, 2nd page should display the same content as 1st page. But I cannot figure out a way to only load 1st page before I switch to 2nd page.
Really I can't understand you. I will make a try:

left panel (pane?) has a list control, you change selection, then change content in pag1 and not in pag2.
pag2 will change only when a change is made directly in pag1.
If this is the case, the boolean approach will be enough:
before changing pag1, toggle a boolean variable in pag2 to prevent to be updated with any event. Toggle again to wait event from pag1.
0
 
xxg4813Author Commented:
HI Jaime,

Sorry for misleading. What I mean is:

If I select any item in the left panel, its configuration info should be displayed in both 1st and 2nd pages. 2nd page is just a read-only version of 1st page. If I make changes in 1st page, this change will be displayed in 2nd page. For this operation, 1st page can just call 2nd page's update function. However, what's my concern is how to populate the 2nd page initially?

My current approach is to load the both pages initally. But I want to load them only the page is set active. How to do that?

Thanks!

Andy
0
 
Jaime OlivaresCommented:
> what's my concern is how to populate the 2nd page initially?
Maybe you can call 2nd's page update from some initialization function of pag1 like OnInitialUpdate()...

> But I want to load them only the page is set active. How to do that?
Why? Still don't understand why this constraint, that will force to extra synchonization tasks....
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now