Link to home
Start Free TrialLog in
Avatar of rrashedi
rrashedi

asked on

How to disable dialogbar from floating?


I have a dialogbar that is allowed to be docked either to the top or bottom of the frame window. However, I would like to disable it from floating. How?
Avatar of KurtVon
KurtVon

First, override the OnMove command like so:

void CMyBar::OnMove(int x, int y)
{
    CDialogBar::OnMove(x, y);

    if (IsFloating())
        AfxGetMainWnd()->PostMessage(WM_USER, 0, (LPARAM)this);
}

then, in the main frame, catch the WM_USER message and call

LRESULT CMainFrame::OnUserMessage(WPARAM wParam, LPARAM lParam)
{
    DockControlBar((CMyBar*)lParam);
    return 0;
}

And the bar is still dragable between docking points, but auto-redocks to the last position if the user tries to float it.
Avatar of rrashedi

ASKER


Thanks for your comment.

Unfortunately, the CMyBar::OnMove() is never executed when the bar is dragged from its docked position. I think when the bar is floating the CMiniFrameWnd::OnMove is called instead.
Hmm, the test program I threw off worked fine.  Are you sure you have an ON_WM_MOVE in the message map?  Or maybe the window is a child window of the actual docking window?

Yes, the OnMove() implementation works. It is getting called properly when the bar is docked. But as soon as the bar becomes a floating bar, it is no longer accessed. I've verified this by placing a breakpoint and stepping through the code in debug mode.
Odd.  Is your bar derived from CControlBar?  Also, CBRS_FLOAT_MULTI should not be set in the EnableDocking call (I'm fairly certain that is not the default, though).

It is derived from CDialogBar class. It is EnabledDocked
with CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM style as follows:
   CMyBar->EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM);
Well, CDialogBar, when floated suddenly has the stye 0xcdcdcdcd which means the memory was not initialized.  This, of course, makes it CBRS_FLOAT_MULTI but I can't tell why.

I think I remember seeing something like this before, I just can't remember what does it, or why it is only at line 417 in DOCKCONT.CPP.

Let me think about it.  maybe I'll remember what caused that.
ASKER CERTIFIED SOLUTION
Avatar of KurtVon
KurtVon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It works great. Thanks for your assistance.