Wrox Programmer Forums
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2004, 01:19 AM
Authorized User
 
Join Date: Jul 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default ToolBarControl help!!

Hi Guys,

Iam trying to put some bitmap images using a toolbarcontrol into a dialog.

I have done it as follows:


CRect toolbarSize(20,20,100,50);
m_toolBarCtrl.Create(WS_CHILD|TBSTYLE_FLAT,toolbar Size,this,IDR_TOOLBAR1);
m_toolBarCtrl.AddBitmap(1,IDB_BITMAP2);
m_toolBarCtrl.AddBitmap(1,IDB_BITMAP3);

TBBUTTON tb[3];

// Index of new button image.
tb[0].iBitmap = 0;
// Setting button state
tb[0].fsState = TBSTATE_ENABLED;
// Setting button style
tb[0].fsStyle = TBSTYLE_BUTTON;
tb[0].dwData = 0;
tb[0].iString = NULL;

// Index of new button image.
tb[1].iBitmap = 1;
//Setting button state
tb[1].fsState = TBSTATE_ENABLED;
// Setting button style
tb[1].fsStyle = TBSTYLE_BUTTON;
tb[1].dwData = 0;
tb[1].iString = NULL;


m_toolBarCtrl.AddButtons(2,tb);
m_toolBarCtrl.ShowWindow(true);



The problem is in both of my buttons,I see only 1 image(ie: the image in "bitmap2").What should I do to see the other bitmap image in the other button.

I have each images in 2 different files(So I imported it into the resource editor as 2 bitmaps -IDB_BITMAP2& IDB_BITMAP3)

If I want to have my images in one bitmapResource(if thats the problem),What should I do ?

Mind that I have each image, which I want to displaye as .bmp file.(one image in 1 .bmp file).

Another thing is How can I see a tooltip for each button in the above code...

Any help is appreciated.....

Thanks.....



 
Old October 5th, 2004, 03:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

All you need to do is combine both the images and call AddBitmap only once.
 
Old October 5th, 2004, 04:06 AM
Authorized User
 
Join Date: Jul 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How Can I combine both these images(Is there a tool).As I told u I have these 2 images in seperate .bmp files....

 
Old October 5th, 2004, 06:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

There are many. Paint Brush, VC++ Resource editor etc.
 
Old October 5th, 2004, 07:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

For the Tool Tips create you toolbarctrl with TBSTYLE_TOOLTIPS style like this

m_toolBarCtrl.Create(WS_CHILD|TBSTYLE_TOOLTIPS,too lbarSize,this,0);

Then add a handler for TTN_NEEDTEXTA message.
Do it by adding this

ON_NOTIFY_EX( TTN_NEEDTEXTA, 0, ToolTipsHandler)

to your Dialog's Message MAPlike this

BEGIN_MESSAGE_MAP(CToolBarProbDlg, CDialog)
    ON_NOTIFY_EX( TTN_NEEDTEXTA, 0, ToolTipsHandler)
    ON_BN_CLICKED(IDC_CALL_IT, OnCallIt)
.
.
.

Add the Handler function

BOOL CToolBarProbDlg::ToolTipsHandler( UINT id, NMHDR* pNMHDR, LRESULT* pResult )
{
        TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
        UINT nID =pNMHDR->idFrom;
        switch(nID)
        {
        case IDC_CALL_IT:
            pTTT->lpszText = "BUTTON ONE";
            return TRUE;
        case IDC_CALL_IT_TWO:
            pTTT->lpszText = "BUTTON TWO";
            return TRUE;
        } return FALSE;

}

Make sure that for each button ID there is a string table entry if you want to have strings loaded from the string table which is the standard way.
 
Old October 5th, 2004, 08:34 AM
Authorized User
 
Join Date: Jul 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Thank You......










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.