Properties Grid Control

This article contains the detail documentation of XPropertiesWnd Control described in A Set of 2 ActveX controls

Properties Grid Control looks exactly like property window from Visual Basic and has more features. It has two columns. The first column contains the name of a property and the second contains the property’s value. The following are the properties, methods and events of the Control:

Properties

Type

Name

Specification

OLE_COLOR

BackColor

Change the background color of this control

BSTR

PagesAndItems

Store all elements from this grid into a template form. It is usefull when user want to load more pages and items without flickering.

Boolean

ToolTips

If the value of one property is not entirely visible, you can activate tooltips with this property.

Boolean

FirstPageHasCaption

Has effect only if control has one page. In that case if this is FALSE the page hasn’t a caption bar.

Boolean

AsFloor

Set the style of the contained xFloorWnd Control to be as floor or page.

IFontDisp*

ItemFont

Set the font for all properties.

IFontDisp*

Font

Set the font for the caption pages or for group property

boolean

ResizeFirstColumn

true –means that you can resize the column name of grid, and false otherwise

boolean

Animation

true – this means that if we are more then one page, when you select other page then the current one this will be activated using animation. false - the selected page will be activated instantly

Methods

Name

Specification

short AddPage(BSTR lpszPageName)

this method adds a new page called lpszPageName into the control and returns the index of this page.

boolean DeletePage(short nIndexPage)

This method deletes the page with the index nIndexPage.Returns true if the page was deleted successfully and false otherwise.

long GetPagesCount()

returns the number of pages from xPropertiesWnd Control.

BSTR GetPageName(short nIndexPage)

returns the name for the page with the index nIndexPage and Null if error

short GetPage(BSTR lpszPageName)

returns the index of the page with the name lpszPageName. If there is no page with this name it returns –1

void ActivatePage(short nIndexPage)

activates the page with the index nIndexPage

short InsertProperty(short nIndexPage, short nIndexProperty, BSTR lpszPropertyName, BSTR lpszPropertyAs, short lpszProperyType)

inserts a new property with name lpszPropertyName. In this case, lpszPropertyName cannot be in the path form. For the other parameters see the AddProperty method. If nIndexProperty is –1 it means that the adding will be done at the end of the page.

boolean DeleteProperty(short nIndexPage, short nIndexProperty)

deletes the property with the index nIndexProperty from nIndexPage page. Returns true if the deletion has done successfully

BSTR GetPropertyName(short nIndexPage, short nIndexProperty)

returns the name of property from nIndexPage page, at nIndexProperty position or Null if no property is found.

short GetPropertyType(short nIndexPage, short nIndexProperty)

f the property from page nIndexPage at nIndexProperty position is enable, the function will return 0. Else, the returned values will be 1 or 2. 1 for grayed property and 2 for black property

void SetPropertyType(short nIndexPage, short nIndexProperty, short nNewType)

enables or disables the property from nIndexPage page at nIndexProperty position

BSTR GetPropertyAs(short nIndexPage, short nIndexProperty)

returns one of the following values: "Edit", "CombBox", "BoolComboBox" etc

boolean IsProperty(short nIndexPage, short nIndexProperty)

returns True is property nIndexProperty exists in nIndexPage page

long GetIDListCtrl(short nIndexPage)

Return the identifier associated with the contained list control of page index nIndexPage.

short GetActivePage()

returns the index of active page. If no page is active then it returns –1

IUnknown* GetxFloorWnd()

Return pointer to interface to contained xFloorWnd Control

boolean GetDefaultValue(short nIndexPage, short nIndexProperty, BSTR* sPropertyValue)

gets the value of nIndexProperty from nIndexPage page into the sPropertyValue. It returns true if the asked property exists

boolean SetDefaultValue(short nIndexPage, short nIndexProperty, BSTR lpszDefaultvalue)

sets the value of property nIndexProperty from nIndexPage page to the lpszDefaultvalue

short GetPropertyCount(short nIndexPage)

returns the number of properties from page nIndexPage

void SetPropertyName(short nIndexPage, short nIndexProperty, BSTR lpszProperyName)

renames the property with the index nIndexProperty from nIndexPage page

boolean GetPropertyIndex(BSTR lpszPropertyName, short* nIndexPage, short* nIndexProperty)

returns true if exists property lpszPropertyName. In nIndexPage will be the index of page and in nIndexProperty will be the position of property lpszPropertyName

boolean SetDefaultValueByName(BSTR lpszPropertyName, BSTR lpszPropertyValue)

it does the same thing as the SetDefaultValue method just that the property is accessed by name

BSTR GetDefaultValueByName(BSTR lpszPropertyName)

