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

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


Problems disabling controls (toolbar buttons).

Ronen Ashkenazi -- rashken@ms-israel.kla.com
Monday, December 02, 1996


Environment: VC++ 4.2b, NT 4.0 + SP1

Hi,

 I have an SDI application which includes a DialogBar with some buttons   
on it. One of the buttons, when pressed, displays a dialog box in the   
view area of the application. The dialog box is created with the Create()   
method of CDialog.
 I override the  OnInitDialog()  function to include code that disables   
the DialogBar button controls when my dialog is displayed. Code follows:

BOOL CKlautMainDlg::OnInitDialog()
{
 TC_ITEM tc;  // Used to set tab control properties.
 CMainFrame* w=(CMainFrame*)GetTopLevelFrame(); // Pointer to the main   
frame.

 CDialog::OnInitDialog();
 
 // Disable toolbar buttons.
 w->EnableKlautBtn(FALSE);
 w->EnableOlBtn(FALSE);
 w->EnableStatBtn(FALSE);

 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}

The problem is that when the dialog box is displayed I see the button   
turn gray (disabled) and then enabled back immediately. I can not   
understand the reason for this. I suppose that the framework enables the   
buttons in some way.

Any ideas ?

Thanks,
Ronen.




Ronen Ashkenazi -- rashken@ms-israel.kla.com
Wednesday, December 04, 1996


Environment: VC++ 4.2b, NT 4.0 + SP1

Hi,

 I have an SDI application which includes a DialogBar with some buttons   
on it. One of the buttons, when pressed, displays a dialog box in the   
view area of the application. The dialog box is created with the Create()   
method of CDialog.
 I override the  OnInitDialog()  function to include code that disables   
the DialogBar button controls when my dialog is displayed. Code follows:

BOOL CKlautMainDlg::OnInitDialog()
{
 TC_ITEM tc;  // Used to set tab control properties.
 CMainFrame* w=(CMainFrame*)GetTopLevelFrame(); // Pointer to the main   
frame.

 CDialog::OnInitDialog();
 
 // Disable toolbar buttons.
 w->EnableKlautBtn(FALSE);
 w->EnableOlBtn(FALSE);
 w->EnableStatBtn(FALSE);

 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}

The problem is that when the dialog box is displayed I see the button   
turn gray (disabled) and then enabled back immediately. I can not   
understand the reason for this. I suppose that the framework enables the   
buttons in some way.

Any ideas ?

Thanks,
Ronen.




Lin Sebastian Kayser -- Lin.Kayser@munich.netsurf.de
Wednesday, December 04, 1996

Ronen,

Please read your documentation on the user interface update handlers of =
your Document View architecture. Basically what you have to do is add an =
OnUpdateUiMyButton handler using Class Wizard and the ID of the button =
in your Dialog Bar. In this handler you check for the visibility of your =
dialog and enable/disable the button (you could also push/release the =
button using SetCheck() - this would probably be more intuitive for your =
users).

As this again is not an "Advanced MFC-Question" this list was designed =
for, I would like to remember everybody that this list is no longer =
moderated. Please do not flood it with beginners questions - otherwise =
many professionals will probably unsubscribe. Also, as far as I know, =
this list was made for MFC-Questions - not SDK questions or database =
questions. I received about 6 messages about SQL wildcards this week. =
Those were definitely no MFC questions.

Now that the amount of messages has grown beyond the capabilities of our =
moderator (thank you very much David), we should show more discipline - =
otherwise this list will drown in miscellaneous stuff. BTW thanxalot to =
Mike B. for his continued (im)patience with all those questions....

Regards,
Lin



-----Original Message-----
From:	Ronen Ashkenazi [SMTP:rashken@ms-israel.kla.com]
Sent:	Monday, December 02, 1996 6:09 PM
To:	'mfcl'
Subject:	Problems disabling controls (toolbar buttons).


Environment: VC++ 4.2b, NT 4.0 + SP1

Hi,

 I have an SDI application which includes a DialogBar with some buttons  =
=20
on it. One of the buttons, when pressed, displays a dialog box in the  =20
view area of the application. The dialog box is created with the =
Create()  =20
method of CDialog.
 I override the  OnInitDialog()  function to include code that disables  =
