Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - No notification message from custom button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

No notification message from custom button

 Post Reply Post Reply
Author
Message
floydzhang View Drop Down
Groupie
Groupie


Joined: 08 March 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote floydzhang Quote  Post ReplyReply Direct Link To This Post Topic: No notification message from custom button
    Posted: 10 March 2008 at 3:54am
Hi,
 
I met a strange problem with XTP 11.2.1. I inserted a propertygrid on a pane, and I also created a CXTListCtrl on that pane. I could catch the notification message through OnGridNotify() when I clicked the standard grid items. Then I inserted some custom button as grid item into the propertygrid(same as GridSample) , but I couldn't catch the notification message through OnGridNotify() when I clicked custom button.
 
What's the problem...?
 
some of my code:
 
BEGIN_MESSAGE_MAP(CPropertiesPane, CWnd)
     ......
     ON_MESSAGE(XTPWM_PROPERTYGRID_NOTIFY, OnGirdNotify)
END_MESSAGE_MAP()
 
LRESULT CPropertiesPane::OnGirdNotify(WPARAM wParam, LPARAM lParam)
{
     int nGridAction = (int)wParam;
     .....
}
 
int CPropertiesPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CWnd::OnCreate(lpCreateStruct) == -1)
       return -1;
  
    ......
    if (m_wndPropertyGridPart.GetSafeHwnd() == 0)
    {
        m_wndPropertyGridPart.Create(CRect(0, 0, 0, 0), this, 0xf0);
        m_wndPropertyGridPart.SetOwner(this);
        m_wndPropertyGridPart.SetTheme(xtpGridThemeDefault);
        m_wndPropertyGridPart.ShowHelp(FALSE);
    .....
}
 
Regards
Boyang
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2008 at 4:26am
Hi,
Why standard buttons have to send messages to OnGridNotify??? They send them to its parent.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
floydzhang View Drop Down
Groupie
Groupie


Joined: 08 March 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote floydzhang Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2008 at 7:29am
Hi, Oleg,
 
Thank you for your reply. Actually, they are not standard buttons. These custom buttons are propertygrid items derived from CTXPropertyGridItem. I copied this class from GridSample shipped with XTP. This class is defined as below:
 
class CCustomItemButton : public CXTPPropertyGridItem
{
protected:
public:
 CCustomItemButton(CString strCaption, BOOL bFullRowButton, BOOL bValue);
 BOOL GetBool();
 void SetBool(BOOL bValue);
protected:
 virtual BOOL IsValueChanged();
 virtual void SetVisible(BOOL bVisible);
 BOOL OnDrawItemValue(CDC& dc, CRect rcValue);
 virtual void OnIndexChanged();
 void CreateButton();

private:
 CInplaceButton m_wndButton;
 BOOL m_bValue;
 CFont m_wndFont;
 CString m_strButtonText;
 BOOL m_bFullRowButton;
 friend class CInplaceButton;
};

 
I created this grid items as following code:
 
CXTPPropertyGridItem* pCustomItem = m_wndPropertyGridPart.AddCategory(_T("Test Button"));
   pCustomItem->AddChildItem(new CCustomItemButton(_T("Update"), TRUE, TRUE));
 
But GridSample hasn't this kind of problem, it can catch notify message when the button grid item is clicked through OnGirdNotify(). I do the same as GridSample, but I can get the same result.
 
By the way, I update these grid items dynamically. This mean I will remove or add some items according to some rules. I use a function UpdateGrid() located in CMainFarme to do this (update grid items).
 
Regards
Boyang
Back to Top
floydzhang View Drop Down
Groupie
Groupie


Joined: 08 March 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote floydzhang Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2008 at 4:26am
Anyone can help me?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2008 at 4:45am
See code in sample:
 
BEGIN_MESSAGE_MAP(CInplaceButton, CXTButton)
 ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
 ON_WM_SETCURSOR()
END_MESSAGE_MAP()
void CInplaceButton::OnClicked()
{
 m_pItem->m_bValue = !m_pItem->m_bValue;
 m_pItem->OnValueChanged(m_pItem->GetValue());
 
 SetChecked(m_pItem->m_bValue);
}
check that you have same.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
floydzhang View Drop Down
Groupie
Groupie


Joined: 08 March 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote floydzhang Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2008 at 7:51am
I copied the customitems.h and customitems.cpp to my project from sample, but it didn't work.
Back to Top
floydzhang View Drop Down
Groupie
Groupie


Joined: 08 March 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote floydzhang Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2008 at 2:45am
Originally posted by oleg oleg wrote:

See code in sample:
 
BEGIN_MESSAGE_MAP(CInplaceButton, CXTButton)
 ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
 ON_WM_SETCURSOR()
END_MESSAGE_MAP()
void CInplaceButton::OnClicked()
{
 m_pItem->m_bValue = !m_pItem->m_bValue;
 m_pItem->OnValueChanged(m_pItem->GetValue());
 
 SetChecked(m_pItem->m_bValue);
}
check that you have same.
 
Hi, Oleg,
 
Thank you for your information. The probelm has been fixed. Because one line was commented by a guy. Haha. Thank you and sorry.
 
Regards
Boyang
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.