473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What happened to UpdateCommandUI?

I'm pretty new to C#, but I've had a lot of experience with MFC. MFC
had a mechanism for updating dialog controls using an idle message.
For those unfamiliar, basically you would override OnIdle and call
UpdateDialogControls(), and that would send WM_UPDATECOMMANDUI messages
to all the controls in the dialog. Then you could add handlers for
each control that you wanted to update. For example, if you wanted a
button to be disabled if some text box was empty, you would add the
UpdateCommandUI handler for the button that would check the state of
the text box. It was very useful, and completely undetectable as far
as the user goes (no flicker).

I can't seem to find that kind of mechanism in C#. I can create an
Idle handler for the application and call Update() for all the
controls, but the handler for Update isn't called unless the control is
invalidated -- so that's no good. So I've tried calling Invalidate(),
and then create a handler for Invalidate on each control. However, by
calling invalidate, it creates an annoying flicker in many controls --
basically any control that's not a button.

I figure there must be a way, and microsoft wouldn't completely leave
it out, but I could be wrong. Any help would be appreciated.

Nov 17 '05 #1
6 2718

"SugarDaddy" <er*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I'm pretty new to C#, but I've had a lot of experience with MFC. MFC
had a mechanism for updating dialog controls using an idle message.
For those unfamiliar, basically you would override OnIdle and call
UpdateDialogControls(), and that would send WM_UPDATECOMMANDUI messages
to all the controls in the dialog. Then you could add handlers for
each control that you wanted to update. For example, if you wanted a
button to be disabled if some text box was empty, you would add the
UpdateCommandUI handler for the button that would check the state of
the text box. It was very useful, and completely undetectable as far
as the user goes (no flicker).

I can't seem to find that kind of mechanism in C#. I can create an
Idle handler for the application and call Update() for all the
controls, but the handler for Update isn't called unless the control is
invalidated -- so that's no good. So I've tried calling Invalidate(),
and then create a handler for Invalidate on each control. However, by
calling invalidate, it creates an annoying flicker in many controls --
basically any control that's not a button.

I figure there must be a way, and microsoft wouldn't completely leave
it out, but I could be wrong. Any help would be appreciated.


I don't know of anything specifically to do this. Most of the time I would
probably handle that in the TextBox's TextChanged event since I only need
the code to execute when the textbox's state changes rather than on idle
ticks. Still, you should be able to roll your own implementation without
much trouble, shouldn't you?
Nov 17 '05 #2
Oh, it's not an issue of moving existing code to .NET. I was just
wondering if .NET included the same mechanism that MFC had.

I guess the model has changed, and it breaks the abstraction concept.
What I mean by that is: If I want a button to be enabled or disabled
based on the state of another control (checkbox, textbox, whatever...)
then it's the job of the button to monitor the state of that control
because the button knows about what controls it depends on. Now, with
the seemingly new model, the button still remains a dependency, but the
button doesn't know about what it is a dependency of. Only the
controls that have the button as a dependency know about the button.
So instead of controlling the state of the button within some handler
of the button, I know have to control the state of the button from
within handlers for the controls that the button depends on. Basically
it changed from all the code in one spot to all the code in multiple
spots. It's ugly, and it seems like Microsoft wouldn't have left out
this wonderful mechanism since .NET includes so much more than MFC had.

But thank you for your response. It's not an issue of not knowing how
to code it. It's an issue that it's basically a hack of the
UpdateCommandUI mechanism of MFC.

Nov 17 '05 #3
This doesn't exist in Windows Forms controls.

MFC was an application framework and provided lots of additional
functionality that helped out a lot. Windows Forms is a loose collection of
individual controls. No control / form / application integration is
provided.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"SugarDaddy" <er*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I'm pretty new to C#, but I've had a lot of experience with MFC. MFC
had a mechanism for updating dialog controls using an idle message.
For those unfamiliar, basically you would override OnIdle and call
UpdateDialogControls(), and that would send WM_UPDATECOMMANDUI messages
to all the controls in the dialog. Then you could add handlers for
each control that you wanted to update. For example, if you wanted a
button to be disabled if some text box was empty, you would add the
UpdateCommandUI handler for the button that would check the state of
the text box. It was very useful, and completely undetectable as far
as the user goes (no flicker).

