Using ON_UPDATE_COMMAND_UI with controls

afxpriv.h has a message, WM_KICKIDLE, that is sent during idle processing. To get dialogs to work with the ON_UPDATE_COMMAND_UI message maps, you need to trap the kick idle message and call UpdateDialogControls.

In a dalog class header, add the following in the message map:

	afx_msg LRESULT OnKickIdle(WPARAM , LPARAM );

In the implementation file:

	#include <afxpriv.h>

In the message map add:
	ON_MESSAGE(WM_KICKIDLE, OnKickIdle)

Implement the function:

	LRESULT CMyDlg::OnKickIdle(WPARAM wParam, LPARAM lParam)
	{
		UpdateDialogControls(this, FALSE);
		return 0;
	}

I leave the bDisableIfNoHndler flag as FALSE so buttons without message map entries are not disabled.

You can now use ON_UPDATE_COMMAND_UI message maps for enabling/disabling controls, setting static text, etc.

It works really well when you have two or more radio buttons that enable/disable different groups of controls. Just have one OnUpdate... function for each group of controls that enables/disables depending on the radio button selected, use IsDlgButtonChecked. Then add a message map entry for each control.

To use ON_UPDATE_COMMAND_UI in form views.

The kick idle message doesn't work in form views, but there's another message in afxpriv.h called WM_IDLEUPDATECMDUI, that does.

In a form view class header, add the following in the message map:

	afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM , LPARAM );

In the implementation file:

	#include <afxpriv.h>

In the message map add:

	ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)

Implement the function:

	LRESULT CMyFormView::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
	{
		UpdateDialogControls(this, FALSE);
		return 0L;
	}

ON_UPDATE_COMMAND_UI can now be used as described above.

Updated 21 March 1998



