Buttons on CDialogBar
Christine Hagberg -- CHAGBERG@datx.com
Monday, December 09, 1996
Environment: Win95, VC++ 4.2-flat
Hi,
I am trying to add a button to a CDialogBar. I add the button with no
trouble and when the program runs the button is always disabled. Just
for kicks in the OnIdle function I enabled it, whenever I enable it is
immediately disabled.
I also added a button to the CTRLBARS code from the Dev Net and it does
the same thing. Any suggestions for adding buttons to CDialogBar's would
be much appreciated.
Thanks,
Chris
Vincent W. Mayfield -- vmax@gulf.net
Wednesday, December 11, 1996
[Mini-digest: 5 responses]
Christine,
I am not sure how you mean you are adding the button dynamically or in =
the resource editor. By what you stated in your e-mail I'll assume the =
resource editor. So here goes : Dialog bars are part of the main window =
and all of the control notifications are sent to the parent of the =
dialog bar. So if your application was an SDI application your dialog =
bar was probably attached to CMainFrame. So you must handle the messages =
in the parent which in this case is the main frame. If your application =
was an MDI then you need to handle the messages in the parent of the =
frame of the MDI frame you dialog is attached to. For further =
information take a look at the MFC Encyclopedia in the Visual C++ Books =
on line under Dialog Bars. This means you will have to put a message =
handler in your Frame for the button. It should then be enabled. Good =
Luck.
Vincent W. Mayfield
Senior Software Engineer
vmax@gulf.net
"It is better to beg for forgiveness than ask for permission."
----------
From: Christine Hagberg[SMTP:CHAGBERG@datx.com]
Sent: Monday, December 09, 1996 11:04 AM
To: 'MFC List'
Subject: Buttons on CDialogBar
Environment: Win95, VC++ 4.2-flat
Hi,
I am trying to add a button to a CDialogBar. I add the button with no =
=20
trouble and when the program runs the button is always disabled. Just =
for kicks in the OnIdle function I enabled it, whenever I enable it is =
immediately disabled.
I also added a button to the CTRLBARS code from the Dev Net and it does =
=20
the same thing. Any suggestions for adding buttons to CDialogBar's =
would =20
be much appreciated.
Thanks,
Chris =20
-----From: =?iso-8859-1?Q?Gunnar_=D6rn_Rafnsson?=
Chris
Add a commandhandler or updateui handler for your button
ON_COMMAND(ID_DIALOGBAR_BUTTON, OnDialogBarButton)
ON_UPDATE_COMMAND_UI(ID_DIALOGBAR_BUTTON, OnUpdateDialogBarButton)
to the message map where you want to handle messages from your button
Gunnar =D6rn Rafnsson
Taugagreining hf
Armuli 7b Reykjavik Iceland
E-mail : gor@nervus.is
WWW : http://www.nervus.is/gor/
----------
From: Christine Hagberg[SMTP:CHAGBERG@datx.com]
Sent: 12. desember 1996 09:13
To: 'MFC List'
Subject: Buttons on CDialogBar
Environment: Win95, VC++ 4.2-flat
Hi,
I am trying to add a button to a CDialogBar. I add the button with no =
=20
trouble and when the program runs the button is always disabled. Just =
for kicks in the OnIdle function I enabled it, whenever I enable it is =
immediately disabled.
I also added a button to the CTRLBARS code from the Dev Net and it does =
=20
the same thing. Any suggestions for adding buttons to CDialogBar's =
would =20
be much appreciated.
Thanks,
Chris =20
-----From: "Daniel Munoz"
Environment: VC++ 4.2, Win 95, NT 3.51, NT 4.00
Hi Chris,
just add manually to your MESSAGE_MAP a ON_UPDATE_COMMAND_UI handler and a
function to say TRUE !
BEGIN_MESSAGE_MAP(CDialogBar_Search, CDialogBar_DDX)
ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
ON_UPDATE_COMMAND_UI(IDC_BUTTON_TEST, OnUpdateButtonTest)
END_MESSAGE_MAP()
void CDialogBar_Test::OnUpdateButtonTest(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable (TRUE); //or whatever you want
}
Daniel Munoz
dmunoz@socabim.fr
-----From: Eric Bryant
Is you look into the MFC Online help on CDialogBar, it states that buttons
on a CDialogBar will be disabled by the framework unless you handle it
messages in its parent class.
I recently had the same problem, simply add an:
ON_COMMAND(, )
to either the CView or CMainFrame derived class (both are considered
parents of the CDialogBar) and it should work.
This is the "quick and dirty" method. Hopefully someone will give you a
more detailed explaination -- I am also curious.
Eric J. Bryant
InterWorld Technology Ventures, Inc.
Senior Support Engineer
On Mon, 9 Dec 1996, Christine Hagberg wrote:
>
> Environment: Win95, VC++ 4.2-flat
>
> Hi,
> I am trying to add a button to a CDialogBar. I add the button with no
> trouble and when the program runs the button is always disabled. Just
> for kicks in the OnIdle function I enabled it, whenever I enable it is
> immediately disabled.
>
> I also added a button to the CTRLBARS code from the Dev Net and it does
> the same thing. Any suggestions for adding buttons to CDialogBar's would
> be much appreciated.
>
> Thanks,
>
> Chris
>
-----From: "Mark"
I think you need to have that button appear in
a message map (whatever class will
handle the button being pressed).
ON_BN_CLICKED(IDC_BUTTON, OnButton)
(use class wizard to make life easier).
Mk
| Вернуться в корень Архива
|