Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Toolbar protocol isn’t implemented
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Toolbar protocol isn’t implemented

 Post Reply Post Reply
Author
Message
Chilly32 View Drop Down
Newbie
Newbie


Joined: 03 July 2005
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chilly32 Quote  Post ReplyReply Direct Link To This Post Topic: Toolbar protocol isn’t implemented
    Posted: 03 July 2005 at 12:21pm

G’Day,

I have a question about tooltips support in your library.

Before we bought your library, we were using a tooltips component from www.tooltips.net, which provided very colourful and descriptive tooltips. We used it via Command ID-s for menus commands and toolbar commands.  That tooltip component supported both standard menu and toolbar classes and custom ones, I could call AddToolbarClass or AddMenuClass to recognize derived objects correctly. Now as I added XTP menus and toolbars – it all stopped working. It seems that not only you override toolbars and menus with your own classes, but you also do not implement corresponding protocols. For instance, all toolbar classes are supposed to implement such messages as TB_HITTEST and TB_GETBUTTON (see in MSDN).

Code example:

 

LPPOINT pt;

int iButtonIndex = ::SendMessage(hToolbarWnd, TB_HITTEST, 0, (long)pt);

TBBUTTON info;

::SendMessage(hToolbarWnd, TB_GETBUTTON, iButtonIndex, (long)&info);

 

Now, that code doesn’t work for your toolbars at all, and hence we cannot see any tooltips for that matter.

And since your library doesn’t offer anything like those tooltips, please advice us how we should get around this problem.

Thank you,



Edited by Chilly32
Back to Top
Chilly32 View Drop Down
Newbie
Newbie


Joined: 03 July 2005
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chilly32 Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2005 at 4:39am

To put it simply, your toolbars must implement TB_HITTEST and TB_GETBUTTON, or they become unusable for other components, i.e. cannot be recognized as toolbars, and hence cannot be integrated with other software bits. And if your menus are also toolbars - them too.

I think you must implement those, which shouldn't be a big deal for you, but would make a world of difference for us, as we are stuck now with this issue: too much effort has been put in documenting our software via those tooltips, and now they don't work.

 

 



Edited by Chilly32
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: 06 July 2005 at 1:44am

2005-07-06_014247_VXPMenus.zip

See attched sample how to use CommandBars and Tooltips

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Chilly32 View Drop Down
Newbie
Newbie


Joined: 03 July 2005
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chilly32 Quote  Post ReplyReply Direct Link To This Post Posted: 06 July 2005 at 5:27am

Thank you Oleg,

 

Before you published this example I got some reply from your tech support guys just suggesting to derive and implement my own CXTPToolbar class. So I did that yesterday, and actually managed to make it work for toolbar buttons. But when I tried the same for menu items – just didn’t work. Mistakenly, I derived from CXTPMenuBar instead of CXTPPopupBar. Your code example clarified all that, thank you. And since I had already my own class written for toolbars that worked, I simply applied the same for CXTPPopupBar – and oh miracle!!! I now can see tooltips for menu items, now that’s some hi-tech stuff J And it looks just amazing!!! Those VXPLib tooltips in combination with XTP library is kick-ass!!! I’m sending you a screenshot of what I got:

 

 

And for the menu items:

 

 

Now I would like to share the code I used for toolbars and menus, and which worked nicely for me:

 

class CXTPToolBarEx : public CXTPToolBar

