Customize a toolbar in win32
-
Anyone familiar with the TB_CUSTOMIZE message? I'm looking for an example in Win32 C++ code. Thanks in advance, Ward
LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
static UINT i=0;
LPNMHDR lpnmhdr;lpnmhdr = (LPNMHDR)lparam; // The following code allows the toolbar to be customized. // If you return FALSE the Customize Toolbar dialog flashes // and goes away. if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code == TBN\_QUERYDELETE) { return TRUE; } if (lpnmhdr->code == TBN\_GETBUTTONINFO) { LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam; char szBuffer \[20\]; // 20 = total number of buttons. // tbButton and tbButtonNew send information about // the other 12 buttons in tbButtonNew. if (lpTbNotify->iItem < 12) { lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\]; LoadString(hInst, 4000+ lpTbNotify->iItem, szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\])); hr = StringCchCopy (lpTbNotify->pszText, sizeof(lpTbNotify->pszText) /sizeof(lpTbNotify->pszText\[0\]), szBuffer ); if(SUCEEDED(hr)) { lpTbNotify->cchText = sizeof(szBuffer)/sizeof(szBuffer\[0\]); } else { TODO: Write error handler. } return TRUE; } else return 0; } return 0;
}
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
static UINT i=0;
LPNMHDR lpnmhdr;lpnmhdr = (LPNMHDR)lparam; // The following code allows the toolbar to be customized. // If you return FALSE the Customize Toolbar dialog flashes // and goes away. if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code == TBN\_QUERYDELETE) { return TRUE; } if (lpnmhdr->code == TBN\_GETBUTTONINFO) { LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam; char szBuffer \[20\]; // 20 = total number of buttons. // tbButton and tbButtonNew send information about // the other 12 buttons in tbButtonNew. if (lpTbNotify->iItem < 12) { lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\]; LoadString(hInst, 4000+ lpTbNotify->iItem, szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\])); hr = StringCchCopy (lpTbNotify->pszText, sizeof(lpTbNotify->pszText) /sizeof(lpTbNotify->pszText\[0\]), szBuffer ); if(SUCEEDED(hr)) { lpTbNotify->cchText = sizeof(szBuffer)/sizeof(szBuffer\[0\]); } else { TODO: Write error handler. } return TRUE; } else return 0; } return 0;
}
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
LRESULT MsgNotify(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
static UINT i=0;
LPNMHDR lpnmhdr;lpnmhdr = (LPNMHDR)lparam; // The following code allows the toolbar to be customized. // If you return FALSE the Customize Toolbar dialog flashes // and goes away. if (lpnmhdr->code == TBN\_QUERYINSERT || lpnmhdr->code == TBN\_QUERYDELETE) { return TRUE; } if (lpnmhdr->code == TBN\_GETBUTTONINFO) { LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam; char szBuffer \[20\]; // 20 = total number of buttons. // tbButton and tbButtonNew send information about // the other 12 buttons in tbButtonNew. if (lpTbNotify->iItem < 12) { lpTbNotify->tbButton = tbButtonNew\[lpTbNotify->iItem\]; LoadString(hInst, 4000+ lpTbNotify->iItem, szBuffer, sizeof(szBuffer)/sizeof(szBuffer\[0\])); hr = StringCchCopy (lpTbNotify->pszText, sizeof(lpTbNotify->pszText) /sizeof(lpTbNotify->pszText\[0\]), szBuffer ); if(SUCEEDED(hr)) { lpTbNotify->cchText = sizeof(szBuffer)/sizeof(szBuffer\[0\]); } else { TODO: Write error handler. } return TRUE; } else return 0; } return 0;
}
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
Where is TB_CUSTOMIZE event used or processed here?
-Prakash
-
Anyone familiar with the TB_CUSTOMIZE message? I'm looking for an example in Win32 C++ code. Thanks in advance, Ward
This is what i got after doing a brif search in google hope its useful TB_CUSTOMIZE ------------- Display the Customize dialog for a toolbar The standard windows customization dialog for toolbars can be displayed by sending the toolbar the TB_CUSTOMIZE message. SendMessage(hwndToolbar, TB_CUSTOMIZE, 0, 0); You must remember to handle the TBN_QUERYDELETE and TBN_QUERYINSERT notifications, and return non-zero for both of these. Without them, the customize dialog will appear very briefly and then vanish.
-Prakash
-
This was what I already found myself on the msdn site. But it is not a very complete example, is it? It is somewhat the only example I was able to find on the Internet. But thanks anyway, Ward
Yeah it is complete with the one that I didn't paste. Search in MSDN documentation for the other one. The search is titled "Using toolbar controls". It has got a comprehensive coverage of what you want. I just pasted the interesting(for me) part.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord
-
Where is TB_CUSTOMIZE event used or processed here?
-Prakash
-
This is what i got after doing a brif search in google hope its useful TB_CUSTOMIZE ------------- Display the Customize dialog for a toolbar The standard windows customization dialog for toolbars can be displayed by sending the toolbar the TB_CUSTOMIZE message. SendMessage(hwndToolbar, TB_CUSTOMIZE, 0, 0); You must remember to handle the TBN_QUERYDELETE and TBN_QUERYINSERT notifications, and return non-zero for both of these. Without them, the customize dialog will appear very briefly and then vanish.
-Prakash
-
Yeah it is complete with the one that I didn't paste. Search in MSDN documentation for the other one. The search is titled "Using toolbar controls". It has got a comprehensive coverage of what you want. I just pasted the interesting(for me) part.
Love Forgives--Love Gives--Jesus is Love :)
--Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord