[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 803
  • Last Modified:

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?
0
rrashedi
Asked:
rrashedi
  • 5
  • 4
1 Solution
 
KurtVonCommented:
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.
0
 
rrashediAuthor Commented:

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.
0
 
KurtVonCommented:
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?
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
rrashediAuthor Commented:

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.
0
 
KurtVonCommented:
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).
0
 
rrashediAuthor Commented:

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);
0
 
KurtVonCommented:
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.
0
 
KurtVonCommented:
Okay, here's how to get around the CBRS_FLOAT_MULTI problem.  Just use the same code in the OnMove, but instead put it in the handler for WM_WINDOWPOSCHANGED.  I've tested and it works with a CDialogBar fine.

The message is the last one in the Class Wizard, and it definately gets called in all circumstances that I could think of.
0
 
rrashediAuthor Commented:
It works great. Thanks for your assistance.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now