mfc - When panel collapsed, getting rect of button no longer works -
i've tried in several ways. deriving object cbcgpribbonbutton (same cmfcribbonbutton) , using getrect() within class, , having click event find button in ribbon , rect.
what happens rect relative window in. if panel collapsed, window in not ribbon bar gets wrong location.
i need way of getting location relative ribbon bar. ideas?
ok, trying figure out rect button:

when panel had collapsed:

this solution:
class cmybutton : public cbcgpribbonbutton { declare_dyncreate(cheaderfooter) public: cmybutton() { }; cmybutton( uint nid, lpctstr lpsztext, int nsmallimageindex = -1, int nlargeimageindex = -1, bool balwaysshowdescription = false) : cbcgpribbonbutton(nid, lpsztext, nsmallimageindex, nlargeimageindex, balwaysshowdescription) { } bool hasmenu() const override { return true; } cwnd* getbuttonwnd() const { cbcgpbaseribbonelement* pdroppeddown = m_pparent->getdroppeddown(); cwnd* pwnd; if (pdroppeddown) // popup opened collapsed panel ribbon? { pwnd = pdroppeddown->getpopupmenu()->getmenubar(); } else { pwnd = m_pparent->getparentribbonbar(); } return pwnd; } void onshowpopupmenu() override { crect rect = getrect(); // pt bottom left corner of button relative window // contained in. cpoint pt(rect.left, rect.bottom); getbuttonwnd()->clienttoscreen(&pt); // convert pt screen coordinates ... // other stuff point } }; implement_dyncreate(cheaderfooter, cbcgpribbonbutton) which determines cwnd button part of rect can converted correctly screen coordinates.
Comments
Post a Comment