muqawem

Hello,

I have devloped a toolbar for IE based on this article
http://www.codeproject.com/wtl/toolband.asp

my toolbar contains 6 buttons which have only icons ( no captions ) and an edit control. This is a sanpshot of CreateSimpleToolBarCtrl function which is the main function of the toolbar.

m_nResourceID = nResourceID;
m_bInitialSeparator = bInitialSeparator;
HINSTANCE hInst = _Module.GetResourceInstance();
HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(nResourceID), RT_TOOLBAR);
if (hRsrc == NULL)
return NULL;

HGLOBAL hGlobal = ::LoadResource(hInst, hRsrc);
if (hGlobal == NULL)
return NULL;

_AtlToolBarData* pData = (_AtlToolBarData*)::LockResource(hGlobal);
if (pData == NULL)
return NULL;
ATLASSERT(pData->wVersion == 1);

WORD* pItems = pData->items();
int nItems = pData->wItemCount + (bInitialSeparator 1 : 0);
TBBUTTON* pTBBtn = (TBBUTTON*)_alloca(nItems * sizeof(TBBUTTON));

// set initial separator (half width)
if(bInitialSeparator)
{
pTBBtn[0].iBitmap = 4;
pTBBtn[0].idCommand = 0;
pTBBtn[0].fsState = 0;
pTBBtn[0].fsStyle = TBSTYLE_SEP;
pTBBtn[0].dwData = 0;
pTBBtn[0].iString = 0;
}

int nBmp = 0;
for(int i = 0, j = bInitialSeparator 1 : 0; i < pData->wItemCount; i++, j++)
{
if(pItemsIdea != 0)
{
pTBBtn[j].idCommand = pItemsIdea;

switch(i)
{
case EXACT_SEARCH_BUTTON:
pTBBtn[j].iBitmap = 0;
break;
case SEARCH_BUTTON:
pTBBtn[j].iBitmap = 1;
break;
case LOGIN_BUTTON:
pTBBtn[j].iBitmap = 2;
break;
case SEND_SMS__BUTTON:
pTBBtn[j].iBitmap = 3;
break;
case UPLOAD_BUTTON:
pTBBtn[j].iBitmap = 4;
break;
default:
pTBBtn[j].iBitmap = 0;
}

pTBBtn[j].fsState = TBSTATE_ENABLED;
pTBBtn[j].fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE ;
pTBBtn[j].dwData = 0;
pTBBtn[j].iString = -1;

}
else
{
pTBBtn[j].iBitmap = 8;
pTBBtn[j].idCommand = 0;
pTBBtn[j].fsState = 0;
pTBBtn[j].fsStyle = TBSTYLE_SEP;
pTBBtn[j].dwData = 0;
pTBBtn[j].iString = 0;
}
}


Now I have to insert a new button that have caption without an image to the toolbar at the runtim, but every time I try, the toolbar buttons disappeared. However when I add a new button with an image and no text every thing works fine.

void CBandToolBarCtrl::AddInboxButton()
{
char MyButtonText[]="My Button\0\0";

TBBUTTON pTBBtn;

pTBBtn.iBitmap = I_IMAGENONE;
pTBBtn.idCommand = ID_BUTTON_INBOX;
pTBBtn.fsState = TBSTATE_ENABLED ;
pTBBtn.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT;
pTBBtn.dwData = 0;
pTBBtn.iString = SendMessage(m_hWnd,TB_ADDSTRING,NULL,(long)&MyButtonText);;

SendMessage(m_hWnd, TB_INSERTBUTTON, (INBOX_BUTTON, (LPARAM)&pTBBtn);

}

I need help to get this done. I will appreciate any suggestions.

Thanks in advanced


Re: Internet Explorer Extension Development Insert New Button to my IE Toolbar

muqawem

Hello,

Can someone at least tell me if I am unclear or this issue is not solvable.