CToolBar Help

Hello,

I've been trying to add a toolbar to my dialog following the example from 
MSDN a
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_ctoolbar.asp

But for some reason I just can't add the toolbar I created.  Here is my code:
CToolBar m_toolbar;
if (!m_toolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
      | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, 
IDR_TOOLBAR1))
	{
		MessageBox("Error -1");
	}
	m_toolbar.LoadToolBar(IDR_TOOLBAR1);

Could somebody please tell what, if anything, I am doing wrong? 

Thank you,
Victor.
0
victorsk (138)
7/14/2005 1:30:01 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1187 Views

Similar Articles

[PageSpeed] 16

Hi,

Finally!  Thank you so much for an awesome reply.  Yes, I do have this code 
in the same function and thank you for pointing out the problem and what to 
do next.

Regards,
Victor.

"Scott McPhillips [MVP]" wrote:

> victorsk wrote:
> > Hello,
> > 
> > I've been trying to add a toolbar to my dialog following the example from 
> > MSDN at
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_ctoolbar.asp
> > 
> > But for some reason I just can't add the toolbar I created.  Here is my code:
> > CToolBar m_toolbar;
> > if (!m_toolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
> >       | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, 
> > IDR_TOOLBAR1))
> > 	{
> > 		MessageBox("Error -1");
> > 	}
> > 	m_toolbar.LoadToolBar(IDR_TOOLBAR1);
> > 
> > Could somebody please tell what, if anything, I am doing wrong? 
> > 
> > Thank you,
> > Victor.
> 
> Does your code actually look like the above, with the m_toolbar variable 
> defined in the same function as the Create call?  If so then you have 
> made a basic C++ mistake.  A variable defined within a function is 
> destroyed as soon as the function returns.  That would destroy your 
> toolbar right after you create it (:
> 
> The link you reference includes a link to a working MFC sample program 
> that does what you want.  To solve your problem you must do the things 
> shown in that sample code, including deriving a class member variable 
> from CDlgToolBar.  I see from your other post that you think the sample 
> is too lengthy.  Take the time to learn from it.  There is a bug in the 
> MFC library code and the sample contains a work around for that bug.
> 
> -- 
> Scott McPhillips [VC++ MVP]
> 
> 
0
victorsk (138)
7/14/2005 2:43:02 AM
victorsk wrote:
> Hello,
> 
> I've been trying to add a toolbar to my dialog following the example from 
> MSDN at
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_ctoolbar.asp
> 
> But for some reason I just can't add the toolbar I created.  Here is my code:
> CToolBar m_toolbar;
> if (!m_toolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
>       | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, 
> IDR_TOOLBAR1))
> 	{
> 		MessageBox("Error -1");
> 	}
> 	m_toolbar.LoadToolBar(IDR_TOOLBAR1);
> 
> Could somebody please tell what, if anything, I am doing wrong? 
> 
> Thank you,
> Victor.

