Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Codejock alternative to CDialogBar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Codejock alternative to CDialogBar

 Post Reply Post Reply
Author
Message
CyberSky View Drop Down
Groupie
Groupie


Joined: 15 February 2010
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote CyberSky Quote  Post ReplyReply Direct Link To This Post Topic: Codejock alternative to CDialogBar
    Posted: 11 April 2010 at 8:34pm
My program uses a docked CDialogBar for a "control panel" along the left or right size of the window. I want to replace this with a nicer-looking Codejock alternative, such as a docking pane or CXTPDialogBar. My problem is that unlike the standard MFC CDialogBar, neither of the alternatives automatically size themselves to the dialog template.
 
I checked the samples, and CommandBars.ActionsSample uses a CXTPDialogBar, and it looks okay when I first run the program, but if I resize the dialog and then rebuilt the program, the dialog bar's controls are cut off by the window's edge. I also tried using docking panes but have the same trouble. I know about the SetSize() method but can't seem to programmatically determine the size that I need to pass so that the entire dialog appears in the pane with even margins around it.
 
If anybody has dealt with this and could give me some pointers, I'd be grateful. Maybe it's obvious, but I'm really frustrated right now and a bit worried. Using the Codejock product has been more work than I imagined, but so far I've eventually managed to make things work.
 
Am using VS2008 on Windows 7 64-bit, Xtreme Toolkit Pro 13.3.1.
 
Back to Top
Hieracosphinx View Drop Down
Newbie
Newbie
Avatar

Joined: 22 January 2010
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hieracosphinx Quote  Post ReplyReply Direct Link To This Post Posted: 10 September 2010 at 11:00am
I had the exact same problem and have just solved it.  The solution that works for me is to restore the template size to the CXTPDialogBar after loading the command bars from registry or serialized storage.

My structure to support this:

1. derive CMyDlgBar from MFC CDialog.  CDialogBar does not seem to work in all kinds of ways.  (I am on VS 2002, MFC 7.)
You will need access to the template size so:

BOOL CMyDlgBar::OnInitDialog(CDataExchange* pDX)
{
  .
  .
  CRect rc;
  GetWindowRect(rc);
  ScreenToClient(rc);
  m_size = rc.Size();
  .
  .
}

CSize CMyDlgBar::GetSize()
{
  return m_size:
}

2. Add a dockbar (CXTPDialogBar) to CommandBars, connecting my bar as child, then set the size.

void CMainFrame::CreateBar(int nID, LPCTSTR name, CMyDlgBar* pDlgBar, BOOL hideAtStart)
{
    CXTPCommandBars* pCommandBars = GetCommandBars();
    CXTPDialogBar* pBar = (CXTPDialogBar*)pCommandBars->Add(name,
        xtpBarTop, RUNTIME_CLASS(CXTPDialogBar));
    pBar->SetBarID(nID);
    pBar->EnableDocking(xtpFlagAlignTop|xtpFlagAlignBottom|xtpFlagStretched);
    pBar->ModifyStyle(0, WS_CLIPCHILDREN|WS_CLIPSIBLINGS);
    pBar->SetCloseable(FALSE);
    pBar->SetResizable(FALSE);
    pDlgBar->Create(pBar);
    pDlgBar->ShowWindow(SW_SHOW);
 
    pBar->SetChild(pDlgBar);
    pBar->SetSize(pDlgBar->GetSize());   // Note, this only changes the height of a docked bar.

    pBar->SetVisible( ! hideAtStart);
}

3. Each time you load the command bars from storage, the dock size may be old so you will need
something to reset it after loading:  (I have a workspace library for users to create their own layouts.)
 
void CMainFrame::SetSizeDlgBarDockToTemplate(int nDockID, CMyDlgBar* pDlgBar)
{
    CXTPCommandBars* pCommandBars = GetCommandBars();
    CXTPDialogBar* pBar = (CXTPDialogBar*)pCommandBars->GetToolBar(nDockID);
    CSize sz = pDlgBar->GetSize();
    pBar->SetSize(sz);
}

Hope this helps.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.