returns the value of property lpszPropertyName, for example, "Page1\Item". If lpszPropertyName is not a valid property then the result is Null

short GetActiveProperty(short* nIndexPage)

returns the position of active property from active page. nIndexPage will contain the value of GetActivePage. If no property is active then it returns –1.

boolean SetActiveProperty(short nIndexPage, short IndexProperty)

activates the nIndexPage page and the nIndexProperty property. Returns true if everything was OK.

boolean SetActivePropertyByName(BSTR lpszPropertyName)

it does the same thing as the SetActiveProperty method just that the property is accessed by name

boolean DeletePropertyByName(BSTR lpszPropertyName)

deletes the property called lpszPropertyName. This lpszPropertyName can be in the path form such as : "Page1\Item"

short AddProperty(BSTR lpszPropertyName, BSTR lpszPropertyAs, short nPropertyType)

adds a new property called lpszPropertyName. LpszPropertyName can be something like this: "Page1\Item" which means that property "Item" will be added in the page "Page1" , if this page will be found.

lpszPropertyAs parameter can have one of the following values :

  • "Edit" property

  • "Button" property

  • "Link" for a link button. Same as button, Only picture is changed

  • "Return" for a return button. Same as button, Only picture is changed

  • "Font" property.

  • "BoolComboBox" for a combo with two valuse "True" and "False"

  • "ADORComboBox" for a multicolumn combobox who can store ADOR recordset.

  • "DataComboBox" for a data property.

  • "ComboBox" for a unboud combobox

  • "ShellFolder" for a property who can set a path.

  • "ColorComboBox" for a color property.

  • "Group" property

  • "NComboBox" property, based on Ncombo ActiveX Control

void Init()

Refresh the sizes of all windows attached to pages.

long ColumnKey(short nIndexPage, short nIndexProperty)

Return the column key for a ADORComboBox property.

void ColumnKey(short nIndexPage, short nIndexProperty, long nNewValue)

This method will specify which column from the dropdown you want to have as the value of property. This column has to be specified by index. Only in ADORComboBox

long ColumnWidth(short nIndexPage, short nIndexProperty, long nColumn)

Gives the width of a column. Only in ADORComboBox

void ColumnWidth(short nIndexPage, short nIndexProperty, long nColumn, long nNewValue)

Set the width of one column. This is useful when you want to hide some columns. To hide a column you’ll set the ColumnWidth to 0 Only in ADORComboBox

BSTR ColumnName(short nIndexPage, short nIndexProperty, short nColumn)

Gets the name of a column. Only in ADORComboBox

void ColumnName(short nIndexPage, short nIndexProperty, short nColumn, BSTR lpszNewValue)

Sets the name of a column. Only in ADORComboBox

boolean ColumnHeader(short nIndexPage, short nIndexProperty)

Return TRUE if the column header of ADORComboBox property is visible or not.

Void ColumnHeader(short nIndexPage, short nIndexProperty, boolean bNewValue)

Shows/Hides the column header of ADORComboBox property

double DropDownWidth(short nIndexPage, short nIndexProperty)

Gets the width of the dropdown. Only in ADORComboBox property

void DropDownWidth(short nIndexPage, short nIndexProperty, double newValue)

Sets the width of the dropdown. Only in ADORComboBox property

long DropDownHeight(short nIndexPage, short nIndexProperty)

Return the number of rows that you want to see in dropdown corresponding to the property that has the nIndexProperty index. Only for ADORComboBox property

void DropDownHeight(short nIndexPage, short nIndexProperty, long nNewValue)

sets the number of rows that you want to see in dropdown corresponding to the property that has the nIndexProperty index

void RefreshProperty(short nIndexPage, short nIndexProperty)

this is useful when you want to change the database source for an ADOR.Recordset associated with an ADORComboBox.

VARIANT GetValue(short nIndexPage, short nIndexProperty, long nColumn)

The same thing as GetDefaultValue, with some changes:

ADORComboBox – return the value (as variant) of field from column nColumn (the selected item from combo)

ColorComboBox – return the color as COLORREF from a ColorComboBox property.

Font – return IfontDisp* from a Font property, for nColumn == 0

Font – return COLORREF from a Font property (the color of font), for nColumn == 1

NComboBox – return the value from nColumn column, if nColumn exist, or item data if not (<0 as sample)

VARIANT GetValueByName(BSTR lpszPropertyName, long nColumn)

The same as GetValue, only that the accessing to property is gave by name.

BSTR ColumnKeyByName(short nIndexPage, short nIndexProperty)

Return the name of column key for a ADORComboBox property

void ColumnKeyByName(short nIndexPage, short nIndexProperty, BSTR lpszNewValue)

