The right way to update a tool bar

Hello newsgroup,

I searched pretty hard, but I couldn't find some valuable piece of
information about updating tool bars. I have an SDI application with a
tool bar. If the user retrieves an image (e.g. by loading from file) I
want to enable some buttons in this tool bar. I wrote an OnUpdate...
handler for the button, that will check if an image is available (or if
the document is "empty"). But I can't convince the tool bar to update (I
even tried to invalidate the CToolBar window that displays the tool bar,
but this doesn't trigger my OnUpdate... handler). Curiously enough, if I
display a message box, and this message box is closed, the
OnUpdate-handler is invoked.
This seems quite strange to me. Any help will be appreciated.

Thanks,
Stuart
0
DerTopper (96)
3/7/2006 12:22:35 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
617 Views

Similar Articles

[PageSpeed] 18

Stuart Redmann wrote:
> Hello newsgroup,
> 
> I searched pretty hard, but I couldn't find some valuable piece of
> information about updating tool bars. I have an SDI application with a
> tool bar. If the user retrieves an image (e.g. by loading from file) I
> want to enable some buttons in this tool bar. I wrote an OnUpdate...
> handler for the button, that will check if an image is available (or if
> the document is "empty"). But I can't convince the tool bar to update (I
> even tried to invalidate the CToolBar window that displays the tool bar,
> but this doesn't trigger my OnUpdate... handler). Curiously enough, if I
> display a message box, and this message box is closed, the
> OnUpdate-handler is invoked.
> This seems quite strange to me. Any help will be appreciated.
> 
> Thanks,
> Stuart

When displaying a message box fixes a problem it indicates that the 
actual problem is the original code is not returning to MFC so it can 
pump messages.  If you are executing some long-running loop then 
messages are not being processed.  (And the OnUpdate... functions are 
message handlers.)

If you return to the MFC message pump regularly it will periodically 
call your toolbar OnUpdate... functions and the toolbar will update 
itself with no action required on your part.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
3/7/2006 1:24:55 PM
"Scott McPhillips [MVP]" wrote:
 :
> 
> When displaying a message box fixes a problem it indicates that the
> actual problem is the original code is not returning to MFC so it can
> pump messages.  If you are executing some long-running loop then
> messages are not being processed.  (And the OnUpdate... functions are
> message handlers.)

I have a timer for my UI thread that periodically (every 500ms) updates
a window. But my app is responding quite fast (no perceptable delay for
any actions), so there should be enough idle time. 

> If you return to the MFC message pump regularly it will periodically
> call your toolbar OnUpdate... functions and the toolbar will update
> itself with no action required on your part.

Well, well. So if I start a long routine, the toolbar won't be updated
until this routine ends? That doesn't sound very good. Wouldn't it be
rather nice if one could enable/disable or check/uncheck the button
synchronously?

Stuart
0
DerTopper (96)
3/7/2006 2:16:14 PM
It appears your application is too busy to update toolbar/UI. Thats the
only explanation for UI to be not updated. YOu can confirm this by
dragging the mainframe window when you see this behavior. The window
will not be painted correctly. If you can control the task, you can
update the UI at cetain times by calling pApp->OnIdle(-1).

---------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
3/7/2006 2:28:20 PM
"Stuart Redmann" <DerTopper@web.de> wrote in message 
news:440D95AE.AE844C74@web.de...
> "Scott McPhillips [MVP]" wrote:
> :
>>
>> When displaying a message box fixes a problem it indicates that the
>> actual problem is the original code is not returning to MFC so it can
>> pump messages.  If you are executing some long-running loop then
>> messages are not being processed.  (And the OnUpdate... functions are
>> message handlers.)
>
> I have a timer for my UI thread that periodically (every 500ms) updates
> a window. But my app is responding quite fast (no perceptable delay for
> any actions), so there should be enough idle time.
>
>> If you return to the MFC message pump regularly it will periodically
>> call your toolbar OnUpdate... functions and the toolbar will update
>> itself with no action required on your part.
>
> Well, well. So if I start a long routine, the toolbar won't be updated
> until this routine ends? That doesn't sound very good. Wouldn't it be
> rather nice if one could enable/disable or check/uncheck the button
> synchronously?

Ahhhh, Grasshopper, now it is time that you took the test of the Worker 
Thread. Read up on them thoroughly, and they will serve you well. Whatever 
you do, don't move your BBQ around your patio until it's gone cold. And stop 
wasting time with that flute.

Remember what Confucious says: "Even in the Autumn of a million trees, no 
two leaves hit the ground at precisely the same moment."


>
> Stuart 


0
kma3184 (100)
3/7/2006 2:51:22 PM
>  Wouldn't it be rather nice if one could enable/disable or check/uncheck the button
> synchronously?