Does your code actually look like the above, with the m_toolbar variable 
defined in the same function as the Create call?  If so then you have 
made a basic C++ mistake.  A variable defined within a function is 
destroyed as soon as the function returns.  That would destroy your 
toolbar right after you create it (:

The link you reference includes a link to a working MFC sample program 
that does what you want.  To solve your problem you must do the things 
shown in that sample code, including deriving a class member variable 
from CDlgToolBar.  I see from your other post that you think the sample 
is too lengthy.  Take the time to learn from it.  There is a bug in the 
MFC library code and the sample contains a work around for that bug.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
7/14/2005 3:17:14 AM
Reply:

Similar Artilces:

Formula help (Lookup)
Hello! I use this formula to extract data from a pricelist. I found this formula on the net (thanks to whoever who made it). {=INDEX(B93:E302;MATCH(Pris!I2&Pris!G2;A92:A301&B92:B301;0);Match(Pris!H2;92:92;1))} The problem I have is that it only allows exact match on the first two lookups, I can not change the type from 0 to 1 or -1 to allow for a not exact match like I have done in the third lookup. Column A is a name for fifferent pricelists,Column B is length in kilometers and Row 1 is weight in kilos. First I lokkup which pricelist to use then the length and then the weight. Any ide...

PLEASE HELP
I'm having trouble with Microsoft word and excels Find and Replace functions. Any help would be really appreciated. Basically i have an excel file that is thousands of columns down.. which I need to change the formatting!! I am trying to take digits that start out looking like: 0314-T210557 And turn them into: 14-Mar-09 21:05:57 So far, (In Microsoft word) I have used Find and Replace to get rid of the dash and the T. I have also used find and replace and put a tab in between the 0314 and the 210557.. (so that when I put it back into excel, they are in separate colum...

HELP with an INSERT INTO statement
Hello everyone, I received the response below for a previous question. I understand the logic behind the reply, and I am sure it will work. I can't, however, figure out what I should be substituting for '2345' in the "SELECT '2345' AS" part of the solution below? I'm getting very close to running out of time and would greatly appreciate any assistance. Regards, Franc. Hi Franc, > > Use an append query. Probably you'll need to write VBA code to > assemble and execute the necessary SQL statement, which could look > something like this: > ...

Toolbar buttons (text and bitmaps) are disappearing, when using with MFC CToolBar class
Guys, help me to sovle the following problem I have a MFC SDI application (Vc++ 6.0) ( 2 Threads, UI and data acqusition thread). The UI is having a simple toolbar control with text and bitmap. The problem is once i run this application after doing some gui operation (like invoking some dialog box changing to diffrent view) the toolbar button is getting disappeared. sometimes the fonts of the toolbar button is getting changed or sometimes when i move the mouse over the toolbar, the buttons is slowly going away( only back ground color of rebar is comming. Is there any methods to debug this ki...

Help on redistributals on an MFC application
Hello, I created an MFC exe that utilizes the flexgrid and some common controls. No third party dll or anything that would not be installed with newer versions of windows. I do all my development on 2000 professional and the application works fine on it. I tried to install it on a XP box but to my surprise it did not even open on it. I get no error. It just beeps and the application never starts. It was dynamically linked to MFC and the MFC dll come with the OS, so I recompiled it statically and I got the same result when launching the application. It never starts and I get a system beep, no ...

CToolBar
I have noticed that by handling toolbar's button click command, that button automatically gets enabled. How can I explicitly disable the that button? Thanks in advance "RG" <nobody@nowhere.com> wrote in message news:uabUoMjsFHA.3604@tk2msftngp13.phx.gbl... >I have noticed that by handling toolbar's button click command, that button >automatically gets enabled. How can I explicitly disable the that button? > > > Thanks in advance > You need to add an ON_UPDATE_UI handler, then you can do something like this... if ( some_reason_to_disable_b...

HELP files not showing
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: imap Previously, I got help from the Help menu, Entourage Help. Now, all I get is so-called online help, which gives a bunch of tutorials and such. <br><br>Where did it go? <br><br>Specifically, I am trying to find out how to view a reply that I just sent to a certain message. There is a reply notation at the top of the message display but it doesn't do anything when I click on it. On 4/24/10 7:08 PM, roberthgoldstein@officeformac.com wrote: > Specifically, I am...

forecast function help
This might seem a bit newbie but im having trouble with the forecas function. Say for example i have a collection of data for sales of each item ove a number of years: item 2000 2001 2002 2003 1 3 4 5 2 4 3 2 3 2 2 4 4 3 1 5 5 4 1 6 6 2 2 4 i am asked to forcast the values for the year 2003. I have read an looked at many examples on how to do this and still can't work ou where to start? Any help would ...

i need help with error on deleting rows in vba #2
Thanks Dave you hit the nail on the head. some of the rows below g25 were neve touched. your code fixed it. thanks -- GregJ ----------------------------------------------------------------------- GregJG's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1106 View this thread: http://www.excelforum.com/showthread.php?threadid=26123 ...

Help with Money2004 Help
The help files in Money 2004 are not responding. The help program runs, but it cannot find any data. It appears to be a registry corruption or missing files. I have tried reinstalling, but got no change in behavior. Please help. DC Try deleting all Internet temporary files in Internet Options. This has solved lots of people's help file problems. You'd like to think Microsoft would have fixed this, but guess again. "Donald Christian" <dbchrist@advantexmail.net> wrote in message news:vp2qmo33kglqf6@corp.supernews.com... > The help files in Money 2004 are not re...

I need help
I too can not set up an e-mail address. I use 'comcast.net' Which version of Outlook? Do you have settings for Comcast you can share with us? -- Bill R "Gray-Line" <Gray-Line@discussions.microsoft.com> wrote in message news:A0065C07-5737-44EF-8AAC-25E16D71498D@microsoft.com... >I too can not set up an e-mail address. I use 'comcast.net' Outlook 2003 / Don't know were to find the 'settings' info "BillR" wrote: > Which version of Outlook? > Do you have settings for Comcast you can share with us? > > -- > Bill R ...

URGENT HELP NEEDED
URGENT HELP NEEDED - Can Not Start Microsoft Exchange Directory service on local computer. We tried to use the ESEUTIL.exe comand to defrag our Exchange server 5.5 this last night. Now we can not get anything to run. PLEASE HELP ASAP. We try to start the services on our Exchange 5.5 computer, but no luck. All the echange services state: "Could not start the Microsoft Exchange Directory service on Local Computer. The service did not return an error. This could be an internal Windows error or an internal service error. If the problem persists, contact your system administrator.&...

Help me for these sql line case please
Hi guys I'm newbie on sql structure and syntax. And I have this problem : I have 3 table : Table_A FieldA1 FieldA2 a01 John a02 James a03 Bob a04 Sandra Table_B FieldB1 FieldB2 b01 Desk b02 Chair b03 Sofa b04 Saddle b05 Cradle Table_C FieldC1 FieldC2 c01 Computer c02 Phone c03 Calculator c04 VCR c05 TV c06 DVD c07 CD I want to manage those tables with the queries and the output datasheet will look like this FieldA1 FieldA2 FieldB1 FieldB2 FieldC1 FieldC2 FieldD1 a0...

Help! What is Outlook sending?
OS: Windows 2000 Product: Outlook 2002 Connection: Comcast Cable Mail: Comcast POP3 mail server (mail.comcast.net) Question(s): Every so often (4th or 5th time) when I perform a Send/Receive, Outlook will send out a message that I had in no way composed myself. A few seconds later Norton Antivirus 2002 confirms this with a "Sending Message" window. And the "Sent Messages" folder does not reflect a message being sent. Just what is it that outlook is sending? I'm very sure it isn't spamware or spyware, since one time this happened after a fresh install of my ...

Help Creating A Formula
I need to create a formula that will add cells e2 through e9 if they sa ms fuel in cells c2 through c9 Attachment filename: sample spread.zip Download attachment: http://www.excelforum.com/attachment.php?postid=45046 -- Message posted from http://www.ExcelForum.com =SUMIF(C2:C9,"ms fuel",E2:E9) should do that for you. (and I'll have 2 chocos please ;) ) Rob "chocolab61571 >" <<chocolab61571.120nhm@excelforum-nospam.com> wrote in message news:chocolab61571.120nhm@excelforum-nospam.com... > I need to create a formula that will...

Statement HELP!!
We are using GP 7.5 and becoming familiar with SOP module. As we are testing our statements, is there a way that the only items that print are the open invoices. We don't want to see partial payments or returns. I was able to just show one balance but we would like to show the invoice detail with nothing else. I am not sure if this is a strange request but I need to let our AR dept know the options. If someone could give me some input, I would appreciate. HELP!! Thanks Barb By 'open' invoices, I assume you mean invoices that have not been completely paid. In order to ...

Please help: Interrupt routine to get input from key
I want to create a loop so the program will look for the actual keyboard input (not a program sendkey nor the virtual key) , say "arrow_down" key, and when it sees the change, it does something else. Here is my loop: Dim keystat(0 To 255) As Byte While keystat(40) <> 1 ' keystat(40) is arrow down key ' Check if the arrow down key has been pressed ' This is where I could not see the change. Need some interrupt loop to ' enter keyboard such as input (but I don't want to see it shows on the screen) retval = GetKeyboardState(ke...

Help please
I have a Excel database that I am converting to Access. From there I am converting into Outlook. It all works except my phone numbers are way off and incorrect. My excel db is from a good source (database co.) and they cant seem to help on their end (never happened before). Any help out there? Hi Alan, Please explain exactly what's not working the way you expect it to. At just what stage are the phone numbers going wrong (e.g. are they all right in Excel but not in Access, or in Access but not Outlook?). What exactly do you mean by "way off and incorrect"? On Mon, 5 Jan ...

LoadToolBar Function in Subclassed CToolBar fails.
I am trying to sub-class a Toolbar in a CPropertyPage (Wizard) application. My code fails at LoadToolBar. On further inspection it fails exactly at DefWindowProc while adding bitmapped Buttons (TB_ADDBUTTONS = 1044) LayoutWizardD.dll!NLayoutWizard::CSLToolBar::DefWindowProcA(unsigned int nMsg=1044, unsigned int wParam=1, long lParam=1233352) Line 119 C++ mfc71d.dll!CToolBar::SetButtons(const unsigned int * lpIDArray=0x0140c014, int nIDCount=5) Line 522 + 0x19 C++ mfc71d.dll!CToolBar::LoadToolBar(const char * lpszResourceName=0x00001f69) Line 389 + 0x14 C++ mfc71d.dll!CToolBar::LoadToolBar(...

IIC
HI., This is saravanan .,I have to send 16 bit address to CAMERA(ov3640) With the help of IIC... There is no 16bit address format In IIC... I Read only 7/10 bit addressing format(IIC) ...I have to develop the program in Visual studio for that 16 bit address to camera & I have to read the camera contents (Through 16 bit address format)...Can u help me ...How to send a 16 Bit address format to camera through IIC... For ex: In OV3640 The product id is:300A., The (16Bit) address I have to send through IIC to camera(for read operation),In IIC registers only 8 bit reg...

Help with referenced sheet
Hi all, I am attempting to feed data into a cell on sheet ABC that comes from another sheet that will be created programmatically (call it sheet XYZ). I start by creating the reference with sheet XYZ already existing, so that I can pick the cells I want off of it. I then delete sheet XYZ. My cells on ABC all then become #REF, which is okay with me. I save and close. I then run the program that takes some data, opens my excel file, and (re)creates sheet XYZ and puts the data I want onto it. The problem is that all of my cells on ABC that reference XYZ keep the #REF until I double ...

Password Help
I tried to work on my money file last night and it comes up with an error that says incorrect password. I know this is the correct password I just used it last week and signed in normal. My husband did a microsoft download a few days ago and I'm wondering if this affected the password. The error message talks about the "Live Password" which as far as I know, we've never set up....Is there a way to get around this??? Can I start a new Money account and import the old file to the new account so I can reset the password??? Thanks for any help!!! In microsoft.publi...

HELP! archiving email
Hell-o Having serious trouble with my Information Store. If I tell my users to archive their mail, and I have to do a restore that is a week old, willl they be able to keep all of their mail from the archive process TIA Gary What is your problem? Gary wrote: > Hell-o, > Having serious trouble with my Information Store. If I tell my users to archive their mail, and I have to do a restore that is a week old, willl they be able to keep all of their mail from the archive process? > TIA, > Gary ...

I need a help
I am not able to change the cell to h:mm, and i want them to add also. my format is in such a way Incoming 9.50 9.30 9.15 9.00 9.30 9.40 Lunch 0.40 0.40 0.40 1.00 0.30 - Outgoing 6.20 5.50 5.45 5.35 6.00 1.30 i want to have total working hrs. pls help me =VALUE(SUBSTITUTE(TEXT(A1,"0.00"),".",":")) Format as Time -- Kind regards, Niek Otten Microsoft MVP - Excel "bhanupriya" <bhanupriya@discussions.microsoft.com> wrote in message news:93AE736C-300F-4113-85CF-75F4527436DA@microsoft.com... |I am not able to change the cell to h:mm, and i wan...

Outlook 2003 Messages and Calendar Appts Received as PLAIN TEXT
SGVsbG86DQoNCkkganVzdCBnb3QgYSBuZXcgbGFwdG9wIHdpdGggVmlzdGEgSG9tZSBCYXNpYyBv biBpdCBhbmQgSSBjb3BpZWQgbXkNCnBzdCBmaWxlIGZyb20gbXkgb2xkIGxhcHRvcCB0byB0aGUg bmV3IG9uZS4gRXZlcnl0aGluZyB3b3JrcyBmaW5lDQpleGNlcHQgYWxsIGUtbWFpbCBtZXNzYWdl cyBhbmQgY2FsZW5kYXIgYXBwdHMuIEkgcmVjZWl2ZWQgYXJlIGluIHBsYWluDQp0ZXh0LiBJJ3Zl IHNlYXJjaGVkIGV2ZXJ5d2hlcmUgZm9yIHRoaXMgZml4LCBidXQgZm91bmQgbm90aGluZy4gDQoN CkRvZXMgYW55b25lIGhhdmUgYW55IHN1Z2dlc3Rpb25zIGZvciBtZT8gDQoNClRoYW5rIHlvdSEN ClNwdWRkeQ0K me@cox.net <me@cox.net> wrote: > I just got a new laptop with Vista Home Basic on it and I copied my > pst file...