Set the new column key for a ADORComboBox property, by name

void SetValue(short nIndexPage, short nIndexProperty, VARIANT vValue, short nColumn)

ColorComboBox – Set the new color of a ColorComboBox property

Font – Set a new font (IfontDisp*) for Font property, if nColumn == 0

Font – Set a new color font (COLORREF) for Font property, if nColumn == 1

IDispatch* GetNComboObject(long nIndexPage, long nIndexProperty)

Version 1.07

Return the NCombo ActiveX Control dispinterface associatted with property nIndexPage, nIndexProperty

Events:

Name

Specification

void SelectItem(short nIndexPage, short nIndexItem)

Occurs when property (nIndexPage, nIndexItem) was selected.

void SelectPage(short nIndex)

Occurs when page nIndex was activated

void UnselectItem(short nIndexPage, short nIndexItem)

Occurs when property (nIndexPage, nIndexItem) was unselected

void PropertyChanging(short nIndexPage, short nIndexProperty)

Occurs before property (nIndexPage, nIndexItem) to be changed

void PropertyChanged(short nIndexPage, short nIndexProperty, boolean bUpdate)

Occurs after property (nIndexPage, nIndexItem) was changed. BUpdate is TRUE if value was changed or not

void ButtonClick(short nIndexPage, short nIndexProperty)

Occurs when user click into Button property. Only for: Button, Link, Return properties

void LoadItems(short nIndexPage, short nIndexProperty, BSTR* lpszItems)

before editing a combobox, this needs to be filled with items. For example if you want to have in the combobox the following items "Item1, Item2, Item3" in the property with the page index nIndexPage and property index nIndexProperty, the lpszItems has to be like this : lpszItems = "Item1\Item2\Item3". Only for ComboBox

void SetObject(long nIndexPage, long nIndexProperty, IDispatch** pObject)

the pObject parameter is the object that will contain the ADOR.Recordset object corresponding to the property that has nIndexProperty index.. This event is raised before the loading of the items of the control. It is also raised when you change the name of a column. Only for ADORComboBox.

void Delete(short nIndexPage, short nIndexProperty)

Occurs when user press VK_DELETE into property (nIndexPage, nIndexItem).

Notices:

  • all BSTR returned by any functions (methods), in VC, need to be releases with ::SysFreeString

  • one property can be represents either: name or position (nIndexPage, nIndexItem)

Download source - 239 KB