This is actually a good feature to have. There are some scenarios where
this is very well suited. But by default this can be expensive and
current mechanism is excellent for updating UI when there are no more
messages in message loop. As mentioned earlier, to do this
synchronously, use pApp->OnIdle(-1).

---------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
3/7/2006 3:09:19 PM
Stuart Redmann wrote:
> Well, well. So if I start a long routine, the toolbar won't be updated
> until this routine ends? That doesn't sound very good. Wouldn't it be
> rather nice if one could enable/disable or check/uncheck the button
> synchronously?
> 
> Stuart

If you start a long routine, NOTHING in your windows will be updated 
until the routine ends.  You can force some synchronous updating of some 
things, but that doesn't help with the broader problem that other 
windows (from other apps) can uncover your window at any time, so you 
also need updates that you can't predict.

All painting, even nonclient stuff like the titlebar, is repainted as 
necessary in your main thread.  That won't happen if your main thread is 
executing a long routine.  The solution is to put your long routines 
into secondary threads, leaving your main thread available at all times 
to update windows, accept clicks, etc.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
3/7/2006 10:19:31 PM
Ok, ok, I'll use worker threads (it's been bugging me anyway that I used
this timer).

Thanks to you all.
Stuart
0
DerTopper (96)
3/8/2006 7:56:57 AM
Yes, but why -1 not 0? any reason?
I think 0 is enough, -1 will cause some update job to be done twice.

"Ajay Kalra" wrote:

> It appears your application is too busy to update toolbar/UI. Thats the
> only explanation for UI to be not updated. YOu can confirm this by
> dragging the mainframe window when you see this behavior. The window
> will not be painted correctly. If you can control the task, you can
> update the UI at cetain times by calling pApp->OnIdle(-1).
> 
> ---------
> Ajay Kalra
> ajaykalra@yahoo.com
> 
> 
0
FeiXu (13)
7/8/2006 6:12:01 PM
Reply:

Similar Artilces:

Office Tools in 2010
I use Office 2003 and am accustomed to reaching for Office Tools quite often. Are they included in any version of 2010? Thank you. Some are. Which specific tools are you looking for? -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.htm Author: The Lawyer's Guide to Microsoft Outlook 2007: http://tinyurl.com/ol4law-amazon "JJG" <not@anwhere.com> wrote in message news:ODvL4$76KHA.5708@TK2MSFTNGP02.phx.gbl... > I use Office 2003 and am accustomed to reaching for Office Tools ...

Update one table from another
I am trying to update one table that has one record for each employee(table 1) with available vacation time. The other table records every time off request(table 2) and how much time they want off. I have the update query and it works fine. The problem is that everytime it is ran every requested time off amount(from table2) is subtracted from the available time(table1) again and again. I want the records for requested time(table2) to update the employee available time off(table1) only once, but keep the records on the table as that is the basis for a report. Thank You, Brett ----=...