I can't seem to find that kind of mechanism in C#. I can create an
Idle handler for the application and call Update() for all the
controls, but the handler for Update isn't called unless the control is
invalidated -- so that's no good. So I've tried calling Invalidate(),
and then create a handler for Invalidate on each control. However, by
calling invalidate, it creates an annoying flicker in many controls --
basically any control that's not a button.

I figure there must be a way, and microsoft wouldn't completely leave
it out, but I could be wrong. Any help would be appreciated.

Nov 17 '05 #4
I figured as much. Oh well. Thanks for the reply.

Nov 17 '05 #5

"SugarDaddy" <er*********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Oh, it's not an issue of moving existing code to .NET. I was just
wondering if .NET included the same mechanism that MFC had.

I guess the model has changed, and it breaks the abstraction concept.
What I mean by that is: If I want a button to be enabled or disabled
based on the state of another control (checkbox, textbox, whatever...)
then it's the job of the button to monitor the state of that control
because the button knows about what controls it depends on. Now, with
the seemingly new model, the button still remains a dependency, but the
button doesn't know about what it is a dependency of. Only the
controls that have the button as a dependency know about the button.
So instead of controlling the state of the button within some handler
of the button, I know have to control the state of the button from
within handlers for the controls that the button depends on. Basically
it changed from all the code in one spot to all the code in multiple
spots. It's ugly, and it seems like Microsoft wouldn't have left out
this wonderful mechanism since .NET includes so much more than MFC had.


I don't think its all that different. Whats the difference in subscribing to
a UpdateCommandUI handler and subscribing to a TextBox.TextChanged handler?
Only difference is you have to subscribe to multiple events instead of one.
Nov 17 '05 #6
Yeah that's the difference. It's not a big deal. That's the way I was
doing it. I was just wondering if I was missing out on an easier way
of doing it.

But basically I can get the same effect if I create a method such as
"UpdateControl()" and call UpdateControl from each one of the handlers.
I guess it's a bit more efficient as well, since you're only calling
update when it needs attention rather than calling update on every idle
messages.

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

96
by: BadPony | last post by:
Anyone using Peoplesoft on a Federated UDB (shared nothing)Environment on Open System Platforms? Preferably AIX, but any war stories would be good. TEA EB-C
2
by: Lauren Wilson | last post by:
Hi folks, Just "upgraded" from A2K to A2K3. Everything is just hunky dory (so far) -- EXCEPT that the Add-in I had with A2K that auto inserts error code is no longer available in the Add-in...
2
by: N J | last post by:
Hi, Please take a look at http://webmonky.myby.co.uk/error.JPG . This is the second time this has happened. All I did was run command ... CurrentDb.Execute "Update tblDownload Set OrderType =...
1
by: Mikey | last post by:
Can somebody tell me what happened to the Source Profiler? It used to be under the Build menu in VC6, but now it's gone, and I cannot find anything in the docs that say what happened to it. The...
1
by: JS | last post by:
Hello, I am using ASP .Net to create my own web controls and I have noticed that there is one too many requirements that forces the developer to be aware of and get involved with. In the past...
9
by: Jay | last post by:
Everywhere I go (read/browse) I see these parameters.... ByVal sender As Object, ByVal e As System.EventArgs Yet I never see them used within the function/method. Could someone tell me what they...
5
by: rodchar | last post by:
hey all, what happened to being able to compile my app as Release version? thanks, rodchar
9
by: jacob navia | last post by:
??? Not that I miss his posts, but somehow I find sad that somebody disappears from view and nobody gives a damm. Anybody knows what happened to him? He had lost is job, and was looking for...
3
by: Giampaolo Rodola' | last post by:
http://groups.google.com/group/python-dev2 It seems it no longer exists. What happened?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.