15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


ON_UPDATE_COMMAND_UI in dialog

John.Bell@xcellenet.com
Friday, September 27, 1996

Environment: VC++ 4.1, Win95

I have a class that is based on CFrameWnd and implements an editor. When I 
create this editor class from a modal dialog, I don't get the ON_UPDATE_
COMMAND_UI messages to update the menus etc. because the dialog doesn't 
handle the OnIdle().
I could implement a timer to update my interface, but I would prefer getting 
an idle message somehow.
If a timer is unavoidable how could I trigger the ON_UPDATE_COMMANDs? Could 
I send a WM_IDLEUPDATECMDUI to do this?

Thank you in advance.

John



Eric Kenslow -- kenslowe@cdsnet.net
Sunday, September 29, 1996

[Mini-digest: 2 responses]

First off, no, sending the WM_IDLEUPDATECMDUI doesn't work (at least, not
in the simplistic way in which I tried it).

The way I got this to work from a dialog was by implementing my own message
loop, making my dialog-based application's dialog modeless, rather than
modal.  Here is how I modified MyApp::InitInstance() (this is taken pretty
much directly from books online, BTW):

    CMyAppDlg dlg;
    m_pMainWnd = &dlg;

    dlg.Create( IDD_MY_DIALOG );

    while( ::IsWindow( dlg.GetSafeHwnd() ) )
      {
      MSG msg;
      while( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
        {
        PumpMessage();
        }
      // let MFC do its idle processing
      LONG lIdle = 0;
      while ( ::AfxGetApp()->OnIdle(lIdle++ ) )
        ;
      }

/* Eric Kenslow - Digital Lighthouse Inc.
 * webmaster@digilight.com
 * http://www.digilight.com
 */



----------
> From: John.Bell@xcellenet.com
> To: mfc-l@netcom.com
> Subject: ON_UPDATE_COMMAND_UI in dialog
> Date: Friday, September 27, 1996 5:00 AM
> 
> Environment: VC++ 4.1, Win95
> 
> I have a class that is based on CFrameWnd and implements an editor. When
I 
> create this editor class from a modal dialog, I don't get the ON_UPDATE_
> COMMAND_UI messages to update the menus etc. because the dialog doesn't 
> handle the OnIdle().
> I could implement a timer to update my interface, but I would prefer
getting 
> an idle message somehow.
> If a timer is unavoidable how could I trigger the ON_UPDATE_COMMANDs?
Could 
> I send a WM_IDLEUPDATECMDUI to do this?
> 
> Thank you in advance.
> 
> John
-----From: ganeshs@nationwide.com

    Check out  KB article Q123158...  The article's main emphasis  is on
adding  control bars  to  dialogs,  but handling  menu  updates is  also
explained. Since you're using VC++ 4.1/Win  95, the approach is the same
for modal as well as modeless dialogs.

/ ___|    / ___| __ _ _ __   ___  ___| |    I do not speak for
\___ \   | |  _ / _` | '_ \ / _ \/ __| '_ \ Tata   Unisys   or
 ___) |  | |_| | (_| | | | |  __/\__ \ | | |Nationwide    Ins.
|____(_)  \____|\__,_|_| |_|\___||___/_| |_|------------------



Lance Lovette -- lovette@iftech.com
Friday, October 04, 1996

>>> I have a class that is based on CFrameWnd and implements an
>>> editor. When I create this editor class from a modal dialog,
>>> I don't get the ON_UPDATE_COMMAND_UI messages to update the
>> menus etc. because the dialog doesn't handle the OnIdle().
>> I could implement a timer to update my interface, but I would
>>> prefer getting  an idle message somehow. If a timer is unavoidable
>>> how could I trigger the ON_UPDATE_COMMANDs? Could I send a
>>> WM_IDLEUPDATECMDUI to do this?

If memory serves, there is a Microsoft Systems Journal article that
describes this. There is also a chapter in the 2nd edition of the book
"Developing Professional Applications in Windows 95 and NT Using MFC"
(due out by the end of the month) that gives you a CIdleUpdateDialog
you can derive your dialogs from to get this exact behavior.

Lance
lovette@iftech.com

+-------------------------------------------------------------------+
Interface Technologies, Inc.

For a collection of free tutorials covering a variety of programming
and computer-related topics such as Visual C++, MFC, and Windows NT
check out the ITI On-line Training Center at http://www.iftech.com.





| Вернуться в корень Архива |