Comments

  • XPropertieWnd for VB6

    Posted by Legacy on 12/25/2003 12:00am

    Originally posted by: Loco

    Hey man, I can't add the component to a VB6 app, somebody can help me? Does it work in VB6? Help!!!!!!!
    Please!
    Thank you all!
    []'s

    Reply
  • Could anybody tell me how to retrive properties from MSFlexGridControl at runtime.

    Posted by Legacy on 01/24/2002 12:00am

    Originally posted by: James

    Could anybody tell me how to retrive properties from MSFlexGridControl at runtime.

    Reply
  • Unicode, Gray screen,... - Sulotion

    Posted by Legacy on 07/12/1999 12:00am

    Originally posted by: Eitan Pilipski

    Add the _AFXDLL in the Prop, Floor projects settings

    Reply
  • Why the control works only in unicode compilation

    Posted by Legacy on 07/09/1999 12:00am

    Originally posted by: Alex Spivak

    I noticed that the control works properly only when compiled in unicode. That means it will only work on NT.
    Any solutions to that?

    Reply
  • Why the floor control is gray ?

    Posted by Legacy on 07/07/1999 12:00am

    Originally posted by: Eitan Pilipski


    The problem was that in Windows 95/98 the control is gray.

    In function :

    BOOL CXFloorWndCtrl::_AttachWindow(short nIndex, long pWnd)
    {
    CWnd* pWndClient = (CWnd*)pWnd;
    if (pWndClient)
    if (::IsWindow(pWndClient->m_hWnd))
    if (CFloorPageObject* pPage =GetPage(nIndex))
    {
    pPage->Attach(pWndClient);
    return TRUE;
    }
    return FALSE;
    }


    IsWindow(pWndClient->m_hWnd) returns false
    Why ?

    Reply
  • a little problem with the colors

    Posted by Legacy on 03/29/1999 12:00am

    Originally posted by: demirdjian

     Great job mister Filimon but i ve a little problem using the color combobox : I can't use custom colors.
    
    I m not easy with VC++ so if u see a solution you d be nice to message me
    Regards

    Nicolas DEMIRDJIAN

    Reply
  • Pb with deletePage or DeleteProperty

    Posted by Legacy on 02/23/1999 12:00am

    Originally posted by: ZEGDOUN

    Great job, but I see a little problem when deleting a Page or deleting a Property that uses a
    "DataCombobox" or "Font" style (ie, any ControlWnd that will not be deleted but just
    hidden in their virtual Delete() method)
    
    

    In fact : as these controls are not really deleted, when you use the same item index with a new property (for example an "Edit" where you had a "DataComboBox") the old control still hang the SetValue and lock the new property.

    To solve this, I add this code in the DeletePage method of XPropertiesWndCtrl method :

    BOOL CXPropertiesWndCtrl::_DeletePage(short nIndexPage)
    {
    ResetMAPFound();

    // BEGIN modification
    if (m_xFloorWnd.IsPage(nIndexPage))
    if (CPageListCtrl* pListCtrl = m_xFloorWnd.GetListCtrl(nIndexPage))
    {
    int nCount = pListCtrl->GetItemCount();
    for (int j = 0; j < nCount; j++ )
    {
    CControlsWnd* pControl = NULL;
    if (TMapIdx2Ctrl* pMap = CControlsWnd::LookupPage(pListCtrl))
    if (pMap->Lookup(j, pControl))
    if (AfxIsValidAddress(*(void**)pControl, sizeof(void*), FALSE))
    // really delete the control and clean the map
    pControl->Kill();
    }
    pListCtrl->DeleteAllItems();
    }
    // END modification

    return m_xFloorWnd.DeletePage(nIndexPage);
    }

    Some work need to be done to make DeleteProperty safe also. (Sorry, I was a bit short in time to do it since I remove the whole page/ add a new one before inserting my new properties.

    I hope I didn't miss something important by using the control ;-))
    Let me know...
    Regards.
    OZ

    Reply
  • XPropertiesWnd : need help

    Posted by Legacy on 01/21/1999 12:00am

    Originally posted by: Kebir

    Could someone help ?

    When linking XPropertiesWnd, I have unresolved externals :

    COleControl::FireEvent(...).

    I'm using Visual C++ 5.

    Thanx,


    Kebir

    Reply
  • Great stuff, and a very small improvement

    Posted by Legacy on 01/19/1999 12:00am

    Originally posted by: Philippe Drapeau

        Very impressive work Mr. Filimon, your tools 
    
    are just great.

    I've found a very minor problem with the "CDropListBox"
    that didn't allow me to 'cancel' a selection, once a drop-down
    selection list was opened for an item (for a ComboBox or BoolComboBox for example). It essentially had to do with the fact that the "CDropListBox::Close" function didn't check if a cancel
    operation was performed instead of a selection. Here are
    the 2 functions that I modified to correct this.

    // Function name : CDropListBox::OnKeyDown
    // Description :
    // Return type : void
    // Argument : UINT nChar
    // Argument : UINT nRepCnt
    // Argument : UINT nFlags
    void CDropListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
    {
    switch (nChar)
    {
    case VK_RETURN:
    case VK_ESCAPE: // Added this
    case VK_CANCEL:
    {
    Close(nChar == VK_CANCEL || nChar == VK_ESCAPE);
    return;
    }
    }

    CListBox::OnKeyDown(nChar, nRepCnt, nFlags);

    SelChange();
    }

    // Function name : CDropListBox::Close
    // Description :
    // Return type : void
    // Argument : BOOL bCancel
    void CDropListBox::Close(BOOL bCancel)
    {
    m_bCancel = bCancel;


    if (!bCancel) // Added this
    SelChange();
    // m_nSelectedItem este valid doar daca m_bCancel = FALSE;
    if (m_pNotifyClass)
    m_pNotifyClass->Close(m_bCancel);
    }

    Reply
  • Does this compile under Visual Studio 5.0?

    Posted by Legacy on 01/15/1999 12:00am

    Originally posted by: Rudla Kudla

    I have troubles to compile this project under Visual Studio 5.0.
    
    

    This is what i receive for XFloorWnd project, and same error is reported for this project.

    --------------------Configuration: XFloorWnd - Win32 Debug--------------------
    Creating Type Library...
    command line error MIDL1012 : argument illegal for switch / /o
    command line warning MIDL1009 : unknown argument ignored "D:\Home\Rudla\Projects\Controls\XFloorWnd\XFloorWnd.odl"
    Processing .\NUL
    NUL
    .\NUL(2) : error MIDL2183 : unexpected end of file found
    Error executing midl.exe.

    XFloorWnd.ocx - 2 error(s), 1 warning(s)


    However, playing with project settings, a was able to eliminate this this error.

    But it also seems, I miss include file "afxdtctl.h". I suspect this to be part of MFC classes, but I didn't found it on my system. Where can I get this file?

    Thanks, Rudla

    Reply
  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds