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

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


Preventing floating of a toolbar

Brian Weeres -- bweeres@rescom.com
Tuesday, March 11, 1997

Environment: Visual C++ 4.2b  Windows NT 4.0

I have a toolbar which I programatically dock on the right side of a =
CMDChildWnd by doing the following in OnCreateClient

  EnableDocking(CBRS_ALIGN_RIGHT);
  // add the toolbar
  m_wndActionBar.Create(this);
  m_wndActionBar.LoadToolBar(IDR_ACTIONBAR);
  m_wndActionBar.SetBarStyle(...);
  m_wndActionBar.EnableDocking(CBRS_ALIGN_RIGHT);
  DockControlBar(&m_wndActionBar,AFX_IDW_DOCKBAR_RIGHT);

I'm probably missing something simple but I can't figure out how to =
prevent someone from floating this toolbar. I want it to always remain =
docked.

-----------------------------------------------
Brian Weeres
Rescom Ventures, Inc.
bweeres@rescom.com




Hans Wedemeyer -- hansw@sprintmail.com
Saturday, March 15, 1997

[Mini-digest: 3 responses]

Brian, maybe a solution in mfc-l(7856) I copied the important part.

regards 
Hans W

from mfc-l 7856
>From:  chakri@sunserv.cmc.stph.net
>Sent:  Tuesday, November 19, 1996 10:39 AM
>To:  mfc-l@netcom.com; Wayne Tang
>Subject:  [Q] Docking a dialog bar besides the Standard tool bar...
>What I wanted was to dock the dialog bar just adj. to the std. tool >bar.I am not able to do so, until I explicitly do it thru the cmd. hdlr >as shown below
># Code begins
>void CMainFrame::OnHelpTest()
>{
> CRect rect;
> m_wndToolBar.GetWindowRect(&rect);
> CRect rect1;
> CRect rect2;
> m_tinDialogBar.GetWindowRect(&rect1);
> long w =3D rect1.Width();
> long h =3D rect1.Height();
> rect2.top =3D rect.top;
> rect2.left =3D rect.right;
> rect2.right =3D rect2.left + w;
> rect2.bottom =3D rect2.top + h;
> DockControlBar(&m_tinDialogBar,
>   AFX_IDW_DOCKBAR_BOTTOM | AFX_IDW_DOCKBAR_TOP ,rect3);
>}
># Code ends here










Brian Weeres wrote:
> 
> Environment: Visual C++ 4.2b  Windows NT 4.0
> 
> I have a toolbar which I programatically dock on the right side of a CMDChildWnd by doing the following in OnCreateClient
> 
>   EnableDocking(CBRS_ALIGN_RIGHT);
>   // add the toolbar
>   m_wndActionBar.Create(this);
>   m_wndActionBar.LoadToolBar(IDR_ACTIONBAR);
>   m_wndActionBar.SetBarStyle(...);
>   m_wndActionBar.EnableDocking(CBRS_ALIGN_RIGHT);
>   DockControlBar(&m_wndActionBar,AFX_IDW_DOCKBAR_RIGHT);
> 
> I'm probably missing something simple but I can't figure out how to prevent someone from floating this toolbar. I want it to always remain docked.
> 
> -----------------------------------------------
> Brian Weeres
> Rescom Ventures, Inc.
> bweeres@rescom.com
-----From: Ben Burnett 

Brian Weeres wrote:

  I have a toolbar which I programatically dock on the right side of a
  CMDChildWnd by doing the following in OnCreateClient

Try setting the bar style to dock on the right and leave out the
EnableDocking() call, that should solve it.

Like this:

m_wndActionBar.Create(this);
m_wndActionBar.LoadToolBar(IDR_ACTIONBAR);
m_wndActionBar.SetBarStyle(CBRS_ALIGN_RIGHT | ... );

-----From: "Chris McKillop" 

:From: Brian Weeres 
:To: 'mfc-l@netcom.com'
:Subject: Preventing floating  of a toolbar
:Date: Tuesday, March 11, 1997 11:02 PM
:
:Environment: Visual C++ 4.2b  Windows NT 4.0
:
:I have a toolbar which I programatically dock on the right side of a
CMDChildWnd by doing the :following in OnCreateClient
:
:  EnableDocking(CBRS_ALIGN_RIGHT);
:  // add the toolbar
:  m_wndActionBar.Create(this);
:  m_wndActionBar.LoadToolBar(IDR_ACTIONBAR);
:  m_wndActionBar.SetBarStyle(...);
:  m_wndActionBar.EnableDocking(CBRS_ALIGN_RIGHT);
:  DockControlBar(&m_wndActionBar,AFX_IDW_DOCKBAR_RIGHT);
:
:I'm probably missing something simple but I can't figure out how to
prevent someone from floating :Lthis toolbar. I want it :to always remain
docked.

	This is really easy actually.  Although I have only been using MFC for
about
a week now (and finding it really easy after having done a couple of years
of
SDK coding), I think this will work.  Don't enable docking. :)  You might
also want to
try using CBRS_SIZE_FIXED in the toolbar setting, but if you don't enable
docking, I
don't think that this is needed either.  Some code that I am using at the
moment
looks like this....

    //
    // Create Play/Pause Toolbar
    //
    m_toolbar.Create( this,
                      WS_CHILD | WS_VISIBLE | CBRS_BOTTOM |
                      CBRS_SIZE_FIXED | CBRS_FLYBY );

    m_toolbar.LoadToolBar( IDR_TOOLBAR1 );

	
	Where IDR_TOOLBAR1 is a toolbar resource.  It also gives me the funky
flyby status bar messages (if you setup the statusbar correctly).  
I think if you actually use the Wizard things in VC++ (I cannot stand the
code they 
output, plus it breaks with my company's internal coding standards), some
of those 
window styles are default.  This code will create a toolbar at the bottom
of "this" 
that cannot be torn off from "this".

	Hope this helps...

		Chris

------------------------------------------------
cdmckill@focus-systems.on.ca

It's the end of the world as we know it, and I feel fine.
             - REM, "Document"




Become an MFC-L member | Вернуться в корень Архива |