예제 #1
0
void CMergeEditFrame::ActivateFrame(int nCmdShow) 
{
	// load docking positions and sizes
	CDockState pDockState;
	pDockState.LoadState(_T("Settings"));
	if (EnsureValidDockState(pDockState)) // checks for valid so won't ASSERT
		SetDockState(pDockState);
	// for the dimensions of the diff and location pane, use the CSizingControlBar loader
	m_wndLocationBar.LoadState(_T("Settings"));
	m_wndDetailBar.LoadState(_T("Settings"));

	if (!m_bActivated) 
	{
		m_bActivated = true;

		// get the active child frame, and a flag whether it is maximized
		BOOL bMaximized = FALSE;
		CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);
		if (oldActiveFrame == nullptr)
			// for the first frame, get the restored/maximized state from the registry
			bMaximized = GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX);
		if (bMaximized)
			nCmdShow = SW_SHOWMAXIMIZED;
		else
			nCmdShow = SW_SHOWNORMAL;
	}

	CMDIChildWnd::ActivateFrame(nCmdShow);
}
예제 #2
0
bool COutlookFrame::VerifyBarState(LPCTSTR lpszProfileName)
{
    CDockState state;
    state.LoadState(lpszProfileName);

    for (int i = 0; i < state.m_arrBarInfo.GetSize(); i++)
        {
            CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
            ASSERT(pInfo != NULL);
            int nDockedCount = (int) pInfo->m_arrBarID.GetSize();
            if (nDockedCount > 0)
                {
                    // dockbar
                    for (int j = 0; j < nDockedCount; j++)
                        {
                            UINT nID = (UINT) pInfo->m_arrBarID[j];
                            if (nID == 0)
                                continue; // row separator
                            if (nID > 0xFFFF)
                                nID &= 0xFFFF; // placeholder - get the ID
                            if (GetControlBar(nID) == NULL)
                                return false;
                        }
                }

            if (!pInfo->m_bFloating) // floating dockbars can be created later
                if (GetControlBar(pInfo->m_nBarID) == NULL)
                    return false; // invalid bar ID
        }

    return true;
}
예제 #3
0
파일: MainFrm.cpp 프로젝트: DrDub/Byakhee
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	//create base
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1;

	//create child controls
	if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) return -1;
	if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) return -1;
	m_wndStatusBar.SetPaneText( m_wndStatusBar.CommandToIndex(ID_INDICATOR_LINENUMBER), "" );
	m_wndStatusBar.SetPaneText( m_wndStatusBar.CommandToIndex(ID_INDICATOR_POINTS), "" );

	//turn on tooltips
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()|CBRS_TOOLTIPS );

	//find the button to replace with the combo box
    int iPlaceHolder = 0;
    while( m_wndToolBar.GetItemID(iPlaceHolder) != ID_VIEW_SHEETSTYLE ) iPlaceHolder++;

    //change it to a separator and change it's width
    m_wndToolBar.SetButtonInfo( iPlaceHolder, ID_VIEW_SHEETSTYLE, TBBS_SEPARATOR, SHEETSTYLE_WIDTH );

    //get it's position on the toolbar and expand it so there is room for it to drop down
    RECT rc;
    m_wndToolBar.GetItemRect( iPlaceHolder, &rc );
    rc.bottom += 200;

    //create, change it's font and show it
    if(!m_wndSheetType.Create( WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL|CBS_DROPDOWNLIST|CBS_HASSTRINGS, rc, &m_wndToolBar, ID_VIEW_SHEETSTYLE)) return -1;
    m_wndSheetType.SendMessage( WM_SETFONT, (WPARAM)::GetStockObject(ANSI_VAR_FONT) );
    m_wndSheetType.ShowWindow(SW_SHOW);
    m_wndSheetType.EnableWindow(FALSE);

	//make toobar flat if requested by user
    if( AfxGetApp()->GetProfileInt( "Display", "FlatToolbar", TRUE ) == TRUE )
        m_wndToolBar.GetToolBarCtrl().ModifyStyle( 0, TBSTYLE_FLAT ); //make it flat

	//Initialize dialog bar m_wndOutput
	if (!m_wndOutput.Create(this, CSize(250,75), ID_VIEW_OUTPUT, CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC))
	{
		TRACE0("Failed to create output window\n");
		return -1;		// fail to create
	}

    m_wndOutput.SetWindowText( "Output" );
	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking( CBRS_ALIGN_ANY );
	DockControlBar(&m_wndOutput, AFX_IDW_DOCKBAR_BOTTOM);
	ShowControlBar(&m_wndOutput, FALSE, FALSE);

	//Load in the docked toolbar positions
	CDockState dockState;
	CString szToolbarPositionsKey;
	szToolbarPositionsKey.LoadString( IDS_TOOLBARKEY );
	dockState.LoadState( szToolbarPositionsKey );
	SetDockState( dockState );
	// CG: The following line was added by the Splash Screen component.
	CSplashWnd::ShowSplashScreen(this);
	return 0;
}
예제 #4
0
파일: sizecbar.cpp 프로젝트: zphseu/cuiyan
void CSizingControlBar::LoadState(LPCTSTR lpszProfileName)
{
    ASSERT_VALID(this);
    ASSERT(GetSafeHwnd()); // must be called after Create()

#if defined(_SCB_REPLACE_MINIFRAME) && !defined(_SCB_MINIFRAME_CAPTION)
    // compensate the caption miscalculation in CFrameWnd::SetDockState()
    CDockState state;
    state.LoadState(lpszProfileName);

    UINT nID = GetDlgCtrlID();
    for (int i = 0; i < state.m_arrBarInfo.GetSize(); i++)
    {
        CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
        ASSERT(pInfo != NULL);
        if (!pInfo->m_bFloating)
            continue;
        
        // this is a floating dockbar - check the ID array
        for (int j = 0; j < pInfo->m_arrBarID.GetSize(); j++)
            if ((DWORD) pInfo->m_arrBarID[j] == nID)
            {
                // found this bar - offset origin and save settings
                pInfo->m_pointPos.x++;
                pInfo->m_pointPos.y +=
                    ::GetSystemMetrics(SM_CYSMCAPTION) + 1;
                pInfo->SaveState(lpszProfileName, i);
            }
    }
#endif //_SCB_REPLACE_MINIFRAME && !_SCB_MINIFRAME_CAPTION

    CWinApp* pApp = AfxGetApp();

    TCHAR szSection[256];
    wsprintf(szSection, _T("%s-SCBar-%d"), lpszProfileName,
        GetDlgCtrlID());

    m_szHorz.cx = max(m_szMinHorz.cx, (int) pApp->GetProfileInt(
        szSection, _T("sizeHorzCX"), m_szHorz.cx));
    m_szHorz.cy = max(m_szMinHorz.cy, (int) pApp->GetProfileInt(
        szSection, _T("sizeHorzCY"), m_szHorz.cy));

    m_szVert.cx = max(m_szMinVert.cx, (int) pApp->GetProfileInt(
        szSection, _T("sizeVertCX"), m_szVert.cx));
    m_szVert.cy = max(m_szMinVert.cy, (int) pApp->GetProfileInt(
        szSection, _T("sizeVertCY"), m_szVert.cy));

    m_szFloat.cx = max(m_szMinFloat.cx, (int) pApp->GetProfileInt(
        szSection, _T("sizeFloatCX"), m_szFloat.cx));
    m_szFloat.cy = max(m_szMinFloat.cy, (int) pApp->GetProfileInt(
        szSection, _T("sizeFloatCY"), m_szFloat.cy));
}
예제 #5
0
파일: ChildFrm.cpp 프로젝트: skappert/mcp
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	CDockState dockstate;
	if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_bEnableFloatingBars = true;

	if (!m_ToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_TOOLBAR1) ||
		!m_ToolBar.LoadToolBar(IDR_TOOLBAR1))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	m_ToolBar.LoadToolBar(IDR_TOOLBAR1);
	m_ToolBar.SetPaneStyle( CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_TOP | CBRS_GRIPPER );
	m_ToolBar.EnableDocking( CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM );
	m_ToolBar.EnableReflections(true);
	EnableDocking(CBRS_ALIGN_ANY);
	
	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetPaneStyle(0,SBPS_STRETCH);

	if (!m_SaveDialog.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_TOOLBAR5) ||
		!m_SaveDialog.LoadToolBar(IDR_TOOLBAR5))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	m_SaveDialog.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_SaveDialog);
	DockPaneLeftOf(&m_ToolBar,&m_SaveDialog);

	m_SaveDialog.ShowWindow(true);
	
	dockstate.LoadState("ChildDockbars");
	SetDockState(dockstate);

	return 0;
}
예제 #6
0
void CChildFrame::ActivateFrame(int nCmdShow) 
{
	BOOL bMaximized = FALSE;
	CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);

	if (!m_bActivated) 
	{
		m_bActivated = TRUE;

		// get the active child frame, and a flag whether it is maximized
		if (oldActiveFrame == NULL)
			// for the first frame, get the restored/maximized state from the registry
			bMaximized = theApp.GetProfileInt(_T("Settings"), _T("ActiveFrameMax"), FALSE);
		if (bMaximized)
			nCmdShow = SW_SHOWMAXIMIZED;
		else
			nCmdShow = SW_SHOWNORMAL;
	}

	// load the bars layout
	// initialize the diff pane state with default dimension
	int initialDiffHeight = ((CMergeDiffDetailView*)m_wndDetailSplitter.GetPane(1,0))->ComputeInitialHeight();
	UpdateDiffDockbarHeight(initialDiffHeight);
	// load docking positions and sizes
	CDockState pDockState;
	pDockState.LoadState(_T("Settings"));
	if (EnsureValidDockState(pDockState)) // checks for valid so won't ASSERT
		SetDockState(pDockState);
	// for the dimensions of the diff and location pane, use the CSizingControlBar loader
	m_wndLocationBar.LoadState(_T("Settings"));
	m_wndDetailBar.LoadState(_T("Settings"));

	if (bMaximized)
	{
		// If ActivateFrame() is called without tricks, Resizing panes in MergeView window could be visible.
		// Here, two tricks are used.
		// [First trick]
		// To complete resizing panes before displaying MergeView window, 
		// it needs to send WM_SIZE message with SIZE_MAXIMIZED to MergeView window before calling ActivateFrame().
		// [Second trick]
		// But it causes side effect that DirView window becomes restored window from maximized window
		// and the process could be visible.
		// To avoid it, it needs to block the redrawing DirView window.
		// I had tried to use LockWindowUpdate for this purpose. However, it had caused flickering desktop icons.
		// So instead of using LockWindowUpdate(), 
		// I wrote My[Lock/Unlock]WindowUpdate() function that uses subclassing window.
		// 
		if (oldActiveFrame)
			MyLockWindowUpdate(oldActiveFrame->m_hWnd);
		
		RECT rc;
		GetClientRect(&rc);
		SendMessage(WM_SIZE, SIZE_MAXIMIZED, MAKELPARAM(rc.right, rc.bottom));

		CMDIChildWnd::ActivateFrame(nCmdShow);

		if (oldActiveFrame)
			MyUnlockWindowUpdate(oldActiveFrame->m_hWnd);
	}
	else
	{
		RecalcLayout();

		CMDIChildWnd::ActivateFrame(nCmdShow);
	}
}
예제 #7
0
파일: MainFrm.cpp 프로젝트: skappert/mcp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	// CG: This line was added by the Palette Support component
	CDockState dockstate;

	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7));
	CDockingManager::SetDockingMode(DT_SMART);
