Tuesday, February 03, 2009

Property List Notifications

In my last post I presented a custom control based on the previously published CTouchWindow WTL class. In this post I'm updating the code to support individual item enabling and disabling and also to illustrate how the client code can manage item notifications.

Each CTouchListItem (the base class for CPropertyListItem) now supports two new functions to control and report the enabled state: SetEnabled and IsEnabled. After changing the item state your code will have to update the item in order to reflect its updated status (this is very likely to change in the near future).

The new sample code now implements a very simple notification handling mechanism that tests the check state of the check box. This is done in the dialog's OnItemActivated method, called after a particular item is activated or deactivated. In this case, I test if the activated item is the check box item and enable or disable the second group (collapsing it when disabling).

As always, comments are welcome!

Sample: PropList2.zip (46 KB)

5 comments:

vincent said...

Hi,

I download, unzip and compile for WM6 in debug, I run it and click in the blank area below Details and it crashes!

João Paulo Figueira said...

Yikes! Looks like a major bug... Let me see what's wrong.

vincent said...

I have found some more bugs :

1) First unfold all your property groups to maximize height
2) Scroll down to display the last line Colors: Red
3) Uncheck and then check the checkbox
4) Now you cannot move anymore(at least on emulator)

I wanted also to display read-only fields so I have added dwStyle |= ES_READONLY to PropertyString.cpp but result is not good since I still have a cursor.

vincent said...

Forgot to say I had to check control validity:

if (m_wndEdit.IsWindow())
{
...
}

otherwise I got debug asserts.

vincent said...

To be more precise :
bool CPropertyString::Activate(bool bActive, int iItem)
{
if(bActive)
{

}
else
{
if (m_wndEdit.IsWindow())
{

}
}

return true;
}