Cannot Update Prices Online
I can no longer updated prices online. I use 2003 stnd. When on Portfolio page, if i click on Update Prices on the left, the only option I now have is Update Prices Manually. There is no longer any option for Update Prices Online. Also, on the home page if I do click the Update Online Quotes link, all it does is refresh my related investment charts on the home page. This has worked with no problem as long as I can remember. I cannot think of any changes or updates I have made to the software or options... Standard Edition? In use for a year now? Read the License Agreement (Hel...

Update MSN Services with Money 2007
How can I update the Portfoglio and Accounts on MSN with MS Money 2007 Deluxe version ??? Thank you. Bye. Paolo B. Italy In microsoft.public.money, Paolo B. wrote: >How can I update the Portfoglio and Accounts on MSN with MS Money 2007 >Deluxe version ??? Transactions that you enter yourself into Microsoft Money 2007 would not be forwarded out to MSN Money. This keeps that info on your own computer. For institutions with their own OFX servers, you would have to set up those accounts to download into MSN Money also. Accounts where the data comes in via "third party" ...

Can't install windows updates on SBS 2003
I have a SBS 2003 server that has not been updated in a couple years. It has SP2 installed but when I run Microsoft Update it needs to download and install 96 updates. When I try to get them installed it comes back with an error saying not enough disk space. I have tried to just install 1 update at a time and get the same error. The C:\ drive has over 14GB of free space and the other drives have plenty of space as well. I restarted the server and also ran Disk Cleanup, as the error message reccomends, but am still having the same problem. Anyone run across this problem befo...

Won't configure updates...
I am able to install updates, and actually get a "pending" message beside the updates in the Update Manager. But when I restart my computer, I get a 0% installed message next to the 3-3 updates etc. then a message that the updates weren't configured correctly. I'm about ready to punt, any help is appreciated. CrystalBall© sez... Free unlimited installation and compatibility support is available for Windows Vista, but only for Service Pack 2 (SP2). This support, originally scheduled to end 26 November 2009, has been extended until 26 February 2010. A...

Text to columns
Once I use the Text to columns feature in Excel, it seems there is no way to turn it off. Anyone know if there is a way to reset this so that newly pasted text will not continue to get broken up (for example by the space delimiter) Presently the only way is to exit Excel and restart Excel - then pasted text all goes into one cell regardless of spaces. Hope I explained that well enough Al I may have been to hasty in making this assumption, it appears that the problem I described below is only happening on one workstation - this may indicate that the Excel Registry keys are in need of...

Right click in Pivot Table or on Entire Column
I have added items to the right-click menu that popups up when you have a cell or cells selected. But when you are in a Pivot Table or have an entire column selected the right-click popup is different. Is there a way to add an item to the right-click popup menu when you are in a Pivot Table or have an entire column selected? Thank you for your help. Steven Never mind. This one was right in the help section. I should have looked first. Thank you, Steven "Steven" wrote: > I have added items to the right-click menu that popups up when you have a ...

How do text capture tools work?
Here are two examples of this technology. http://www.textcapture.com/en/default.html http://www.deskperience.com/textcapture/ Sounds like they will have to involve OCR, which works fine for standard fonts but probably won't work with fancy fonts. Key here is to test them try a static control with a TextOut and change the fonts and see what happens. joe On Wed, 31 Oct 2007 15:02:04 -0500, "Peter Olcott" <NoSpam@SeeScreen.com> wrote: >Here are two examples of this technology. > > http://www.textcapture.com/en/default.html > http://www.deskp...

After 12.2.4 update, cannot open some Word docs with Open passwords
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel After installing the 12.2.4 Office update, I am unable to open some Word files that I had password-protected with an Open File password. How can I open? Thanks Basically, "you can't". Sorry, the other passwords are crackable, but "Password to Open" is effectively the encryption key. The entire file is encrypted, and unless you have the correct password, you can't get it open. However, are you sure you are not attempting to open files that were password-=protected on the PC? ...

Windows Update Office 2007 Converter confusion
On my desktop I have Office 2003 (laptop has Office 2007). I recently received an attachment in .docx format (2007). I downloaded the converter to my desktop and opened the document. Now on my desktop (which has Office 2003) I receive update notices for Office 2007. Should I ignore these? Hide them? Install them? Will I still be notified re updates needed for Office 2003? Thank you for whatever insight you can provide. If you can give me some of the background explanation as to why this is happening (I presume related to the 2007 converter viewer install), I can understand bett...

Separators In OUTLOOK Tool Bars???
How do I pace a separator in an OUTLOOK tool bar? In outlook 2003: Right click on toolbar, and choose customize. Select the Commands tab, then click on the toolbar button you want to be to the right of the separator. Click on "modify selection", then on "Start a group". HTH Mark -----Original Message----- From: C. Davey Utter [mailto:cdutter@spamex.com] Posted At: 02 October 2005 19:57 Posted To: microsoft.public.outlook Conversation: Separators In OUTLOOK Tool Bars??? Subject: Separators In OUTLOOK Tool Bars??? How do I pace a separator in an OUTLOOK tool bar? --...

right aligned menus?
is there any way to use menus from resources in right justified order? we have a customer that might like a non-English menu. TY Open the .rc file in a Text Editor and Add MFT_RIGHTJUSTIFY to the menu item. "Donald Sorenson" <dony_s@excite.com> wrote in message news:OyeQn1TfEHA.3556@TK2MSFTNGP12.phx.gbl... > is there any way to use menus from resources in right justified order? we > have a customer that might like a non-English menu. > > TY > > TY! but I didn't find the right place in the script file... I tried to OR (|) it with the first M...

Right click mouse no menu
Outlook 2003, Windows XP, SP2. Since a while (context unknown) when I right-click an email in a folder the menu that normally pops up (with options like open, mark as read, delete, etc.). This Menu doesn't come up any more. On a another Laptop and on a Desktop (same revision level) it works.I did a repair of office. No luck. Looks like this is a know problem (you can search forum for occurence of "right") but no solution provided yet. Any suggestions, solutions? Thanks If you close and reopen Outlook, does it work again? How about after a reboot of Windows? --� Milly...

Right-click menu does not appear
I am having an issue with Outlook 2000. I have installed Microsoft Outlook 2000 with Office 2000 SR-1 and SP3. When I log on as the user (with or without local admin rights on the machine) then he cannot right-click on messages in his Inbox. Right-clicking works fine on any of the folders in the folder list. In the message list, no menu pops up at all. When I am logged onto the computer as myself (with domain admin rights) it works fine. None of our other Outlook installations are having this issue. The computer with the issue is a Dell Latitude laptop running Windows XP Professional wi...

How to determine whether update rollup is installed
Hi, I've just installed the update rollup on test machines both for client and server. However there's no obvious change - even the build version numbers shown on the web interface remain the same. Is this to be expected? How can I tell that the update is installed successfully? Thanks! Tom Not sure why they didn't update the version number. On the server, go to add/remove programs and check the 'show updates' checkbox at the top. then, under the Microsoft CRM Server, you should see 'Update Rollup 1...' Dave Ireland "Tom" <thisisme_ithink@yahoo...

HowTo disable cell reference update
I want to disable cell reference updates when I am inserting a row. My chart has series data in A2..A7. After row insert with MoveDown at row 2 the references are updated to A3..A8 How do I preserve the original cell refernce? ...

Permissions after 12.1.2 update
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Question. Not sure, but I after running the 12.1.2 office 2008 updater, I noticed this when repairing permissions using disk utility Permissions differ on "Library", should be drwxrwxr-t , they are drwxrwxr-x . Now, I also noticed other disk utility repair permissions that take place after the weekly overnight sripts run. I am just trying to figure out if running the office 2008 updater 12.1.2 could generate the permissions fix reported above. I installed this on 2 exactly the same computers, and didn't g...

2 updates won't install
Server 2003 SP2 updates KB973354 and 958469 both get error 0x800F0102. What can I look for ? Dave Mc wrote: > Server 2003 SP2 updates KB973354 and 958469 both get error > 0x800F0102. What can I look for ? Gone through this yet? http://support.microsoft.com/kb/906602 -- Shenan Stanley MS-MVP -- How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html ...

After update 10-31-07
I'm using an After Update event on a form to update one field with the current date when a checkbox is checked, but the date doesn't display until I scroll down the form. Is there some way to get the date to display right after the box is checked (or at least once the next record is selected)? Thanks, Tom -- Thanks, Tom Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200710/1 Sounds like you have a control that has a Name that is different from the name of the date field. In the AfterUpdate code, use the name of the control,...

When is Microsoft coming out with updated version of Publisher?
I've been using Pubisher since 1997 and it's great...but now it's almost FOUR years old with no no version! More graphics, more WordArt options, that would be nice. When are we going to see a Publisher 2006-7?????? There is a new version of Office being beta tested now with an approximate release date of Spring 2007. (No clue about the amount of clipart or WordArt. Sorry) -- JoAnn Paules MVP Microsoft [Publisher] "Nancy O'Brien" <Nancy O'Brien@discussions.microsoft.com> wrote in message news:005128ED-EF3D-4ADA-B02D-B5EB6790BFC0@microsoft.com.....

Security bar
Hi, I have the following problem with my Access dataabse: Evertime I open the database i get the security warning bar,users should press on options and select "Enable this content" in ordr to proceed to the database... Is there a VB code that i can run on the on load event of my main form to set this option to automatically "enable this content" ? You don't mention which version this is. If Access 2007, you need to tell it your database is in a trusted folder. Go to: Office Button | Access Options | Trust Center | Trust Center Settings and Add your folder...

Update a radio button by combobox selection
Hi, In a VS2008 VB project, I have a combobox that gets its value from a table with three columns. I want to display one column in the combobox, write the value of the second column back to a different table, and I want to change the value of a radio button (on the same form as the combobox) based on the value of the third column of the selected record. I'm setting the ComboBox.Text value to be the first column, the ComboBox.SelectedValue to be the second column, but how would I change the radio buttons in the most efficient way? Thanks in advance, Steve Wrong g...

Quick way to convert to Text
I am looking at a quick way to convert a column of numbers to text... Any ideas? thanks Brent "Text" as in 123 is converted to one hundred and twenty three? See Bob Phillips' site. http://www.xldynamic.com/source/xld.xlFAQ0004.html Gord Dibben MS Excel MVP On Mon, 5 Feb 2007 10:19:25 -0800, "Brent" <sagemaster@mvdsl.com> wrote: >I am looking at a quick way to convert a column of numbers to text... Any >ideas? >thanks > Try copying an unused cell then highlighting the required column ans Paste Special > Add -- HTH Sandy In Perth,...

Errors at ActiveSync Mobile Administration Web tool.
Dear colleagues, We've met problems trying remote wipe feature at ActiveSync Mobile Administration Web tool. Namely we've received the following error after entering smtp address to lookup list of devices: Server Error in '/MobileAdmin' Application. -------------------------------------------------------------------------------- Enumerator is positioned before the first item or after the last item. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it o...