button in dialog bar 
Author Message
 button in dialog bar

I created a dialog bar with a button in it using the resource editor.   I
then placed the following in MainFrm.h

          CDialogBar m_DialogBar;

In CMainFrame::OnCreate I added

          if (!m_m_DialogBar.Create( this,
                  IDD_DIALOG_BAR,
                  CBRS_TOP,
                  IDD_DIALOG_BAR ))
          return -1;

         m_DialogBar.EnableDocking( CBRS_ALIGN_TOP );
         DockControlBar(&m_DialogBar, AFX_IDW_DOCKBAR_TOP);

The button handler is CMainFrame::OnStop().  Inside this function I have the
line

         m_DialogBar.GetDlgItem( IDC_STOP )->EnableWindow( FALSE );

What I want to happen is that when this button is pressed it becomes
disabled.

What is happening, however, is that when the button is pressed, the button
is momentarily greyed out, but becomes re-enabled as soon as this function
is exited.

What do I need to do to make it stay disabled permanently?

-John



Fri, 24 Nov 2000 03:00:00 GMT  
 button in dialog bar

John,

You might try to add a message handle "UPDATE_COMMAND_UI" for this dialog
bar
and also create a global boolean variable. For example,

Declare this variable:
BOOL dialogbar_stop_enable=TRUE;

Add a message handle for "IDC_STOP" in AFX_MSG_MAP:
ON_UPDATE_COMMAND_UI(IDC_STOP, OnUpdateDialogBarStop)

Move the statement into this function:
void CMainFrame::OnUpdateDialogBarStop(CCmdUI* pCmdUI)
{
     // TODO: Add your command update UI handler code here

    m_DialogBar.GetDlgItem( IDC_STOP )->EnableWindow(dialogbar_stop_enable);

Quote:
}

In CMainFrame::OnStop() function, toggle the flag:
dialogbar_stop_enable=FASE;

These changes may disable the stop button depending on the flag at run time.

Good luck.

Allen


Quote:
>I created a dialog bar with a button in it using the resource editor.   I
>then placed the following in MainFrm.h

>          CDialogBar m_DialogBar;

>In CMainFrame::OnCreate I added

>          if (!m_m_DialogBar.Create( this,
>                  IDD_DIALOG_BAR,
>                  CBRS_TOP,
>                  IDD_DIALOG_BAR ))
>          return -1;

>         m_DialogBar.EnableDocking( CBRS_ALIGN_TOP );
>         DockControlBar(&m_DialogBar, AFX_IDW_DOCKBAR_TOP);

>The button handler is CMainFrame::OnStop().  Inside this function I have
the
>line

>         m_DialogBar.GetDlgItem( IDC_STOP )->EnableWindow( FALSE );

>What I want to happen is that when this button is pressed it becomes
>disabled.

>What is happening, however, is that when the button is pressed, the button
>is momentarily greyed out, but becomes re-enabled as soon as this function
>is exited.

>What do I need to do to make it stay disabled permanently?

>-John



Sat, 25 Nov 2000 03:00:00 GMT  
 button in dialog bar

How did you create the OnStop() handler for the button?  Did you use class
wizard?  If you did, it won't work!  You can't use Class Wizard for Dialog
Bars.
You have to create the message map youself,



Sun, 26 Nov 2000 03:00:00 GMT  
 button in dialog bar

Thanks for your help.  There was one small error in your example.  It turns
out that buttons inside any control bar have to be treated like menu items.
This means that the way to grey out a button in the OnUpdateDialogBarStop()
function is to include this line

        pCmdUI->Enable(dialogbar_stop_enable)

rather than the EnableWindow() calll.

Again, thank.  If it weren't  for your help I would never have discovered
the control bar/menu similarity.

John

Quote:

>John,

>You might try to add a message handle "UPDATE_COMMAND_UI" for this dialog
>bar
>and also create a global boolean variable. For example,

>Declare this variable:
>BOOL dialogbar_stop_enable=TRUE;

>Add a message handle for "IDC_STOP" in AFX_MSG_MAP:
>ON_UPDATE_COMMAND_UI(IDC_STOP, OnUpdateDialogBarStop)

>Move the statement into this function:
>void CMainFrame::OnUpdateDialogBarStop(CCmdUI* pCmdUI)
>{
>     // TODO: Add your command update UI handler code here

   m_DialogBar.GetDlgItem( IDC_STOP )->EnableWindow(dialogbar_stop_enable);

- Show quoted text -

Quote:

>}

>In CMainFrame::OnStop() function, toggle the flag:
>dialogbar_stop_enable=FASE;

>These changes may disable the stop button depending on the flag at run
time.

>Good luck.

>Allen



>>I created a dialog bar with a button in it using the resource editor.   I
>>then placed the following in MainFrm.h

>>          CDialogBar m_DialogBar;

>>In CMainFrame::OnCreate I added

>>          if (!m_m_DialogBar.Create( this,
>>                  IDD_DIALOG_BAR,
>>                  CBRS_TOP,
>>                  IDD_DIALOG_BAR ))
>>          return -1;

>>         m_DialogBar.EnableDocking( CBRS_ALIGN_TOP );
>>         DockControlBar(&m_DialogBar, AFX_IDW_DOCKBAR_TOP);

>>The button handler is CMainFrame::OnStop().  Inside this function I have
>the
>>line

>>         m_DialogBar.GetDlgItem( IDC_STOP )->EnableWindow( FALSE );

>>What I want to happen is that when this button is pressed it becomes
>>disabled.

>>What is happening, however, is that when the button is pressed, the button
>>is momentarily greyed out, but becomes re-enabled as soon as this function
>>is exited.

>>What do I need to do to make it stay disabled permanently?

>>-John



Tue, 28 Nov 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Bitmap buttons and dialog bars

2. button in dialog bar

3. button on dialog bar always disabled?

4. Buttons in Dialog Bar

5. How do I Enable / Disable button in Dialog Bar?

6. Dialog Bars and Bitmap Buttons

7. how can i add menu and button bar to a dialog

8. Buttons on a dialog bar

9. HELP NEEDED: Modal Dialog pops up with own button in task bar

10. Dialog Bars and Buttons

11. Detecting dialog bar being hidden by command button

12. Launch dialog from Floating Tool Bar by double clicking on a button

 

 
Powered by phpBB® Forum Software