{

DECLARE_XTP_COMMANDBAR(CXTPToolBarEx)

public:

CXTPToolBarEx();

virtual ~CXTPToolBarEx();

protected:

////////////////////////////////////////////////////////

// Toolbar messages:

//

afx_msg LRESULT OnHitTest(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnButtonCount(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnGetButton(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnGetButtonInfo(WPARAM wParam, LPARAM lParam);

DECLARE_MESSAGE_MAP()

static int GetControlState(CXTPControl * pControl);

};

class CXTPPopupBarEx : public CXTPPopupBar

{

DECLARE_XTP_COMMANDBAR(CXTPPopupBarEx)

public:

CXTPPopupBarEx();

virtual ~CXTPPopupBarEx();

protected:

////////////////////////////////////////////////////////

// Toolbar messages:

//

afx_msg LRESULT OnHitTest(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnButtonCount(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnGetButton(WPARAM wParam, LPARAM lParam);

afx_msg LRESULT OnGetButtonInfo(WPARAM wParam, LPARAM lParam);

DECLARE_MESSAGE_MAP()

static int GetControlState(CXTPControl * pControl);

};

 

 And implementation:

 

// CXTPToolBarEx

IMPLEMENT_XTP_COMMANDBAR(CXTPToolBarEx, CXTPToolBar)

CXTPToolBarEx::CXTPToolBarEx()

{

}

CXTPToolBarEx::~CXTPToolBarEx()

{

}

int CXTPToolBarEx::GetControlState(CXTPControl * pControl)

{

int iState = pControl->GetEnabled()?TBSTATE_ENABLED:0;

iState |= pControl->GetChecked()?TBSTATE_CHECKED:0;

iState |= (pControl->GetHideFlags()&xtpNoHide)?0:TBSTATE_HIDDEN ;

iState |= pControl->GetPressed()?TBSTATE_PRESSED:0;

iState |= pControl->GetWrap()?TBSTATE_WRAP:0;

return iState;

}

BEGIN_MESSAGE_MAP(CXTPToolBarEx, CXTPToolBar)

ON_MESSAGE(TB_HITTEST, OnHitTest)

ON_MESSAGE(TB_BUTTONCOUNT, OnButtonCount)

ON_MESSAGE(TB_GETBUTTON, OnGetButton)

ON_MESSAGE(TB_GETBUTTONINFO, OnGetButtonInfo)

END_MESSAGE_MAP()

// CXTPToolBarEx message handlers

LRESULT CXTPToolBarEx::OnHitTest(WPARAM wParam, LPARAM lParam)

{

LPPOINT lpPoint = (LPPOINT)lParam;

CXTPControl * pControl = GetControls()->HitTest(CPoint(lpPoint->x, lpPoint->y));

if(pControl)

return pControl->GetIndex();

return -1;

}

LRESULT CXTPToolBarEx::OnButtonCount(WPARAM wParam, LPARAM lParam)

{

return GetControls()->GetCount();

}

LRESULT CXTPToolBarEx::OnGetButton(WPARAM wParam, LPARAM lParam)

{

LPTBBUTTON lpButton = (LPTBBUTTON)lParam;

CXTPControl * pControl = GetControls()->GetAt((int)wParam);

if(!pControl)

return FALSE;

lpButton->iBitmap = pControl->GetIndex();

lpButton->idCommand = pControl->GetID();

lpButton->fsState = GetControlState(pControl);

lpButton->dwData = pControl->GetTag();

lpButton->iString = (INT_PTR)(LPCTSTR)pControl->GetCaption();

lpButton->fsStyle = 0; // Unsupported;

return TRUE;

}

LRESULT CXTPToolBarEx::OnGetButtonInfo(WPARAM wParam, LPARAM lParam)

{

LPTBBUTTONINFO lpInfo = (LPTBBUTTONINFO)lParam;

CXTPControl * pControl = GetControls()->FindControl(xtpControlButton, (int)wParam, FALSE, FALSE);

if(!pControl)

return -1;

if(lpInfo->dwMask & TBIF_STATE)

lpInfo->fsState = GetControlState(pControl);

return pControl->GetID();

}

//////////////////////////////////////////////////////////// /

// CXTPPopupBarEx

IMPLEMENT_XTP_COMMANDBAR(CXTPPopupBarEx, CXTPPopupBar)

CXTPPopupBarEx::CXTPPopupBarEx()

{

}

CXTPPopupBarEx::~CXTPPopupBarEx()

{

}

int CXTPPopupBarEx::GetControlState(CXTPControl * pControl)

{

int iState = pControl->GetEnabled()?TBSTATE_ENABLED:0;

iState |= pControl->GetChecked()?TBSTATE_CHECKED:0;

iState |= (pControl->GetHideFlags()&xtpNoHide)?0:TBSTATE_HIDDEN ;

iState |= pControl->GetPressed()?TBSTATE_PRESSED:0;

iState |= pControl->GetWrap()?TBSTATE_WRAP:0;

return iState;

}

BEGIN_MESSAGE_MAP(CXTPPopupBarEx, CXTPPopupBar)

ON_MESSAGE(TB_HITTEST, OnHitTest)

ON_MESSAGE(TB_BUTTONCOUNT, OnButtonCount)

ON_MESSAGE(TB_GETBUTTON, OnGetButton)

ON_MESSAGE(TB_GETBUTTONINFO, OnGetButtonInfo)

END_MESSAGE_MAP()

// CXTPPopupBarEx message handlers

LRESULT CXTPPopupBarEx::OnHitTest(WPARAM wParam, LPARAM lParam)

{

LPPOINT lpPoint = (LPPOINT)lParam;

CXTPControl * pControl = GetControls()->HitTest(CPoint(lpPoint->x, lpPoint->y));

if(pControl)

return pControl->GetIndex();

return -1;

}

LRESULT CXTPPopupBarEx::OnButtonCount(WPARAM wParam, LPARAM lParam)

{

return GetControls()->GetCount();

}

LRESULT CXTPPopupBarEx::OnGetButton(WPARAM wParam, LPARAM lParam)

{

LPTBBUTTON lpButton = (LPTBBUTTON)lParam;

CXTPControl * pControl = GetControls()->GetAt((int)wParam);

if(!pControl)

return FALSE;

lpButton->iBitmap = pControl->GetIndex();

lpButton->idCommand = pControl->GetID();

lpButton->fsState = GetControlState(pControl);

lpButton->dwData = pControl->GetTag();

lpButton->iString = (INT_PTR)(LPCTSTR)pControl->GetCaption();

lpButton->fsStyle = 0; // Unsupported;

return TRUE;

}

LRESULT CXTPPopupBarEx::OnGetButtonInfo(WPARAM wParam, LPARAM lParam)

{

LPTBBUTTONINFO lpInfo = (LPTBBUTTONINFO)lParam;

CXTPControl * pControl = GetControls()->FindControl(xtpControlButton, (int)wParam, FALSE, FALSE);

if(!pControl)

return -1;

if(lpInfo->dwMask & TBIF_STATE)

lpInfo->fsState = GetControlState(pControl);

return pControl->GetID();

}

 

I hope it will be just as useful to somebody else who decides to use custom tooltips like VXPLib in their projects

 

Regards,

Vitaly Tomilov

 

Back to Top
Chilly32 View Drop Down
Newbie
Newbie


Joined: 03 July 2005
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Chilly32 Quote  Post ReplyReply Direct Link To This Post Posted: 06 July 2005 at 5:40am

Oleg,

 

I have a related question for you…

You showed the following code to switch off the standard tooltips on start up:

pCommandBars->GetCommandBarsOptions()->bToolBarScreenT ips = FALSE;

This, however, doesn’t prevent the user from going into “Customize”, tab “Options” and switch the tooltips ON again.

Is there any way to override that behavour? For instance, disable that tooltip option, or override the event of switching that option so that I can switch ON/OFF my own tooltips, and not the standard tooltips?

Regards,

Vitaly Tomilov



Edited by Chilly32
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: 06 July 2005 at 11:45pm

Hi, glad you find solution for tooltips :)

I think in CMainFrame::OnCustomize before you call DoModal you can set

pCommandBars->GetCommandBarsOptions()->bToolBarScreenT ips = m_bToolBarScreenTips;

 

and after DoModal

 

m_bToolBarScreenTips = pCommandBars->GetCommandBarsOptions()->bToolBarScreenT ips;

pCommandBars->GetCommandBarsOptions()->bToolBarScreenT ips; = FALSE;

UpdateToolTips();

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.061 seconds.