Subject |
Author |
Date |
|
Robert Webb
|
Aug 2, 2009 - 11:34 PM
|
I may have missed something, but the sample code all seems to shows control bars with only a single control in them, such as a tree or list, which resizes with the control bar. I wish to have a tree control with some extra buttons at the bottom. But CExtControlBar is not derived from CExtResizableDialog, so I can’t use the auto-resizing commands. What’s the best way to do this with Prof-UIS? Thanks, Rob.
|
|
Technical Support
|
Aug 6, 2009 - 10:33 AM
|
You should override the OnCmdMsg() virtual method in the dialog C++ class which is used for creating a dialog window inside the control bar:
BOOL CYourDialog::OnCmdMsg(
UINT nID,
int nCode,
void * pExtra,
AFX_CMDHANDLERINFO * pHandlerInfo
)
{
ASSERT_VALID( this );
CFrameWnd * pFrameWnd = GetParentFrame();
ASSERT_VALID( pFrameWnd );
if( pFrameWnd->IsKindOf( RUNTIME_CLASS(CMiniFrameWnd) ) ) // bar is floating?
{
pFrameWnd = pFrameWnd->GetParentFrame();
ASSERT_VALID( pFrameWnd );
}
if( nID == ID_BUTTON_1 || nID == ID_BUTTON_2 || nID == ID_BUTTON_3 || . . . )
{
if( pFrameWnd->OnCmdMsg(
nID,
nCode,
pExtra,
pHandlerInfo
)
)
return TRUE;
}
return
CBaseOfYourDialog::OnCmdMsg(
nID,
nCode,
pExtra,
pHandlerInfo
);
} If you are using button common controls, then you should re-direct the OnCmdMsg() method invocations only for those dialog buttons which have the command handlers in the main frame window. The command updating invocations are not performed for button dialog controls. If you are using internal toolbar with buttons in your dialog, then both the command hander and updating hander invocations will be redirected to the mail frame window.
|
|
Robert Webb
|
Aug 6, 2009 - 9:21 PM
|
Thanks. That works as far as handling the messages from the buttons goes. However the buttons still don’t update correctly (they’re not pushed in or greyed out when they should be). It seems the dialog’s OnCmdMsg() is never called to update the buttons. What would be the best way to do this? The buttons are also missing their tooltips. Ideally it would be nice for updates and tips to be handled by the command manager just like the toolbar buttons. Thanks, Rob.
|
|
Technical Support
|
Aug 10, 2009 - 6:19 AM
|
The command updating queries are never sent by MFC for any HWND -based dialog controls. You should enable/disable dialog controls by invoking the CWnd::EnableWindow() API. You should check/uncheck button controls by invoking the CButton::SetCheck()() API.
|
|
Robert Webb
|
Aug 10, 2009 - 8:53 PM
|
I tried calling SetCheck() and EnableWindow() for the buttons during OnIdle() but for some reason these do not affect the buttons at all. I have no idea why. I also used SetTooltipText() but no tooltip appears. I looked at the ProfStudio example. The breakpoints control bar has buttons like I want, and for some reason the Update commands work for them, and they have tooltips. It creates an actual toolbar, whereas I am creating individual buttons. A toolbar is also HWND-based, although its buttons are not. Maybe that is the difference? I’ll try changing and see how it goes. Rob.
|
|
Robert Webb
|
Aug 10, 2009 - 9:56 PM
|
Hmm, another hurdle. Looks like a toolbar is the way to do what I want, and this toolbar will be part of the dialog and not dockable/movable. However looking at the ProfStudio sample, I can’t see how the toolbar is positioned. Seems it will always be placed at the top left, whereas I need my toolbar buttons elsewhere in the dialog. I tried calling SetWindowPos() for the toolbar in OnInitDialog(), but it changes nothing. I guess it’s docked. How can I choose where it goes on the dialog? Thanks, Rob.
|
|
Technical Support
|
Aug 11, 2009 - 12:30 PM
|
The toolbars are kind of MFC control bars and they are able to position themselves near tje borders of their parent windows automatically. Please take a look at the CProfStudioBreakpointsView class in the ProfStudio sample application. This class implements dialog window inside the Breakpoints resizable control bar. The Breakpoints window is the dialog window based on the IDD_DIALOG_BREAKPOINTS dialog template resource that contains one toolbar control (custom dialog control) and one list view control. The CProfStudioBreakpointsView class invokes the RepositionBars(0,0xFFFF,IDC_LIST_BREAKPOINTS); code at the end of the CProfStudioBreakpointsView::OnInitDialog() and CProfStudioBreakpointsView::OnSize() methods. The CWnd::RepositionBars() method places all the control bar windows with the dialog control identifiers in range 0...0xFFFF near the borders of the Breakpoints dialog and the window with the IDC_LIST_BREAKPOINTS dialog control identifier is repositioned to occupy the rest central free space of the Breakpoints dialog. The toolbar window is positioned at the top of the dialog because the IDC_BREAKPOINTS_TOOLBAR dialog control has the 0x50002034 style set which contains the CBRS_ALIGN_TOP (0x2000 ) control bar style.
|
|
Robert Webb
|
Aug 10, 2009 - 2:27 AM
|
Any answer to this? I tried using ON_UPDATE_COMMAND_UI in either the dialog or the control bar containing it, but the handlers never get called. I also overrode OnCmdMsg() in both and in the main frame, but again it is never called with the CN_UPDATE_COMMAND_UI code for buttons on my dialog. How do I get the buttons to update? And please don’t forget about tooltips too. Thanks, Rob.
|
|
Technical Support
|
Aug 11, 2009 - 12:29 PM
|
The ProfStudio sample contains many bars similar to Breakpoints bar and they use an inner toolbar window rather than button windows on the dialog surface. As we said before, the toolbars are well updated via MFC’s command updating mechanism.
|
|
Technical Support
|
Aug 4, 2009 - 1:51 AM
|
The CExtControlBar class is designed as a container of one child window only. This child window is always automatically resized to cover the entire control bar’s client area. You should create a child CExtResizableDialog window inside the control bar. The ProfStudio sample application contains many control bars with child container windows, including resizable dialogs.
|
|
Robert Webb
|
Aug 4, 2009 - 12:42 AM
|
On a similar note, how do I load a dialog resource into a control bar? Is it possible to create a CExtResizableDialog as a child of a CExtControlBar? Will there be problems since the CExtResizableDialog wants to be a top level window? If I could do this it would presumably fix my above problem too. Thanks, Rob.
|
|
Technical Support
|
Aug 4, 2009 - 9:15 AM
|
There are no problems with child resizable dialogs created inside control bars. Please create some dialog template resource, remove caption and borders from it, set on its Clip Siblings and Clip Children options and set its type to Child - not Popup, not Resizing. The create the classic C++ dialog class with everything you need and derive it from the CExtResizableDialog class. Then add the main frame’s property like:
CYourDialogClassNameHere m_wndYourDlg;
Then create dialog window as child of some resizable control bar in the main frame’s OnCreate() handler method: if( ! m_wndYourDlg.Create( CYourDialogClassNameHere::IDD, &m_wndSomeExtControlBar ) )
{
ASSERT( FALSE);
return -1;
}
m_wndYourDlg.ShowSizeGrip( FALSE );
That’s all. The resizable dialog is created inside control bar. It’s the child dialog - not popup and not top level.
|
|
Robert Webb
|
Aug 5, 2009 - 9:50 PM
|
Ah, thanks for the excellent and detailed reply. I have it working now. Rob.
|
|
Robert Webb
|
Aug 6, 2009 - 1:32 AM
|
Ah, another question. I have some buttons on my control bar dialog which have the same IDs as other buttons on toolbars elsewhere. My toolbar buttons work, but so far my dialog buttons do not. How can I tell some controls in the dialog to be handled by the main frame instead? That is, when clicked, the message should go to the frame, and the OnUpdate should also be handled by the frame. Would be nice if the tooltips appearing for the toolbar buttons appeared on the dialog buttons too. Thanks, Rob.
|