#if 0
	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | 
                          CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY );

	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
#endif

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_MAINFRAME_TOOLBAR1) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME_TOOLBAR1))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
	
	int nOrigSize = sizeof(indicators) / sizeof(UINT);

	UINT* pIndicators = new UINT[nOrigSize + 2];
	memcpy(pIndicators, indicators, sizeof(indicators));

	// Call the Status Bar Component's status bar creation function
	if (!InitStatusBar(pIndicators, nOrigSize, 60))
	{
		TRACE0("Failed to initialize Status Bar\n");
		return -1;
	}
	delete[] pIndicators;

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

	if (!m_wndLoadFileBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_TOOLBAR2) ||
		!m_wndLoadFileBar.LoadToolBar(IDR_TOOLBAR2))
	{
		TRACE0("Failed to create dialog bar m_wndLoadFileBar\n");
		return -1;		// fail to create
	}
	m_wndLoadFileBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);

	if (!m_wndGPS_HTMEAS.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_TOOLBAR3) ||
		!m_wndGPS_HTMEAS.LoadToolBar(IDR_TOOLBAR3))
	{
		TRACE0("Failed to create dialog bar m_wndGPS_HTMEAS\n");
		return -1;		// fail to create
	}
		
	m_wndGPS_HTMEAS.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);

	if (!m_wndISOLDE_PROTONS.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1), IDR_TOOLBAR4) ||
		!m_wndISOLDE_PROTONS.LoadToolBar(IDR_TOOLBAR4))
	{
		TRACE0("Failed to create dialog bar m_wndISOLDE_PROTONS\n");
		return -1;		// fail to create
	}

	m_wndISOLDE_PROTONS.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
	EnableDocking(CBRS_ALIGN_ANY);

	// dock all panes in desired right to left order
	DockPane(&m_wndLoadFileBar);
	DockPaneLeftOf(&m_wndISOLDE_PROTONS,&m_wndLoadFileBar);
	DockPaneLeftOf(&m_wndGPS_HTMEAS,&m_wndISOLDE_PROTONS);
	DockPaneLeftOf(&m_wndToolBar,&m_wndGPS_HTMEAS);

	dockstate.LoadState("Dockbars");
	SetDockState(dockstate);

	CSplashWnd::ShowSplashScreen(this);

	mytimer = SetTimer(TimerID,1000,NULL);

	return 0;
}
예제 #8
0
BOOL CMainFrame::VerifyBarState(LPCTSTR lpszProfileName)
{
	CDockState	state;
	state.LoadState(lpszProfileName);
	return(VerifyDockState(state, this));
}