=20
the DialogBar button controls when my dialog is displayed. Code follows:

BOOL CKlautMainDlg::OnInitDialog()
{
 TC_ITEM tc;  // Used to set tab control properties.
 CMainFrame* w=3D(CMainFrame*)GetTopLevelFrame(); // Pointer to the main =
 =20
frame.

 CDialog::OnInitDialog();
=20
 // Disable toolbar buttons.
 w->EnableKlautBtn(FALSE);
 w->EnableOlBtn(FALSE);
 w->EnableStatBtn(FALSE);

 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}

The problem is that when the dialog box is displayed I see the button  =20
turn gray (disabled) and then enabled back immediately. I can not  =20
understand the reason for this. I suppose that the framework enables the =
 =20
buttons in some way.

Any ideas ?

Thanks,
Ronen.





=?iso-8859-1?Q?Jos=E9_Gabriel_Gayt=E1n_Manzano?= -- jgaytan@infosel.com.mx
Wednesday, December 04, 1996

[Mini-digest: 3 responses]

The buttons are refreshing all the time, that's why you see first gray
and then enable.
You have to use the message ON_UPDATE_COMMAND_UI
and in your code you need something like this:

    if (your_decision)
       pCmdUI->Enable(FALSE);
    else
       pCmdUI->Enable(TRUE);

Saludos!

>----------
>From: 	Ronen Ashkenazi[SMTP:rashken@ms-israel.kla.com]
>Sent: 	Monday, December 02, 1996 12:09PM
>To: 	'mfcl'
>Subject: 	Problems disabling controls (toolbar buttons).
>
>
>Environment: VC++ 4.2b, NT 4.0 + SP1
>
>Hi,
>
> I have an SDI application which includes a DialogBar with some buttons
>on it. One of the buttons, when pressed, displays a dialog box in the
>view area of the application. The dialog box is created with the
>Create() method of CDialog.
> I override the  OnInitDialog()  function to include code that disables
>the DialogBar button controls when my dialog is displayed. Code
>follows:
>
>BOOL CKlautMainDlg::OnInitDialog()
>{
> TC_ITEM tc;  // Used to set tab control properties.
> CMainFrame* w=(CMainFrame*)GetTopLevelFrame(); // Pointer to the main
>frame.
>
> CDialog::OnInitDialog();
> 
> // Disable toolbar buttons.
> w->EnableKlautBtn(FALSE);
> w->EnableOlBtn(FALSE);
> w->EnableStatBtn(FALSE);
>
> return TRUE;  // return TRUE unless you set the focus to a control
>               // EXCEPTION: OCX Property Pages should return FALSE
>}
>
>The problem is that when the dialog box is displayed I see the button
>turn gray (disabled) and then enabled back immediately. I can not
>understand the reason for this. I suppose that the framework enables
>the buttons in some way.
>
>Any ideas ?
>
>Thanks,
>Ronen.
>
>
-----From: Mihir Dalal 


Try disabling the toolbar controls just before you call the OnCreate() 
to create your dialog box. That should solve the problem. Your code for 
the BN_CLICKED for that particular button would look something like this

CYourClass:: OnToolBarBtnClicked()
{
   // Disable toolbar buttons.
   w->EnableKlautBtn(FALSE);
   w->EnableOlBtn(FALSE);  
   w->EnableStatBtn(FALSE);
   CYourDialog dlg;
   dlg.OnCreate();
}

Also re-enable the toolbar buttons in the OnOK() message handler of your 
dialog box. 

I hope that helps.

Mihir.
(m_dalal@ece.concordia.ca)


On Mon, 2 Dec 1996, Ronen Ashkenazi wrote:

 
  Environment: VC++ 4.2b, NT 4.0 + SP1
