Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Drop down button in header cell Collapse All
Subject Author Date
Bart Kampers Nov 16, 2009 - 3:31 AM


I created my own row header cell having a button to popup a menu. The code below works fine. But when I change the button type to __EGCS_BUTTON_DROPDOWN the menu is not shown anymore. Instead I see a small rectangle.

How should I implement my header cell if I want to  use the __EGCS_BUTTON_DROPDOWN type?

Thanks in advance,



CClassRowHeader::CClassRowHeader(CExtGridDataProvider* pDataProvider)

: CExtGridCellHeader(pDataProvider)




void CClassRowHeader::OnButtonPressed(

 CExtGridWnd & wndGrid,

 INT nButtonType,

 const RECT & rcCellExtra,

 const RECT & rcCell,

 LONG nVisibleColNo,

 LONG nVisibleRowNo,

 LONG nColNo,

 LONG nRowNo,

 INT nColType,

 INT nRowType)


  CExtPopupMenuWnd* menu = new CExtPopupMenuWnd;


  menu->ItemInsertCommand(WM_GRADING_TABLE_INSERT_ROW_BEFORE, -1, LANGUAGE_GET_CAT("InsertRowBefore"));

  menu->ItemInsertCommand(WM_GRADING_TABLE_INSERT_ROW_AFTER, -1, LANGUAGE_GET_CAT("InsertRowAfter"));

  menu->ItemInsertCommand(WM_GRADING_TABLE_DELETE_ROW, -1, LANGUAGE_GET_CAT("DeleteRow"));

  menu->ItemInsertCommand(WM_GRADING_TABLE_CLEAR_ROW, -1, LANGUAGE_GET_CAT("ClearRow"));

  CRect cellRect(rcCell);


  CRect rcExclude(cellRect.left, cellRect.bottom, cellRect.left + 3, cellRect.bottom + 3);

  if (! menu->TrackPopupMenu(TPMX_LEFTALIGN, cellRect.left, cellRect.bottom, &rcExclude))



    delete menu;

    menu = NULL;


  __super::OnButtonPressed(wndGrid, nButtonType, rcCellExtra, rcCell, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType);


Bart Kampers Nov 18, 2009 - 1:39 AM

- Your changes draw the menu on some other place when I use the __EGCS_BUTTON_ELLIPSIS style

- When I use the __EGCS_BUTTON_DROPDOWN style I still see a small rectangle in stead of the menu

- I do not analyze which button is pressed since I know that there is only one button in the cell.



Technical Support Nov 16, 2009 - 1:45 PM

First of all, the menu->DestroyWindow(); line of code should be removed. Second, the exclude area rectangle should use the screen coordinate system. The rcCell and rcCellExtra rectangles are using grid window client coordinate system. You should invoke the wndGrid.ClientToScreen( &rcExclude ); line of code. Third, the point coordinates are also should be in screen coordinate system and it should be inside exclude rectangle. This means the following part of your code snippet:

   CRect rcExclude( cellRect.left, cellRect.bottom, cellRect.left + 3, cellRect.bottom + 3 ) ;
            if( ! menu->TrackPopupMenu( TPMX_LEFTALIGN, cellRect.left, cellRect.bottom, &rcExclude ) )
                        delete menu;
                        menu = NULL;

Should be replaced with the following:
   CRect rcExclude = rcCell;
            m_wndGrid.ClientToScreen( &rcExclude );
            CPoint pt =  rcExclude.CenterPoint();
            if( ! menu->TrackPopupMenu( TPMX_LEFTALIGN, pt.x, pt.y, &rcExclude ) )
                        delete menu;
                        menu = NULL;

Fourth, if you are handling the button pressing event, then you should not invoke the parent class method. Fifth, your code does not analyze which button is clicked. It will work correctly only if your header cell uses only one button.

Bart Kampers Nov 18, 2009 - 3:16 AM

I removed the parent’s call for OnButtonPressed. Not it works OK.