Ticket A221
Visible to All Users

How to Determine a dxBarButton That Calls the Dropdown Popup Menu

created 21 years ago

Description:
How to Determine a dxBarButton That Calls the Dropdown Popup Menu

Answer:
In some instances, the same dxBarPopupMenu, can be used as a dropdown menu by several dxBarButtons (with ButtonStyle = bsDropDown) simultaneously. Below is a sample TdxBarPopupMenu.OnPopup event handler that allows you to determine a button that calls the menu.

Delphi
// Delphi code type TDummyBarControl = class(TCustomdxBarControl); procedure TYourForm.YourdxBarPopupMenuPopup(Sender: TObject); var BC: TCustomdxBarControl; BI: TdxBarItem; begin BC := ActiveBarControl; if (BC <> nil) and (TmyBarControl(BC).SelectedItem <> nil) then begin BI := TmyBarControl(BC).SelectedItem.Item; // do something with BI ... end; end;
Code
// C++Builder code void __fastcall TfrmMain::dxBarPopupMenuPopup(TObject *Sender) { class TmyBarControl : public TCustomdxBarControl { protected: TdxBarItemControl* __fastcall GetDummySelectedItem() { return SelectedItem; }; public: __property TdxBarItemControl* DummySelectedItem = {read=GetDummySelectedItem}; }; TCustomdxBarControl* BC = ActiveBarControl(); if ( (BC != NULL) && (((TmyBarControl*)BC)->DummySelectedItem != NULL) ) { TdxBarItem* BI = ((TmyBarControl*)BC)->DummySelectedItem->Item; // do something with BI ... } }
Show previous comments (1)
DevExpress Support Team 12 years ago

    Hello Dmitri,
    In latest versions of our controls you can use the SelectedLink object instead:

    Code
    void __fastcall TfrmMain::dxBarPopupMenuPopup(TObject *Sender) { class TmyBarControl : public TCustomdxBarControl { protected: TdxBarItemLink* __fastcall GetDummySelectedItem() { return SelectedLink; }; public: __property TdxBarItemLink* DummySelectedItem = {read=GetDummySelectedItem}; }; TCustomdxBarControl* BC = ActiveBarControl(); if ( (BC != NULL) && (((TmyBarControl*)BC)->DummySelectedItem != NULL) ) { TdxBarItem* BI = ((TmyBarControl*)BC)->DummySelectedItem->Item; Caption = BI->CurItemLink->Caption; } }

      Thank you this code works properly.

      DevExpress Support Team 12 years ago

        You are always welcome.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.