> 
> Hi,
> 
>  I have an SDI application which includes a DialogBar with some buttons   
> on it. One of the buttons, when pressed, displays a dialog box in the   
> view area of the application. The dialog box is created with the Create()   
> method of CDialog.
>  I override the  OnInitDialog()  function to include code that disables   
> the DialogBar button controls when my dialog is displayed. Code follows:
> 
> BOOL CKlautMainDlg::OnInitDialog()
> {
>  TC_ITEM tc;  // Used to set tab control properties.
>  CMainFrame* w=(CMainFrame*)GetTopLevelFrame(); // Pointer to the main   
> frame.
> 
>  CDialog::OnInitDialog();
>  
>  // Disable toolbar buttons.
>  w->EnableKlautBtn(FALSE);
>  w->EnableOlBtn(FALSE);
>  w->EnableStatBtn(FALSE);
> 
>  return TRUE;  // return TRUE unless you set the focus to a control
>                // EXCEPTION: OCX Property Pages should return FALSE
> }
> 
> The problem is that when the dialog box is displayed I see the button   
> turn gray (disabled) and then enabled back immediately. I can not   
> understand the reason for this. I suppose that the framework enables the   
> buttons in some way.
> 
> Any ideas ?
> 
> Thanks,
> Ronen.
> 
-----From: Jim Lawson Williams 

At 10:09 AM 2/12/96 PST, you wrote:
>
>Environment: VC++ 4.2b, NT 4.0 + SP1
>
>Hi,
>
> I have an SDI application which includes a DialogBar with some buttons  =
=20
>on it.   =20
                
>The problem is that when the dialog box is displayed I see the button  =20
>turn gray (disabled) and then enabled back immediately. I can not  =20
>understand the reason for this. I suppose that the framework enables the  =
=20
>buttons in some way.

G'day!

You need to plug each Enable() into Wizard-code to give something like

void CMainFrame::OnUpdateButtonX(CCmdUI* pCmdUI)
{=20
	pCmdUI->Enable(m_bButtonX);
}

>From TN031 in "Books OnLine":

CCmdUI Support for CDialogBar
Dialog bar buttons should be updated through the ON_UPDATE_COMMAND_UI=
 handler mechanism. At idle time, the dialog bar will call the=
 ON_UPDATE_COMMAND_UI handler with the command ID of all the buttons that=
 have a ID >=3D 0x8000 (that is, in the range of command IDs).
The ON_UPDATE_COMMAND_UI handler can call:
=B7	Enable:  to enable or disable the button.
=B7	SetText:  to change the text of the button.
 =20
Customization can be done through standard window manager APIs.

Regards,
Jim LW


>From the BBC's "Barchester Chronicles":

    "I know that ultimately we are not supposed to understand.
    But I also know that we must try."

       -- the Reverend Septimus Harding, C++ programmer



Mark Conway -- mrc@mfltd.co.uk
Monday, December 09, 1996

Control bars are updated via the idle mechanism - you need to include
ON_UPDATE handlers in your mainframe/app/view to set the status of these
buttons. What you're doing here is disabling the buttons, and the next
time the idle time gets in, it enables them again.

>----------
>From: 	Ronen Ashkenazi[SMTP:rashken@ms-israel.kla.com]
>Sent: 	04 December 1996 20:44
>To: 	'mfcl'
>Subject: 	Problems disabling controls (toolbar buttons).
>
>
>Environment: VC++ 4.2b, NT 4.0 + SP1
>
>Hi,
>
> I have an SDI application which includes a DialogBar with some buttons on
>it. One of the buttons, when pressed, displays a dialog box in the view area
>of the application. The dialog box is created with the Create() method of
>CDialog.
> I override the  OnInitDialog()  function to include code that disables the
>DialogBar button controls when my dialog is displayed. Code follows:
>
>BOOL CKlautMainDlg::OnInitDialog()
>{
> TC_ITEM tc;  // Used to set tab control properties.
> CMainFrame* w=(CMainFrame*)GetTopLevelFrame(); // Pointer to the main frame.
>
> CDialog::OnInitDialog();
> 
> // Disable toolbar buttons.
> w->EnableKlautBtn(FALSE);
> w->EnableOlBtn(FALSE);
> w->EnableStatBtn(FALSE);
>
> return TRUE;  // return TRUE unless you set the focus to a control
>               // EXCEPTION: OCX Property Pages should return FALSE
>}
>
>The problem is that when the dialog box is displayed I see the button turn
>gray (disabled) and then enabled back immediately. I can not understand the
>reason for this. I suppose that the framework enables the buttons in some
>way.
>
>Any ideas ?
>
>Thanks,
>Ronen.
>
>




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