Comments

  • Plancha ghd rosa de 2010, por lo que siempre será amado por los usuarios de ghd

    Posted by eaxzep811 on 07/25/2013 08:35pm

    Vendemos planchas ghd son la principal vendida a la nacionalidad danesa. Dado que las mujeres saben mejor cómo la belleza danesa. Por esta razón, son poco a poco y ghd daneses las mejores herramientas de diseño. Si te gusta nuestro producto, por favor visite nuestro sitio web para aprender más sobre nosotros en plancha ghd. Sorpresa dig.Ønsker esperando que le des a tu cabello un nuevo remedio que? Operación y pelo creativos planchas ghd con usted sin esfuerzo tuercen en el pelo, para que se alisadores perfekt.Ghd más sexy con el control exclusivo de temperatura digital, se puede ajustar para adaptarse a diferentes tipos de cabello y calentadores cerámicos avanzados para crear la superficie final brillo libre de estática . Cortes de cabello también cuenta con un nuevo modo de suspensión, voltaje universal, y un conector pin forma convertible 3-2. [url=http://planchaspeloghdes.qsite.dk/]GHD España[/url] Planchas GHD hacer mucho más que producir suaves, directamente diseños. Su propio estilo ofrece platos curvas y ofertas, por lo tanto, de la misma unidad de diseño que sólo tiene que hacer uso de corregir alguien bloquea también puede poner, cambiar y afluencia. Este particular elimina la necesidad real de una serie de problemáticas Recursos de diseño inodoro abajo encimera. pelo ghd australia claro que mi grupo es algo realmente hija de aspecto sencillo en la vida real. Además de eso, que he implementado ni siquiera tiene que ser un saludable dentro del estilo es mirar a un niño. Ciertamente, contiene los factores alentaron la confianza. Explícitamente, la próxima creación, Marca requerir mucha más confianza. Inicialmente innovador, yo me crié un aspecto visual para incorporar diversos confianza para ayudarle a mí personalmente. [url=http://comprar-ghd.manifo.com/]planchas ghd baratas[/url] que esté limpio y seco. Para lograr un cabello hermoso saludable, tratar de calentar el champú protección y profunda condición de su aire limpio cabello. Use champú protección contra el calor en el proceso de consolidación para proteger su pelo y lo mantendrá tu cabello limpio y blød.dit cabello seco, toalla de microfibra, van a absorber una gran cantidad de agua, luego retire una toalla ordinaria, a continuación, aplicar dejar en el aire, lo que ayudará a mantener el cabello en el agua, para evitar extra seco y nervioso. Cepille su pelo, y luego secar al aire o secar el pelo. De cualquier manera, el cabello debe estar completamente seco antes de pelo ghd plancha ud.Når liso tu cabello es seco, ya está listo para usar su pelo liso, se debe aplicar para cada componente del derecho a postularse para el pelo liso ghd antes de usar un spray de protección contra el calor y el aerosol de suero brillo. Trate de evitar más de la misma sección de cabello nuevo. Cuanto más se puede causar más daño

    Reply
  • Nike Draught Max+instagram, at one's desire you confine the color to bear up on your feet!

    Posted by madytreathy on 04/24/2013 05:45pm

    Recollect in 2008, if not earlier, when Nike launched ahead of the self-assured shoe color projects, the catchword "Whiz Your Colours", "Nike PhotoiD" scheme, [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] response has not been as hearty as expected. Have in mind, 2008 Canon IXUS 80 IS Digital prankster arcade but one 8 million pixels, Nokia, the mobile phone superstore is the at worst administration, NikeiD was support to color in the photos as a essence someone is concerned sneakers excise color, although exciting, but does provoke some. Instagram which communicate this item make sport and fundamental, Nike PHOTOiD homeopathic upgrade customization services, recently [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] released a new plan. That such iD can you realize pictures as instagram account shoe color, temporarily make available Nike Breeze Max shoes and Nike Style Max 1, Nike Feeling Max 90 953 options. Interested in children's shoes, you [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] can without exception vanish into thin air's valid website photoid.Nike.com, in besides to flip other people's originative work, or you can struggle to upload your own instagram photo, build your own Nike Mood Max.

    Reply
  • UpdateCmdUI for a modeless dialog in a dialog based application

    Posted by Legacy on 04/06/2000 12:00am

    Originally posted by: Anna

    I tried this code for my dialog based application.
    i dont have a frame wnd here but applied all the steps to the main dialog class instead of the frame wnd.
    please see the code:
    In the main dialog class, i put this message map entry and a handler to it.
    ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)

    LRESULT CMyDlg1::OnIdleUpdateCmdUI(WPARAM wParam,
    LPARAM lParam)
    {
    m_pViewDoc->SendMessage(WM_IDLEUPDATECMDUI);
    return 0L;
    }
    m_pViewDoc is a pointer to the modeless dialog(CViewDoc) which has a toolbar that needs the updatecmdUI.
    In the Modeless dialog i have the following code:
    ON_MESSAGE(WM_KICKIDLE, OnKickIdle) in the message map entry of this class.

    LRESULT CViewDoc::OnKickIdle(WPARAM wParam, LPARAM lParam)
    {
    UpdateDialogControls(this, FALSE);
    return 0;
    }
    I have UpdateCmdUI handlers for the toolbar buttons .
    this does not work . can anyone help me out.
    thanks.
    Anna

    Reply
  • Default() might be fine

    Posted by Legacy on 01/29/2000 12:00am

    Originally posted by: Petr Novotny

    It might be cosmetic, but it might not: Instead of 
    
    UpdateDialogControls(this,FALSE);
    return 0;
    I'd rather use
    UpdateDialogControls(this,FALSE);
    return Default();
    giving MFC/Windows chance to do more with this message if neccessary...

    Reply
  • ON_UPDATE_COMMAND_UI for Modeless Dialogs

    Posted by Legacy on 10/07/1998 12:00am

    Originally posted by: Tim McColl

    Modeless dialogs can't automatically use the WM_KICKIDLE message to start idle processing. This is because MFC uses it's own model dialog message loop that sends WM_KICKIDLE messages. But modeless dialogs use the standard dialog message loop in Windows. This one doesn't send WM_KICKIDLE messages.

    So by taking a look at how MFC allows dialog bars to do idle processing, this is the best I can come up with.

    1. Keep a pointer to the modeless dialog in the parent window that created the dialog. Frame or view.
    2. In the parent window add a message map for WM_IDLEUPDATECMDUI. This message is pumped out by the app's OnIdle loop.
    3. Send WM_IDLEUPDATECMDUI to the modeless dialog from the parent's OnIdleUpdateCmdUI function.
    4. Add a message map for WM_IDLEUPDATECMDUI in the dialog and call UpdateDialogControls
    5. Use ON_UPDATE_COMMAND_UI message maps as needed.

    Notes:
    WM_IDLEUPDATECMDUI is defined in afxpriv.h.
    You could send the dialog WM_KICKIDLE messages. I just used WM_IDLEUPDATECMDUI to fit in with the way MFC does things.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds