I want to make them is equal but can’t get the real size of Dockbar.
Who know how to get the real size of Dockbar Size ?
I want to make them is equal but can’t get the real size of Dockbar.
Who know how to get the real size of Dockbar Size ?
Are you using a Rhino_DotNet dockbar?
@dale
Yes, I create the dockbar like below.
I find the reason is SetInitialSizeDockedHorz.
How to solve it ?
Code 1: Set initial size
public DockBarMainDlg(Guid id, string name, Control control) : base(id, name, control) { bool bDockH = SetInitialSizeDockedHorz(new Size(control.Width, control.Height));
Code 2: create dockbar
// Create our user control
m_DockBarMainCtrl = new DockBarMainCtrl();
// Create our dock bar
m_DockBarMainDlg = new DockBarMainDlg( DockBarMainDlg.DockBarId(), “ModuleBar”, m_DockBarMainCtrl );
// Register our dock bar
MRhinoDockBarManager.CreateRhinoDockBar(
this,
m_DockBarMainDlg,
false, // Don’t show yet…
MRhinoUiDockBar.DockLocation.top,
MRhinoUiDockBar.DockStyle.top,
new Point(0, 0)
);
m_DockBarMainDlg.Initialize();
MRhinoDockBarManager.ShowDockBar( DockBarMainDlg.DockBarId(), true, false );
@JohnM, is this something you can help with?
I wrote you a function that will get the client rectangle for a dock site:
static bool GetDockBarClientRectangle(UINT dockSite, CRect& rect)
{
// Need to make sure the Rhino module instance it current so the
// cast operaters will work correctly
AFX_MANAGE_STATE(RhinoApp().RhinoModuleState());
// Get the main Rhino frame window
HWND hwnd_main = RhinoApp().MainWnd();
if (hwnd_main == NULL)
return false;
CWnd* main_window = CWnd::FromHandle(hwnd_main);
if (main_window == NULL)
return false;
CFrameWnd* frame = dynamic_cast<CFrameWnd*>(main_window);
if (frame == NULL)
return false;
// Get the CDockBar (docking location)
CControlBar* bar = frame->GetControlBar(dockSite);
if (bar == NULL || !bar->IsVisible())
return false;
// Get the client rectangle for the top dock bar
bar->GetClientRect(rect);
return true;
}
CRhinoCommand::result CCommandSampleCppPlugIn::RunCommand( const CRhinoCommandContext& context )
{
const UINT dock_bars[] = { AFX_IDW_DOCKBAR_TOP, AFX_IDW_DOCKBAR_BOTTOM, AFX_IDW_DOCKBAR_LEFT, AFX_IDW_DOCKBAR_RIGHT };
const wchar_t* dock_bar_strings [] = { L"AFX_IDW_DOCKBAR_TOP", L"AFX_IDW_DOCKBAR_BOTTOM", L"AFX_IDW_DOCKBAR_LEFT", L"AFX_IDW_DOCKBAR_RIGHT" };
const int count = _countof(dock_bars);
for (int i = 0; i < count; i++)
{
UINT bar = dock_bars[i];
CRect r;
if (GetDockBarClientRectangle(bar, r))
RhinoApp().Print(L"%s Dock site rectangle:\tWidth:%d\tHeight:%d\n", dock_bar_strings[i], r.Width(), r.Height());
else
RhinoApp().Print(L"Unable to calculate the %s dock site rectangle\n", dock_bar_strings[i]);
}
return CRhinoCommand::success;
}
Thanks ! John:grinning: